I've always wondered what the difference between
mov esi,eax
and
mov [esi],eax
was.
Any help is appreciated.
I am assuming you're asking about Intel-style x86 assembly. Square brackets means 'the variable at the memory address stored in RAX”. So: mov RAX, 12. means “store value 12 into RAX” mov [RAX], 12. means “store value 12 in the memory cell whose address is stored in RAX'
The parentheses indicate the move instruction should consider the value in rbp to be a memory address, that it should move the value 42 to the memory address referenced by rbp (or actually to the memory address four bytes before the value of rbp ) and not into rbp itself.
Basically, it means "the size of the target operand is 32 bits", so this will bitwise-AND the 32-bit value at the address computed by taking the contents of the ebp register and subtracting four with 0.
mov esi,eax
writes the contents of register eax
to register esi
.
mov [esi],eax
writes the contents of register eax
to the memory address specified by register esi
(for example, if esi
contained the value 0x1234, eax
would be written to address 0x1234).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With