英特尔x86汇编语法中寄存器的括号 [英] Brackets on registers in Intel x86 assembly syntax

查看:592
本文介绍了英特尔x86汇编语法中寄存器的括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道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汇编语法中寄存器的括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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