What do the brackets mean in x86 asm?

Given the following code:

L1 db "word", 0 mov al, [L1] mov eax, L1 

What are the brackets ([L1])?

+36
assembly x86
Jan 08
source share
8 answers

[L1] means the contents of memory at address L1. After running mov al, [L1] here, register al will receive a byte at address L1 (the letter "w").

+32
Jan 08
source share

It simply means getting memory at the address labeled L1.

If you like C, then think of it this way: [L1] matches *L1

+23
Jan 08 '10 at 20:11
source share

Operands of this type, such as [ebp] , are called memory operands .

All the answers here are good, but I see that no one is talking about a warning, following this as a strict rule - if the brackets are then dereferenced, except when the lea command is .

lea is an exception to the above rule. Let's say we

 mov eax, [ebp - 4] 

The ebp value is subtracted by 4, and the brackets indicate that the resulting value is taken as the address, and the value located at this address is stored in eax . However, in the case of lea brackets do not mean that:

 lea eax, [ebp - 4] 

The ebp value is subtracted by 4, and the resulting value is stored in eax . This instruction simply calculated the address and stored the calculated value in the destination register. See this post for more details.

+19
Sep 13 '14 at 14:20
source share

Brackets mean removing the link to the address for example

mov eax, [1234]

means moves the contents of address 1234 to eax. So:

 1234 00001 

EAX will contain 00001.

+5
Jan 08
source share

Direct memory addressing - al will be loaded with the value located at memory address L1 .

+2
Jan 08 '10 at 20:08
source share

As in many assembly languages, this means indirectness. In other words, the first mov loads al with the contents of L1 (byte 'w' other words), not the address.

The second mov actually loads the eax with the address L1 , and you can later dereference it to get or set its contents.

In both cases, L1 conceptually considered an address.

+1
Jan 08
source share

They mean that instead of moving the register value or numeric value L1 to al register, process the register value or numeric value L1 as a pointer into memory, extract the contents of this memory address, and move this contents to al .

In this case, L1 is the memory location, but the same logic will apply if the name of the register is in parentheses:

 mov al, [ebx] 

Also known as load.

+1
Jan 08
source share

This means that the register should be used as a pointer to the actual location, and not act on the register itself.

0
Jan 08
source share



All Articles