Advertisement

using pointers in nasm

Started by October 25, 2004 02:49 PM
0 comments, last by GameDev.net 20 years ago
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?
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 ?

This topic is closed to new replies.

Advertisement