Calculate Segment:Offset from absolute address

不羁岁月 提交于 2019-12-01 23:52:26
Necrolis

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.

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


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 (top 16 bits)
  • offset = linear & 0x0F (low 4 bits)

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!