A
assembler

Reading and writing to memory (RAM) on FASM?

Hello,
I recently started writing in Fasm, now I'm trying to understand the role - '[]'
For example:

MyVar dq 0
mov rax, MyVar

It compiles fine, but for some reason
MyVar dq 0
mov MyVar, rax

no, but if
MyVar dq 0
mov [MyVar], rax

then everything is fine, am I completely stupid or is it supposed to be like this?
Although, as far as I understand, if I write
MyVar dq 0
mov rax, [MyVar]

then the value at the address MyVar=0 will go to ax, and not 0 itself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
15432, 2016-12-11
@Ruins

MyVar dq 0
mov rax, MyVar ; put into rax address MyVar
MyVar dq 0
mov [MyVar], rax ; write the contents of register rax to address MyVar
MyVar dq 0
mov rax, [MyVar] ; read into register rax the value at address MyVar
MyVar dq 0
mov MyVar, rax ; assign the address (constant number) the value from register rax ?? - mistake

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question