Mail Archives: djgpp/1997/08/03/00:33:10
Chris Frolik writes:
>Is there ANY way to get the real-mode segment:offset of a variable (or
>block of allocated memory) in DJGPP? I am assuming there is, because:
There is no such way. That's why the FAQ says you have to copy your data
into a conventional memory buffer: real mode code can only access the
first megabyte of memory, so there's no way to convert an arbitrary
protected mode address into a format that it can understand...
>1) Every variable must have an address somewhere in memory
True.
>2) Every address in memory can be accessed using the segment:offset
>notation
Untrue. Real mode segments are 64k in size, right? But they overlap, and
each one starts only 16 bytes after the previous one. A 16 bit segment
multipled by a 16 byte granularity = 1 meg. There is absolutely no way
to access memory past that limit (well, actually you can go up to 1 meg
+ 64k - 16 bytes, using offsets from segment 0xFFFF). That is the origin
of the infamous 640k DOS memory limit (because addresses above
0xA000:0000 are reserved for the video card and BIOS), and is the very
reason that protected mode is such a good idea in the first place...
>You are probably wondering why I need this...well, my interrupt requires
>ES:SI to point to a buffer in memory. I am using conventional memory
>and __dpmi_int for this like the FAQ said. However, in this buffer that
>ES:SI points to, there is a pointer that points to more information :-)
That pointer must also refer to a conventional memory location, and the
data must be copied there before the real mode code can access it. To
convert a 32 bit offset like you would pass to dosmemput() into a 16 bit
seg:offset, just set the segment to (address/16) and the offset to
(address%16).
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -