tags:

views:

270

answers:

8

Given the following code:

L1     db    "word", 0

       mov   al, [L1]
       mov   eax, L1

What do the brackets ([L1]) represent?

+7  A: 

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

interjay
Thanks for your reply, I am starting to learn asm. If I understand this correctly, "mov al, [L1]" would move 'w' into al, and "mov eax, L1" would move the address of L1 into eax. Is that correct?
joek1975
yes. and if you did `mov ebx,L1 -- mov al,[ebx]` then `al` would be 'w' in that case too.
Earlz
A: 

Hi there.

The brackets mean to de-reference an address. For example

mov eax, [1234]

means, mov the contents of address 1234 to EAX. So:

1234 00001

EAX will contain 00001.

Cheers. Jas.

Jason Evans
A: 

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

Your second mov actually loads eax with the address L1 and you can later dereference that to get or set its content.

In both those cases, L1 is conceptually considered to be the address.

paxdiablo
A: 

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

In this instance, L1 is a memory location, but the same logic would apply if a register name was in the brackets:

mov al, [ebx]

Also known as a load.

Alex Brown
A: 

It indicates that the register should be used as a pointer for the actual location, instead of acting upon the register itself.

Ignacio Vazquez-Abrams
+1  A: 

Indexed Indirect Addressing. al will be loaded with the value located @ memory address L1

John Dibling
+3  A: 

Simply means to get the memory at the address marked by the label L1.

If you like C, then think of it like this: [L1] is the same as *L1

Earlz
A: 

And why not working with lea instruction? lea ax,[bx]