理解关键字 eax 和 mov
我试图了解 asm 中的寄存器,但我访问的每个网站都假设我了解一些有关寄存器的信息,但我就是无法掌握它。我知道一本关于 C++ 的书,据我所知, mov var1,var2
与 var1 = var2
是一样的,对吗?
但对于 eax 寄存器我完全迷失了。任何帮助表示赞赏。
I am trying to understand the registers in asm but every website I look at just assumes I know something about registers and I just cannot get a grip on it. I know about a books worth of c++ and as far as I know mov var1,var2
would be the same thing as var1 = var2
, correct?
But with the eax register I am completely lost. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将寄存器视为每个处理器的全局变量。有“eax”、“ebx”和其他一些。此外,您只能通过寄存器执行某些操作 - 例如,没有指令可以从一个内存位置读取并将其写入另一个内存位置(除非这些位置由某些寄存器表示 - 请参阅 movsb 指令等)。
所以寄存器一般只用于临时存储某些操作所需的值,但通常不用作常规意义上的全局变量。
你是对的,“mov var1, var2”本质上是一个赋值 - 但你不能使用两个基于内存的变量作为操作数;这是不支持的。您可以改为:
... 具有相同的效果,使用 eax 寄存器作为临时寄存器。
Consider registers as per-processor global variables. There's "eax", "ebx", and a bunch of others. Furthermore, you can only perform certain operations via registers - for example there's no instruction to read from one memory location and write it to another (except when the locations are denoted by certain registers - see movsb instruction, etc).
So the registers are generally used only for temporary storage of values that are needed for some operation, but they usually are not used as global variables in the conventional sense.
You are right that "mov var1, var2" is essentially an assignment - but you cannot use two memory-based variables as operands; that's not supported. You could instead do:
... which has the same effect, using the eax register as a temporary.
eax
指的是处理器寄存器(本质上是一个变量)mov
是一条将数据从一个寄存器复制到另一个寄存器的指令。所以本质上你是正确的(从手动意义上来说)你有一个你想讨论的示例装配块吗?
eax
refers to a processor register (essentially a variable)mov
is an instruction to copy data from one register to another. So essentially you are correct (in a handwavey sense)Do you have an example assembly block you want to discuss?
将 eax 视为内存中可以存储值的位置,就像在 c++ 中 int、long... 和其他类型指定变量在内存中的位置的大小一样。 eax 寄存器只是指向内存中的一个存储位置,在 x86 计算机上是 32 位。 eax 的 e 部分表示扩展。该寄存器->内存位置由乘法和除法运算符自动使用,通常称为扩展累加器寄存器。
Think of eax as a location in memory where a value can be stored, much like in c++ where int, long,... and other types specify the size of the location in memory of a variable. The eax register simply points to a storage location in memory, which on x86 computers is 32 bits. The e part of eax means extended. This register -> memory location is automatically used by the multiplication and division operators and normally called the extended accumulator register.