简体   繁体   中英

Absolute Address to Segment:Offset Conversion

I was learning and reading about Segment:Offset conversion and all that. Our teacher told us how to calculate the absolute address from S:O which is pretty simple (*10 + Offset). He asked us to convert S:O to absolute, I told him that wasn't possible and he asked us to do 'further research' on it.

I've read about the whole overlapping segments and how many S:O can point to the same absolute address. I also read an older question here: Calculate Segment:Offset from absolute address

The answer says it's not possible using only the absolute address, and that makes perfect sense.

Then there's this question here: finding physical address in 8086 microprocessor

Where he simply just splits the absolute address, adds zeros and makes it S:O. Now I'm confused, is this correct? He simply used the absolute address.

This isn't a homework question or anything. I just want to confirm that my answer is correct ie not possible. The question is simply 08F1:0100 which I can translate to 09010 . If I were to try to get at least 1 or 2 valid S:O addresses, what should I do?

As you say, to go from a Segment:Offset pair to an absolute address you do

Absolute = Segment * 16 + Offset

Since Segment and Offset are both 16-bit entities, it's clear that there are multiple pairs of values for segment and offset that yield the same absolute address.

Typically in the past (I haven't coded anything 16-bit for well over a decade), when going in the other direction, I would put only those 4 bits of the full 20-bit address that can't be represented in the segment portion in the offset, so that, for your absolute address of 0x9010 , the segment:offset address would be 0x901:x0 .

Note that any combination of segment and offset values that yields the full 20-bit value of 0x9010 would work equally well for accessing the memory in question, so there isn't any one combination that is better than others for accessing, say, a single byte. However keeping the magnutude of the offset portion as small as possible allows for iterating over the greatest possible buffer without having to modify the segment part of the address.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM