Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- CA-Clipper/ExoSpace 1.0g - <b>real-mode addressing</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Real-Mode Addressing
------------------------------------------------------------------------------

     The standard way to designate a memory location in real mode is with
     segment:offset notation, usually written with hexadecimal digits.  The
     segment portion of the address refers to a base location in memory.  The
     offset designates the number of bytes from the base.

     In real mode, a logical address in segment:offset notation refers to a
     specific location in physical memory.  For example, if you use the C
     code below to assign a value to the variable MyPointer, you can
     dereference MyPointer and get the contents stored at physical address
     3B004 (logical address 3B00:0004):

     char far *MyPointer;
     MyPointer = (char far *)(((long)0x3B00 << 16) + 0x4);

     From the logical address 3B00:0004, the CPU takes the segment address
     and multiplies it by 0x10 to get the base location 0x3B000.  Then it
     adds the offset component, to arrive at the physical address 3B004.
     Using 20 bits, a CPU running in real mode can address up to 1 MB (00000-
     FFFFF) of physical memory.

     From each base address, the CPU can utilize offset values from 0000 to
     FFFF, allowing it to address up to 64 KB for each segment of memory.

     You can utilize as many as 4096 different segment:offset addresses that
     refer to the same physical address in real mode.  For example, the
     address 3AFF:0014 refers to the same address as 3B00:0004:

     0x3AFF * 16 = 0x3AFF0
     0x3AFF0 + 0x0014 = 0x3B004

     In real mode, you can utilize offsets of up to 0xFFFF within any
     segment, whether it is logically correct or not.  If you use an address
     beyond the boundaries of your allocated segment of memory, it is easy to
     overwrite code or data in another segment or program, or even in the
     operating system.  Also, in real mode, you can use any address as code
     or as data, so your program can store data in a code segment or attempt
     to execute data.


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson