计算段:与绝对地址的偏移量 [英] Calculate Segment:Offset from absolute address

查看:164
本文介绍了计算段:与绝对地址的偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将地址Segment:Offset计算为Segment * 0x10 + Offset.但是我该如何计算相反的结果呢?

I can calculate an address Segment:Offset as Segment * 0x10 + Offset. But how do I calculate the opposite?

例如如何从0xF4170F400:0170以及从0xACF04ABCD:1234?

E.g. how do I get from 0xF4170 to F400:0170 and from 0xACF04 to ABCD:1234?

推荐答案

由于多个Segment:Offset对可以映射到相同的对,因此您需要具有基数或起始偏移量以及线性地址线性地址.

You would be required to have either the base or the offset to start with, along with the linear address, as multiple Segment:Offset pairs can map to the same linear address.

因此,如果我们有段0xF400和线性地址0xF4170,则得到的偏移量为0xF4170 - (0xF400 << 4),即0x170.

so if we have the segment 0xF400 and the linear address 0xF4170, we get the offset being 0xF4170 - (0xF400 << 4) which is 0x170.

仅知道线性地址就没有唯一的解决方案,因此您必须选择一种约定,将20位地址拆分为16字节对齐的seg部分和字节偏移量.一种可能的功能是:

Doing this with only knowing the linear address doesn't have a unique solution, so you have to choose a convention for splitting a 20-bit address into a 16-byte-aligned seg part and a byte offset. One possible function is this:

  • Segement = linear >> 4(前16位)
  • offset = linear & 0x0F(低4位)
  • Segement = linear >> 4 (top 16 bits)
  • offset = linear & 0x0F (low 4 bits)

您可以选择12:8位的规范格式,从而为将来扩展更宽的线性地址留出空间.

You might choose a canonical form with 12:8 bits, leaving room for future expansion with wider linear addresses.

这篇关于计算段:与绝对地址的偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆