• Uncategorized

About parsing : Why-doesnt-NASM-have-trouble-with-valid-instruction-mnemonics-as-symbol-names-in-operands

Question Detail

I wrote the following simple program, but nasm refuses to compile it.

section .text
    global _start

_start:
    mov rax, 0x01 
    mov rdi, 0x01
    mov rsi, str
    mov rdx, 0x03
    syscall

    mov rax, 60
    syscall

segment .data
    str db 'Some string'


nasm -f elf64 main.asm
main.asm:15: error: comma, colon, decorator or end of line expected after operand

As I read in this answer this is because str is an instruction mnemonic. So I added a colon to str and now it compiles fine. But what about the line

mov rsi, str

str is an instruction mnemonic here, but it still compiles fine. Why?

Question Answer

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.