delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/03/00:33:10

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: real-mode pointers
Date: Wed, 30 Jul 1997 21:25:38 +0100
Organization: None
Distribution: world
Message-ID: <fPq0HJACN63zEwOT@talula.demon.co.uk>
References: <33DF967A DOT 2A6C AT indy DOT net>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 40
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019