PLATFORM: Pentium 4 processor (i really need to upgrade 🙂 running Windows XP. I am currently assembling with MASM32.
I am an absolute beginner with assembly and I am trying to figure out how to add variables. I understand how to define variables, place data in a register, and how to place registers in the stack, but I don’t know how to combine the values of two variables (by adding).
Also, could anyone give me a link or something to an easy to understand tutorial on x86 assembly, all the ones that I’ve found so far are really high-level stuff and they don’t explain much. That would be really appreciated.
Thanks in advance,
Progrmr
Simple addition:
Load from memory, then add, then store in memory:
In the examples above, DWORD PTR isn’t strictly needed, but is a good habit to practice because it remove any ambiguity and makes code easier to read.
It’s important to remember that you can only add registers of the same size (DWORD in the examples above). If you want to add two registers of different sizes:
This isn’t a terribly good example because there are easier ways to do the same thing, but hopefully it’ll show some of the tricks you can use.
You can also add a memory value to a registers:
Here’s a good site to use as a reference: http://ref.x86asm.net/