具有32位地址大小的64位模式下的x86-64地址计算 [英] x86-64 address calculation in 64bit mode with 32-bit address-size

查看:283
本文介绍了具有32位地址大小的64位模式下的x86-64地址计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了有关64位模式下地址计算的英特尔手册.假设我们有64位模式,默认地址大小是64位.还要假设有问题的指令前面有地址大小覆盖前缀,因此地址大小变为32位.

I read Intel manual about address calculation in 64 bit mode. Suppose we have 64 bit mode, default address size is 64 bit. Suppose also that instruction in question is preceded by address size override prefix, so address size becomes 32 bit.

现在,假设该指令使用寄存器编号0(rax/eax/ax ...)指定的地址对内存操作数进行编码.

Now, imagine that instruction encodes memory operand with address specified by register number 0 (rax/eax/ax ...).

现在我还不完全了解,CPU是否仅查看eax值并在内部进行零扩展以形成本地" 64位地址,还是查看整个rax值并将其截断为有效的32位范围(例如rax包含5Gb之类的内容,而CPU会将其剪切为最大32位地址).

Now the thing that I don't fully understand, whether CPU looks only at eax value and internally zero-extends it to form "native" 64 bit address or it looks at whole rax value and truncate it to valid 32 bit range (for example, rax contains something like 5Gb and CPU cuts it to max 32 bit address).

推荐答案

在64位处理器上使用32位寻址时,地址计算的结果被截断为32位,然后零扩展为64位.请注意,将32位寻址定义为使用32位寄存器,因此,如果RAX包含140000000h(5GB),则改用EAX(40000000h)的值.尽管这在实践中并没有多大区别.

When 32-bit addressing is used on 64-bit processors the result of the address calculation is truncated to 32-bits and then zero extended to 64-bits. Note that 32-bit addressing is defined as using using 32-bit registers, so if RAX contains 140000000h (5GB) the value of EAX (40000000h) is used instead. Although this doesn't make much of a difference in practice.

摘自《 Intel 64和IA-32体系结构软件开发人员手册》第1卷: 基本架构:

From the Intel 64 and IA-32 Architectures Software Developer’s Manual Volume 1: Basic Architecture:

在IA-32e模式下,所有16位和32位地址计算都进行零扩展以形成64位地址.地址 首先将计算结果截断为当前模式(64位模式或兼容性)的有效地址大小 模式),由任何地址大小前缀覆盖.然后将结果零扩展到整个64位地址宽度. 因此,以兼容模式运行的16位和32位应用程序只能访问4 GB的低字节数据. 64位模式的有效地址.同样,以64位模式生成的32位地址只能访问低位地址. 4 GB的64位模式有效地址.

All 16-bit and 32-bit address calculations are zero-extended in IA-32e mode to form 64-bit addresses. Address calculations are first truncated to the effective address size of the current mode (64-bit mode or compatibility mode), as overridden by any address-size prefix. The result is then zero-extended to the full 64-bit address width. Because of this, 16-bit and 32-bit applications running in compatibility mode can access only the low 4 GBytes of the 64-bit mode effective addresses. Likewise, a 32-bit address generated in 64-bit mode can access only the low 4 GBytes of the 64-bit mode effective addresses.

这篇关于具有32位地址大小的64位模式下的x86-64地址计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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