How do real-x86 segments overlap help memory savings?

I have been teaching my 12 years. 8086, and yesterday we talked about memory, addressing, and segmentation. I showed him how segments can be visualized as a sequence of overlapping blocks of 64 Kbytes in size, starting at 16-byte boundaries, with the offset being a pointer to 8080 style in the segment. Then he asked a question that I could not answer: why (why, for what purpose) do they overlap ?

Trying to investigate this issue, I found many copies of 20-bit math and some vague references to memory savings, which this scheme apparently allows. Can anyone describe the spare part of the memory in detail? Or any other ways to make practical use of floors?

+4
source share
3 answers

The less overlapping, the less you will have a choice where a segment begins in physical memory. This creates gaps between segments that are not useful, thereby losing memory. Design choices never create a gap of more than 15 bytes. This overdoing is a bit, but perhaps 8086 was developed in an era when 1 megabyte was enough for everyone. And buying 64 kilobytes put a pretty big dent in your budget. Precious enough to not want to spend on spaces.

+2
source

Suppose you have a car parking service in a long narrow lane, so all cars are parked in the style of a parking lot. Some of your customers drive cars and use only 1 seat. Others move stretch limos and require 2 spaces. One way to park vehicles would be to assign 2 spaces for each car, regardless of size. Your declared tickets said: “The car is parked starting from space 0 (maximum vehicle size is 2 spaces)” or “starting from space 2” or “starting from space 4”, etc.

It will work, but it will save you from gaps, because you reserve 2 seats for cars that only need 1. Therefore, instead you pack the vehicles together and the cars take up only one place and the limousines take two. Your employees know that the car occupies only one place, therefore, if the ticket says that “starting from space 1 (the maximum size of the vehicle is 2 spaces)”, they know that “the car is in space 1 and space 2 belongs to to someone else". Car space 2 actually overlaps a limousine parked in spaces 2 and 3, but it would be a bad idea to use it or you are going to push a limo.

+2
source

Saving memory is a completely wrong way to look at it IMO. This processor came out at a time when the 16-bit address space became very hard. Other 16-bit address space processors have applied bank switching methods after the fact. The 20-bit address space was a significant statement (24, or 32-bit was just crazy talk at the time). Instead of sticking to an external bank switch (which is a pain for the program), they used registers. Well, guess what, the processor is 16-bit inside, so you can use 16-bit registers. Now getting 20 bits from a pair of 16-bit registers is an interesting problem. Using the segment as the main alignment of the paragraph gives you the full range (plus a bit of overspending, but this is a completely different problem) in the most flexible way (remember the pain of the banking conversations that I mentioned? This is primarily due to the inability to do this in a fine-grained way).

+2
source

Source: https://habr.com/ru/post/1389283/


All Articles