how to get address of variable and dereference it in nasm x86 assembly?

Viewed 13734

in c language we use & to get the address of a variable and * to dereference the variable.


    int variable=10; 
    int *pointer;
    pointer = &variable;

How to do it in nasm x86 assembly language.
i read nasm manual and found that [ variable_address ] works like dereferencing.( i maybe wrong ).

section .data
variable db 'A'
section .text
global _start
_start:
mov eax , 4
mov ebx , 1
mov ecx , [variable]  
mov edx , 8
int 0x80
mov eax ,1
int 0x80



i executed this code it prints nothing. i can't understand what is wrong with my code. need your help to understand pointer and dereferencing in nasm x86.

1 Answers
Related