1

I know the ABSOLUTE ADDRESS of the next instruction is located 50000 (hex), and I know that the hex value that should be in the IP Register is 4000 (hex). My question is... Why does it work like this?

I have the other registry values available if they're needed.

Any idea?

Raven Dreamer
  • 6,940
  • 13
  • 64
  • 101
  • 1
    If you are in segmented memory mode then there is a Code Segment register that contains an offset you have to add to the IP to get the absolute address of the next instruction. – Amardeep AC9MF Jun 15 '10 at 14:52

1 Answers1

2

The weirdness of 8086 addressing (inherited by all later Intel chips) is segmentation. The registers are all 16-bit, but addressable memory is 1 Meg = 2 power 20, i.e. you need 20 bits for an address.

The geniuses at Intel decided to use two registers to form full address - a segment register (CS, DS, SS, ES) that is shifted left 4 bits, then added with offset register to form full 20-bit address.

So the value in IP is the offset from the value in CS (code segment). From what you said the value in CS should be (0x50000 - 0x4000) >> 4 = 0x4c00.

Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171