Re: Low Level Mem Question & Return

new topic     » topic index » view thread      » older message » newer message

From:    Alan Tu
Subject: Re: Low Level Mem Question & Return

>Runtime error 200 at 1B14:0091.

>If I should multiply by 16 to get a linear address, shouldn't the
>offset be no greater than f?  1B14:0091, couldn't this be better
>represented by 1B1D:1
>Or, can a single byte be represented in infinite ways in real mode?

Real-mode                                          Protected Mode
 Seg:Offs  -----------Conversion--------------->   physical addr
1B14:0091  #1B14 * #10 = #1B140.  #1B140 + #0091 = #1B1D1
1B1D:1000  #1B1D * #10 = #1B1D0.  #1B1D0 + #0001 = #1B1D1

   Both of those s:o addresses actually point to the same byte in
memory.  So yes, and yes.  You could write it either way, so there
are several (not infinite, but lots of) ways to represent any address
in real-mode.  But the best would be 1B1D:1.  You just stated the
concept of Normalized Addresses...something I'd skipped over.

"  If you need to compare two [real mode] addresses for (in)equality,
you can use normalized addresses. Normalized addresses take a special
form so they are all unique.  [...]  By convention, most programmers
(and high level languages) define a normalized address as follows:
  The segment portion of the address may be any 16 bit value.
  The offset portion must be a value in the range 0..0Fh.
Normalized pointers that take this form are very easy to convert to a
physical address. All you need to do is append the single hexadecimal
digit of the offset to the segment value.  "
--<a
1-91">4.4 The Art Of Assembly</a>


    You actually knew that and were just testing me, right?  smile

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu