NASM “register size specification ignored”

2019-05-03 09:48发布

问题:

I tried to assemble a file with NASM, but it pointed to this line in the file:

mov al, byte ptr es:[bx]

saying:

error: comma, colon or end of line expected

I found a page on this site saying that NASM doesn't like the word "ptr" and it would be happy if I wrote:

mov al, byte es:[bx]

instead. So I took out the word "ptr" and NASM is still not happy. Here is what NASM gives me when I leave out the word "ptr":

warning: register size specification ignored

and:

error: invalid combination of opcode and operands

It's a catch 22! NASM is angry whether or not I put in the word "ptr". Can anybody help me with this?

回答1:

I got it! NASM is happy if I write:

mov al,byte [es:bx]

like Guy Sirton said. If I leave out the word "byte" from the instruction, here is what would happen. If the instruction is one like this:

mov al, [es:bx]

where NASM can see that I want to move one byte, since I'm storing it in al, it won't complain. But, if the instruction is one like this:

mov [es:bx],0xff

where NASM can't see how much memory I want to store 0xff in, it will give you such an error:

error: operation size not specified

It's important to know, especially if you are using this tutorial, that NASM won't except the regular way.



标签: nasm