Mail Archives: djgpp/1998/04/26/23:30:21
At 08:10 4/25/1998 +0200, Elias Pschernig wrote:
>Hi, i have a question !
>
>Using my old (real mode) C-compiler, i could
>convert a pointer to a long-integer and then
>converting it to a seg:off address.
>
>Now i wanted to know, what exactly do
>i get, when i print out a pointer under
>DJGPP-C, like in the following example ?
>
>void printpointer(void *ptr)
>{
> int n=ptr; // convert 32bit ptr to 32bit int
> // (=convert nothing at all ?)
> printf("%d",n);
>}
>
>What does the number printed out mean ?
>Is it a far (selector included) or a
>near pointer ?
It is a 32-bit near pointer, relative to the program's DS segment.
>What exactly is stored in the 32 bits of ptr ?
An offset.
>How can i get the absolute address (from
>absolute zero) of it - using this value ?
Weeeel... You can get the base address of the DS segment with DPMI
functions, and add that to the offset. But that will just give you the
linear address, and the paging mechanisms make that a totally different
thing from the physical address, which there's no good way to find. Why do
you need it?
Nate Eldredge
nate AT cartsys DOT com
- Raw text -