Node:RM Addressing, Next:, Previous:Introduction, Up:Top

2 Addressing in Real Mode

In the 8086-type processors, memory is organized into bytes (8 bits=1 byte). When dealing with quantities larger than eight bits, the 8086 stores the least significant byte in the lowest address. While that sounds logical, it's confusing when you're reading listings or memory dumps because the numbers seem backwards. For instance, the computer stores the word B800H as two bytes: 00H followed by B8H.

The Intel family of processors use a memory-addressing technique known as segmentation. A segment is a region of memory. The computer can handle multiple segments. In real mode (the one in which DOS normally runs), each segment is 64K long and there are 65536 possible segments. But these segments overlap so that each starts 16 bytes after the one before it. This is why DOS cannot address more than 1MB directly (65536 * 16 = 1048576 = 1MB). The 8086 and 8088 can only address 1MB anyway. The 286, 386+ can accomodate much more memory, but DOS cannot access it directly.

Segments are numbered from 0000H to FFFFH. Since each segment is 64KB long, we use a value called an offset, to specify the byte we want to address. A complete 8086 address always contains a segment and an offset.

If a segment is 0040H and the offset is 0102H, we write
0040:0102. Because segments overlap every 16 (10H) bytes, address
0000:0010 is identical to address 0001:0000. Likewise 0040:0000 is the
same as address 0000:0400, which is the same as 0020:0200. The computer
also stores segmented addresses ``backwards''. For instance, 0040:1234
appears like this in the computer's memory (in hex):

34 12 40 00

To verify that all the addresses above are the same, convert them to
linear addresses. To convert a segmented address to linear address,
multiply the segment value by 16 (10H) and add the offset.

So, we have (all in hex)

0040 * 10 + 0000 = 00400
0000 *  0 + 0400 = 00400
0020 * 10 + 0200 = 00400

all of which ultimately point to the same area of memory.



Copyright (C) 2000, 2001 Prashant TR. All rights reserved.