简体   繁体   中英

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:

mov [var], 7

I have defined the variable like so: var db 5 .
Even after trying to do var: db 5 it still errored out and said:

error: invalid size for operand 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. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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