using pointers in nasm
I'm trying to create a linked list in assembly using malloc to create space for new nodes. malloc will return a pointer to the memory location it has allocated. I'm not sure how to use that pointer. How do I write to the memory location of the pointer I've been given in nasm assembly?
October 25, 2004 02:58 PM
Assuming the address is in EAX, you just use a memory indirection:
mov dword [eax], 12345
The C equivalent is: *eax = 12345L;
Or to copy back the contents of that location to a register:
mov edx, [eax]
in C that would be: unsigned int edx = *eax;
To access memory beyond the first dword, add an offset or simply increase/decrease the value in EAX.
BTW, shouldn't that be in general programming ?
mov dword [eax], 12345
The C equivalent is: *eax = 12345L;
Or to copy back the contents of that location to a register:
mov edx, [eax]
in C that would be: unsigned int edx = *eax;
To access memory beyond the first dword, add an offset or simply increase/decrease the value in EAX.
BTW, shouldn't that be in general programming ?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement