Mail Archives: djgpp/1999/06/20/03:44:07
On Thu, 17 Jun 1999, Michael Stewart wrote:
> limit--;
> /* Check for the limit being over 1MB */
> if (limit > 1024 * 1024) limit |= 0xfff;
Sorry, I failed to mention one subtle aspect of the limit. If the
segment is to be larger than 1MB, the limit should be set in 4KB
pages, not in bytes. So instead of setting the lower 12 bits, you
need to shift the limit 12 bits to the right (after rounding it up to
an integral multiple of 4KB). Then the problem with lower 12 bits
doesn't come up at all (it is only relevant for a call to
__dpmi_set_segment_limit, which accepts the limit in bytes).
Note that if you don't convert the limit to pages, "limit >> 16" might
overflow the 4-bit field in byte 6 that is allotted to the high part
of the limit.
Sorry for the confusion.
- Raw text -