I'm working with the following code:
section .text
global _start
_start:
mov ebx, testing
mov [ebx], byte 0x4A
add ebx, byte 1
mov [ebx], byte 0x4B
add ebx, byte 1
mov [ebx], byte 0x4C
;sets var1 as '*'
mov eax, 0x2A
mov [var1], eax
;sets var2 as 'N'
mov eax, 0x4E
mov [var2], eax
;sets var3 = var2
mov eax, [var2]
mov [var3], eax
;Prints var1
mov eax, 4
mov ebx, 1
mov ecx, var1
mov edx, 1
int 0x80
;Jumps a line
mov eax, 4
mov ebx, 1
mov ecx, line_break
mov edx, 2
int 0x80
;Prints var2
mov eax, 4
mov ebx, 1
mov ecx, var2
mov edx, 1
int 0x80
;Jumps a line
mov eax, 4
mov ebx, 1
mov ecx, line_break
mov edx, 2
int 0x80
;Prints var3
mov eax, 4
mov ebx, 1
mov ecx, var3
mov edx, 1
int 0x80
;Jumps a line
mov eax, 4
mov ebx, 1
mov ecx, line_break
mov edx, 2
int 0x80
;Prints variable
mov eax, 4
mov ebx, 1
mov ecx, variable
mov edx, 3
int 0x80
;Jumps a line
mov eax, 4
mov ebx, 1
mov ecx, line_break
mov edx, 2
int 0x80
;Prints testing
mov eax, 4
mov ebx, 1
mov ecx, testing
mov edx, 3
int 0x80
;Jumps a line
mov eax, 4
mov ebx, 1
mov ecx, line_break
mov edx, 2
int 0x80
;Finishes program
mov eax, 1
mov ebx, 1
int 0x80
section .data
variable times 3 db 0x2A
line_break dw 0x0D0A
section .bss
testing resb 3
var1 resb 1
var2 resb 1
var3 resb 1
It prints out:
*
N
N
***
JKL
What i don't understand is: why in the first line "mov ebx, testing" there is no brackets arround "testing" and why those brackets are present in [var2] in the line "mov eax, [var2]". How exactly does this notation work? Shouldn't [var2] be the effective address of var2?