Using [EDX] syntax... can I do the equivalent with a variable someway, somehow?

Started by cork, July 14, 2010, 02:04:24 AM

Previous topic - Next topic

cork

Something I've been wondering about... using MASM32...

I have a variable, pNext, that is a DWORD. It contains an address that points to another location.

Naturally, to do the C equivalent of EAX = *pNext I can do the following:
    mov EDX, pNext                        ; EAX=*pNext
    mov EAX, [EDX]                        ;

I know that "[pNext]" syntax is wrong, as is it translates to "pNext", doing nothing more than removing the brackets.

Is it possible to do something like "[pNext]" without having to first move the address to a register?


raymond

I don't think so. However, you don't need 2 registers (like the C compiler would do :boohoo:) if you don't want to trash that second register.

Quotemov  eax,pNext
mov  eax,[eax]
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

hutch--

cork,

To get multiple levels of indirection you need to do the extra operations as there are no mnemonics that support this action hard wired into the processor.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

cork

Thanks raymond and hutch. This clears up what has heretofore been a mystery for me.