From: silkwodj AT my-dejanews DOT com Newsgroups: comp.os.msdos.djgpp Subject: Re: Question from a beginner Date: Tue, 22 Dec 1998 14:14:33 GMT Organization: Deja News - The Leader in Internet Discussion Lines: 42 Message-ID: <75o9g7$9tf$1@nnrp1.dejanews.com> References: <75licm$pm9$1 AT toto DOT tig DOT com DOT au> NNTP-Posting-Host: 205.147.228.2 X-Article-Creation-Date: Tue Dec 22 14:14:33 1998 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95) X-Http-Proxy: 1.0 x8.dejanews.com:80 (Squid/1.1.22) for client 205.147.228.2 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In article <75licm$pm9$1 AT toto DOT tig DOT com DOT au>, "Tim Czvetics" wrote: > I am writing some code in which I use a pointer to an unsigned char, and I > need to find the segment and offset of that pointer. How do I go about doing > it? > > Thanks. > Welcome to 32-bit protected mode. You probably only need the offset. We have selectors, not segments. Of course you can get an offset by dereferencing the pointer int offset = &ptr. If you really want to know what selector the OS has given your (flat model) code, the following is copied from the libc help file: _my_ds Syntax #include unsigned short _my_ds(); Description Returns the current `DS'. This is useful for setting up interrupt vectors and such. Return Value `DS' You obviously wish to port some example code from 16-bit real mode. DGJPP is a bit more advanced in that it is a 32-bit protected mode compiler only. Don't lose heart, it's not that difficult and I have found the challenge very interesting. There is an introduction in the FAQ, but it's not that comprehendable to a beginner. Matt Mastracci wrote a tutorial that turned the light on for me. http://www.acs.ucalgary.ca/~mmastrac/files/djgppasm.html After a while you will put your nose in the DPMI specification, then you know you've gone over the edge. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own