Search code examples
assemblynasmx86-64bracketsyasm

difference between brackets/no brackets nasm/yasm x86_64


i am learning x86_64 assembly code on yasm and nasm, and i came across with these expressions, and i cant figure out what is happening here, could someone explains me it please?, lets take these snippet as an example:

section .data
word db "Hello, Guys!", 0xa
global _start
section .text
_start:
mov rax, word
...
...
...

AND

section .data
word db "Hello, Guys!", 0xa
global _start
_start:
mov rax, [word]
...
...
...

what are the differences between moving the word variable to rax in brackets and without brackets? i already know that the first one is copying the value from word to rax register, and the one with brackets is the effective address

but i cant understand what really is happenning there, i would be grateful if somebody could explains me this, thanks!, i already read some explanations here on stack overflow but none of them answered my question


Solution

  • This line mov rax, word put content of word in rax register,knowing that word storing address of beginning string "Hello, Guys!"

    `mov rax, [word]`  put content of address pointed by word