Where system stores 16 segment addresses while segment registers are 4?

Viewed 47

In real mode memory addressing there are 16 segments made with the size of 64KB, and there are 4 segment registers, so where system store those 16 addresses?

 0. 00000
 1. 10000
 2. 20000
 3. 30000
      :
      :
14. E0000
15. F0000

For example, if my system respectively uses the first 4 segment starting addresses in CS, DS, ES, and SS. Where will the remaining 12 addresses be stored?

1 Answers

There is no need to store them anywhere. You load your segment address (which doesn't have to be on a 64K boundary, by the way - only at a multiple of 16) into the segment register of your choice/need when you use it.

For example, let's say I want to load some value at physical address 0x12345 into al. Then I'd do mov ds, 0x1234 followed by mov al, [0x5] (note that this instruction implicitly uses ds:, but you could also specify it manually) - or mov ds, 0x1000; mov al, [0x2345], or any other combination that adds up to the value I want (physical address = segment * 16 + offset). I'd usually organize my memory in such a way that the things I often need together are reachable with the same segment, i.e. are within 64K, so I wouldn't have to switch segments all the time.

Related