-1

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

Rablidad
  • 55
  • 2
  • 8

1 Answers1

-3

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 
nissim abehcera
  • 821
  • 6
  • 7
  • This is a very misleading explanation. `mov rax, word` does not load the content of `word`. Furthermore, where do you get that `word` has the value 0xa? – prl Feb 25 '19 at 22:03
  • what is the content of word after this `word db "Hello, Guys!", 0xa` – nissim abehcera Feb 25 '19 at 22:06
  • If you think of `word` as the address of a byte, as I do, then its content is the letter 'H'. If you read it with `mov rax, [word]`, then its content is 0x47202c6f6c6c6548. – prl Feb 25 '19 at 22:13
  • Please see the accepted answer on this question: https://stackoverflow.com/questions/39474332/assembly-difference-between-var-and-var – prl Feb 25 '19 at 22:18
  • mov eax,[variable] ; moves content of variable into eax and `mov rax, [word]` put content of address pointed by word , [word] it's similar to *pointer and word it's similar to pointer – nissim abehcera Feb 25 '19 at 22:30
  • where is stored word ?? – nissim abehcera Feb 25 '19 at 22:32
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/189026/discussion-between-nissim-abehcera-and-prl). – nissim abehcera Feb 25 '19 at 22:32
  • `word` isn't "stored" anywhere. The symbol value (the address) only exists at assemble-time and link time. If you use it as an immediate or an addressing mode, then it ends up embedded in the machine code after linking. – Peter Cordes Feb 26 '19 at 04:26