www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/10/05/19:24:41

Date: Wed, 5 Oct 1994 09:26:24 -0700
From: elf AT netcom DOT com (Marc Singer)
To: djgpp AT sun DOT soe DOT clarkson DOT edu, sl5h9 AT cc DOT usu DOT edu
Subject: Re: segment:offset notation

>    I need to know how to convert a standard memory address to segment 
> offset notation.  If I do this will it work? :
> 
> segment = address / 16
> 
> offset = address % 16
> 
>   or is that entirely wrong?

Yes.  This is entirely wrong.  You are making the understandable
assumption that the 32 bit address is a segment:offset style address.
The reason we like djgpp is that we DON'T have such a beast.  Our 32
bit addresses are linear, contiguous.  When you pass pointers, you are
not passing the segment address because it is implicit.  CS, DS, and
SS are all the same.  The address you get from an expression such as:
  int foo;
  int* pfoo = &foo;
is only the offset, &foo.  If you want to pass segments to DOS, you
need to create an alias for the seg16:off32 that is seg16:off16.  This
is where my knowledge of x86 carries us.  There must be a function in
the go32 extender that permits such a conversion.

Marc Singer
elf AT netcom DOT com

- Raw text -


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