Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does x86 real-mode segments overlap help memory saving?

I'm teaching my 12 y.o. 8086 assembly language and yesterday we were talking memory, addressing and segmentation. I showed him how segments can be visualized as a sequence of overlapping 64Kb blocks starting on 16 byte boundaries, with the offset being an 8080-style pointer within a segment. Then he asked a question I could not answer: why (what for, with what purpose) do they overlap?

Trying to research this question I found many copies of the 20 bit math, and a few vague mentions of some memory savings this scheme presumably allows. Can somebody elaborate on the memory saving part? Or any other ways to take practical advantage of the overlaps?

like image 453
Stop Putin Stop War Avatar asked Jan 04 '12 14:01

Stop Putin Stop War


1 Answers

The less overlap, the less choice you'll have over where a segment starts in physical memory. That creates gaps between segments that are not useful, thus wasting memory. The design choice never creates a gap larger than 15 bytes. That's overdoing it a bit perhaps but 8086 was designed in an era where 1 megabyte was enough for everybody. And buying 64 kilobytes put a rather large dent in your budget. Precious enough to not want to waste on gaps.

like image 164
Hans Passant Avatar answered Sep 28 '22 03:09

Hans Passant