views:

20

answers:

1

Hi guys.

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?

+1  A: 

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 N Fetissov
Much obliged. I knew something was being offset, but I wasn't quite sure where. Thanks!
Raven Dreamer