gpt4 book ai didi

c - 在 x86 汇编方面需要一些帮助

转载 作者:行者123 更新时间:2023-12-02 06:22:50 26 4
gpt4 key购买 nike

MODRM_EAX_06 MACRO   ;/* [EAX], with reg/opcode: /6 */ 
BYTE 030h
ENDM

字节 030h 是做什么的?

有关此宏用于其他信息

void vmxPtrld(u64 addr) 
VmxPtrld PROC StdCall _addr_low,_addr_high
mov eax,8
add eax,ebp
vmx_ptrld
MODRM_EAX_06
ret
VmxPtrld ENDP

我只是想了解下面代码中宏的作用?

最佳答案

许多操作码后面跟着一个 ModR/M 字节,它被分成 3 部分:前两位是“Mod”,接下来的三位是“Reg”,后三位是“R/M”。

“Mod”和“R/M”部分的组合指定了寄存器和寻址模式; “Reg”部分可以指定另一个寄存器,或者在某些情况下,可以指定操作码的进一步扩展。

在这种情况下,ModR/M 字节如下所示:

    0 0 1 1 0 0 0 0    \_/ \___/ \___/    Mod  Reg   R/M

Mod bits of 00 and R/M bits of 000 mean an addressing mode of [EAX] (in 32-bit mode).

The remaining Reg bits are 6 in decimal. Hence MODRM_EAX_06.

To fully understand what is going on in your example, you need to know what the vmx_ptrld macro does. Assuming that this is indeed what @sixlettervariables found, vmx_ptrld produces bytes 0F C7.

0F is the first byte of a two-byte opcode. In many cases, the next byte will complete the opcode; but C7 indicates that further bits must be read from the Reg field of the ModR/M byte to determine what the opcode is. So the final opcode is 0F followed by C7 followed by the 6 from the Reg field of the ModR/M byte, written as 0F C7 /6 in Intel's manuals (which can be found here).

0F C7 /6 is VMPTRLD, so the real meaning of your routine is:

mov eax,8 
add eax,ebp
vmptrld [eax]
ret

大概是为了不理解(相对较新的)VMX 指令的旧汇编器的利益而这样编写的。

关于c - 在 x86 汇编方面需要一些帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6499464/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com