Search code examples
assemblyx86mov

Push/Pop vs Mov in MASM


A simple question but I do not know the answer.

What is the reason for:

push wParam
pop char

where wParam is defined as type WPARAM and char is defined as type WPARAM.

Why can't I simply

mov char, wParam

I have a feeling it has to do with addresses, but I can't justify it. MASM spits out a non-descript error when I try to use the mov statement.


Solution

  • Because both are memory addresses and in x86 assembly there is no such instruction as mov mem,mem (mov char,wParam in this case).

    Therefore, to do that, you need to use either push & pop, or first move the value into some register with mov reg,mem and from that register to memory with mov mem,reg.