简体   繁体   English

YASM mov 指令给出错误:操作数 1 的大小无效

[英]YASM mov instruction gives error: invalid size for operand 1

I am trying to do some basic YASM coming from TASM, and this line of code will error:我正在尝试做一些来自 TASM 的基本 YASM,这行代码会出错:

mov [var], 7

I have defined the variable like so: var db 5 .我已经像这样定义了变量: var db 5
Even after trying to do var: db 5 it still errored out and said:即使在尝试做var: db 5它仍然出错并说:

error: invalid size for operand 1错误:操作数 1 的大小无效

Unlike TASM, YASM/NASM don't look at the declaration of var to decide if it is byte, word, dword, etc. The operand size needs to be specified in any instruction where it isn't implicit from the registers being used.与 TASM 不同,YASM/NASM 不会查看var的声明来确定它是字节、字、双字等。操作数大小需要在任何指令中指定,如果它不是从正在使用的寄存器中隐含的。 So you must write所以你必须写

mov byte [var], 7

Note that注意

mov [var], bl

doesn't need the byte , because the 8-bit operand size is inferred from the use of the 8-bit register bl .不需要byte ,因为 8 位操作数大小是从 8 位寄存器bl的使用中推断出来的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM