CPU为什么会有段?像cs, ds, ss等等。这个问题困扰了我很久,感觉有了段地址后把问题复杂化了,没必要这么做。
后来翻查资料后才发现,段(segment)的存在原来是有历史因素的:http://homepage.smc.edu/morgan_david/cs40/segmentation.htm
以下是摘抄和个人见解
“Vintage 1980 microcomputers used physical addressing, and confined themselves to using 4-digit hexadecimal numbers (which is the same thing as 16 bits) as addresses. The highest you can count with a 4-digit hexadecimal number is FFFF in hex, equivalent to 65535 in decimal. So no more than 65536 bytes or 64K of memory could be used. Even if you could have installed more, the computer could not have used it for lack of ability to refer to it.”
1980年的程序是只有16bit大小的内存空间的,也就是只支持64k的内存,寻址只能从0000-FFFF,也就是 汇编 里的
mov edx AFFFF
这样的指令和程序是不会被执行通过的。
The IBM PC appeared in 1981 and was a fundamental redesign of the earlier microcomputer generation. The designers wanted to allow for 1MB of memory, or 16 times as much as the previous 64K limit. However for design reasons they did not wish to use numbers wider than 16 bits in their addressing system. So they overcame the limit by inventing a system of compound addresses. Each compound address contained 2 16-bit numbers, to be interpreted in a special way. These were the first "segmented addresses" in microcomputers. Coinciding with this was the appearance of a new CPU chip design with new registers to facilitate the new addressing method. (The CPU designers at Intel and the PC architects at IBM worked hand-in-glove designing each piece with the other in mind.)
when he wishes to talk about 763. He now has a way to talk about it, but has successfully avoided using 3-digit numbers. Note he could land on 763 several other ways. For example, by starting at 750 instead of 760, then advancing 13 instead of 3. Just as the 43 yard line on the gridiron is equivalently a 3 yard gain from the 40, a 13 yard gain from the 30, or a 23 yard gain from the 10. All, same thing. So our engineer could write any of the following to refer to 763:
76:03
75:13
74:23
73:33
72:43
71:53
70:63
69:73
68:83
67:93