当我有物理地址时,如何获取段内存地址? [英] How to get segment memory address, when i have physical address?

查看:234
本文介绍了当我有物理地址时,如何获取段内存地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储单元的物理地址以1A32H的形式给出.内存段开头的地址是什么.更确切地说,我应该使用seg:off地址来访问它.

The physical address of the memory cell is given in the form 1A32H. What is the address of the beginning of the memory segment. Or more exactly, the seg:off address I should use to access it.

有人可以一步一步解释我如何解决这个问题吗?

Can someone explain me step by step how to solve this problem?

推荐答案

在x86实模式下,物理地址的计算方式为:

In x86 real-mode, the physical address is calculated as:

16 *细分+偏移量

16 * segment + offset

因此可以通过不同的方式访问物理地址1A32H:

So the physical address 1A32H can be accessed in different ways:

段= 1A3H,偏移= 2或
段= 1A2H,偏移= 12H或
段= 1A1H,偏移= 22H或
...
段= 0,偏移= 1A32H

Segment = 1A3H, Offset = 2 or
Segment = 1A2H, Offset = 12H or
Segment = 1A1H, Offset = 22H or
...
Segment = 0, Offset = 1A32H

要根据您的用例选择细分和偏移量的组合:

It depends on your use case which combination of segment and offset you chose:

如果该地址是内存范围的起始地址(例如,数组的第一个元素),则将使用较高的段值(段1A3H,偏移量2H).

If the address is the start address of a memory range (e.g. the first element of an array), you would use a higher segment value (segment 1A3H, offset 2H).

如果该地址是内存范围的结束地址(例如初始堆栈指针),则将使用较低的段值(段0,偏移量1A32H).

If the address is the end address of a memory range (e.g. initial stack pointer), you would use a lower segment value (segment 0, offset 1A32H).

请注意,偏移量是一个16位数字.

Please also note that the offset is a 16-bit number.

因此,使用段值0不能访问> = 2 ^ 16的物理地址:

So physical addresses >= 2^16 cannot be accessed using a segment value of 0:

可以使用以下地址访问地址1A325H(例如)

Address 1A325H (as an example) can be accessed using:

段= 1A32H,偏移= 5或
段= 1A31H,偏移= 15H或
...
细分= 0A33H,偏移= 0FFF5H

Segment = 1A32H, Offset = 5 or
Segment = 1A31H, Offset = 15H or
...
Segment = 0A33H, Offset = 0FFF5H

这篇关于当我有物理地址时,如何获取段内存地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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