Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly Square Brackets

Tags:

assembly

I've always wondered what the difference between

mov esi,eax

and

mov [esi],eax

was.

Any help is appreciated.

like image 766
user2712959 Avatar asked Aug 24 '13 16:08

user2712959


People also ask

What do [] mean in assembly?

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'

What does parentheses mean in assembly?

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.

What is dword ptr in assembly?

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.


1 Answers

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).

like image 173
Michael Avatar answered Oct 17 '22 08:10

Michael