From: "Patrick Smith" Newsgroups: comp.os.msdos.djgpp Subject: Re: pmode selectors Date: 18 Dec 1996 07:45:13 GMT Organization: Traveling Software Lines: 40 Message-ID: <01bbecb7$9eefb320$be7f10ac@ps.travsoft.com> References: <19961216 DOT 052713 DOT 8263 DOT 0 DOT aclemmer AT juno DOT com> <19961217 DOT 074132 DOT 12471 DOT 2 DOT aclemmer AT juno DOT com> NNTP-Posting-Host: t1.travsoft.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Aaron, The hex numbers 0x000FFFFF and 0xFFFFF both equal 1048575 (or 2 to the 20th power). This is the same as 0x000F and 0xF both equal the number 15. Hex is like base 10 in that zeros to the left do not affect the value (e.g. 1,245 and 001,245). Therefore both my mask of (__tb & 0x000FFFFF) and Shawn's mask of (__tb & 0xFFFFF) yield the same result. The only reason I use the more 'formal' mask is because I like to remind myself what is really going on. We are masking off the high 12-bits and keeping the low 20-bits -- when I look at my mask it reminds me of both operations. It also reminds me that __tb is a 32-bit number... Basically, I find it makes the code a little more 'self-documenting' -- a purely personal choice. Sorry for the confusion... Patrick Smith, Traveling Software Aaron m Clemmer wrote in article <19961217 DOT 074132 DOT 12471 DOT 2 DOT aclemmer AT juno DOT com>... > On 16 Dec 1996 17:02:54 GMT "Patrick Smith" > writes: > >The protected mode selector for any buffer in conventional (dos) memory > is > >the global variable, _dos_ds. In order to use the transfer buffer > (__tb), > >simply use _dos_ds for the selector and the value of (__tb & 0x000FFFFF) > as > >the offset. Note: The reason you mask off the upper 12-bits is because > >real-mode dos only uses 20-bit adresses... > Well, between all these replies I've gotten, I finally understand > what I should be doing, and what I was doing wrong. > There may be no difference (but I believe there is), but if you > say (__tb & 0x000fffff), and Shawn H says (__tb &0xfffff), wouldn't one > be incorrect? > > aaron >