简体   繁体   English

段的绝对地址:偏移量转换

[英]Absolute Address to Segment:Offset Conversion

I was learning and reading about Segment:Offset conversion and all that. 我正在学习和阅读有关Segment:Offset转换的信息。 Our teacher told us how to calculate the absolute address from S:O which is pretty simple (*10 + Offset). 我们的老师告诉我们如何从S:O计算绝对地址,这非常简单(* 10 +偏移)。 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. 他要求我们将S:O转换为绝对值,我告诉他这是不可能的,他要求我们对此进行“进一步研究”。

I've read about the whole overlapping segments and how many S:O can point to the same absolute address. 我已经阅读了整个重叠的段,以及有多少S:O可以指向同一绝对地址。 I also read an older question here: Calculate Segment:Offset from absolute address 我在这里也阅读了一个较旧的问题:从绝对地址计算Segment:Offset

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 然后是这里的问题: 在8086微处理器中查找物理地址

Where he simply just splits the absolute address, adds zeros and makes it S:O. 他只是将绝对地址拆分成零,然后加零并使其变为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 . 问题是08F1:0100 ,我可以将其转换为09010 If I were to try to get at least 1 or 2 valid S:O addresses, what should I do? 如果我试图获得至少1或2个有效的S:O地址,该怎么办?

As you say, to go from a Segment:Offset pair to an absolute address you do 如您所说,要从Segment:Offset对转到绝对地址,您需要

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. 由于SegmentOffset都是16位实体,因此很明显,段和偏移有多对值会产生相同的绝对地址。

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 . 通常在过去(十年来我一直没有对16位代码进行编码),当朝另一个方向前进时,我只将完整的20位地址中的那4位放置在偏移量中的段部分,因此,对于您的绝对地址0x9010 ,segment:offset地址将为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. 请注意,分段和偏移值的任何组合产生0x9010的完整值0x9010 ,对于访问所讨论的内存同样有效,因此,没有任何一种组合比其他组合更能访问例如单个字节。 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. 但是,将偏移部分的大小保持尽可能小允许在最大可能的缓冲区上进行迭代,而不必修改地址的段部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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