Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Peter Norton Programmer's Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

  One of the most common uses of hex numbers is for memory addressing. You
  may recall from Chapters 2 and 3 that a complete 8086 address is 20
  bits, or 5 hex digits, wide. Since the 8086 microprocessor can work only
  with 16-bit numbers, addresses are broken into two 16-bit words, called
  the segment and the relative offset. The two parts are written together as
  1234:ABCD. The segment is always written first, and both segment and
  offset are given in hexadecimal form.

  The 8086 treats the segment of an address as if it were multiplied by 16,
  which is the same as if it had an extra hex 0 written after it. The two
  parts, added together, yield the actual 20-bit address that they
  represent. For example, the segmented address 1234:ABCD converts into a
  complete address like that shown on the following page.

      1 2 3 4 0  (note the zero added on the right)
    +   A B C D
    -----------
      1 C F 0 D

  If you need to calculate the actual address that a segmented address
  refers to, follow this formula. The addition tables on page 474 may also
  help.

  On the 8086, many different segmented addresses correspond to the same
  location in memory. For example, the address 00400H (where the ROM BIOS
  keeps its status information) is equally well represented as 0000:0400H
  and 0040:0000H. (Of course, this does not hold true in protected mode on
  an 80286 or 80386, as we saw in Chapter 2.)

  There is no one best way to break an actual 8086 address into its
  segmented format. One simple way is to take the first digit of the actual
  20-bit address followed by three zeros as the segment-paragraph part, and
  the remaining four digits as the relative part. Following this rule, the
  address above, 1CF0D, would be separated out as 1000:CF0D. IBM's listing
  for the ROM BIOS in the IBM PC Technical Reference Manual follows this
  convention, so all relative addresses appearing there have the (unshown)
  segment of F000.

  When you are working with real segmented addresses, the segment will
  represent the actual contents of one of the segment registers and could
  point to nearly anywhere in memory. The relative offsets typically vary
  with usage. Information in executable code and data segments generally
  starts at a low relative offset. For example, the first instruction of a
  COM program is always at offset 100H in its segment. In contrast, stack
  segments usually use high relative offsets because stacks grow toward
  lower addresses.

  To see the sort of segmented addresses in use when a program is executed,
  run the DOS DEBUG program. When DEBUG begins, it will give you a command
  prompt of -. When you enter the single-letter command D, DEBUG will
  display part of memory; the addresses on the left are typical segmented
  addresses.

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