问题
While reading The Art of Assembly the other day, I came to the section here on memory layout. It started discussing segmented memory, and I didn't think it made a lot of sense.
Splitting memory into segments makes perfect sense as a way for organization, but using the function segment + offset
, what do you do when the function repeats its outputs? e.g. 1038 + 57
, 57 + 1038
, and 1095 + 0
all come out to the linear address 1095. Isn't that a bad thing? Wouldn't you accidentally address the same linear memory space when you didn't mean to?
Wikipedia says it can be used to an advantage, "for example when addressing multiple nested data structures," but how is this be used to address nested structures quicker?
回答1:
You missed an important part of the text how these address are calculated.
On the 8086, 8088, 80186, and 80188 (and other processors operating in real mode), the function that maps a segment to a physical address is very simple. The CPU multiplies the segment value by sixteen (10h) and adds the offset portion.
And dont forget that these addresses are always calculated in hexadecimal system.
来源:https://stackoverflow.com/questions/18264979/x86-segmented-memory