问题描述
我想知道x86组装中的括号.在此示例中,寄存器ax
应该包含X
,因为方括号表示LABEL
的当前地址.
I tought I understood brackets in x86 assembly. In this example, the register ax
should contain X
, because brackets represents the current address of LABEL
.
mov ax, [LABEL]
LABEL:
db "X", 0
但是我不理解以下两条装配线:
But I dont understand the following two assembly lines:
mov al, [ebx]
为什么需要括号?是因为ebx
是32位寄存器,而ax
是16位?有什么区别:
Why do I need brackets? Is it because ebx
is a 32 bits register and ax
a 16 bits? Whats the difference with:
mov al, ebx
或者这一个,我不明白为什么我需要括号...
Or this one, I don't understand why I need brackets...
mov [edx], ax
推荐答案
使用括号表示法可以访问寄存器指定的值".
The bracket notation is used to let you access the "value appointed to" by the register.
在:
mov ax, [LABEL]
LABEL:
db "X", 0
您要使用LABEL
指定的value
设置ax
,在这种情况下,您要将'X'(0x58 ASCII)复制到ax
寄存器中.
You are setting ax
with the value
appointed by LABEL
, in this case, you are copying the 'X' (0x58 ASCII) into the ax
register.
LABEL
包含"X"所在的地址.
LABEL
contains the address where "X" is located.
这不是有效的操作:
mov al, ebx
这:
mov [edx], ax
您将ax
的值移到"edx
所指向的值"的前两个字节中,因为ax
是一个16位寄存器,而edx
是一个32位寄存器,其中包含一个内存地址.
You are moving the value of ax
into the first two bytes of "the value pointed to by edx
", since ax
is a 16 bit register and edx
is a 32 bit register that holds a memory address.
这篇关于英特尔x86汇编语法中寄存器的括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!