format PE64 GUI
Caption db 'Win64 assembly program',0
Message db 'Hello World!',0
As you can see is need to set the format and included file: PE64 GUI and win64ax.inc.
The .data and .code area are the same steps as any programming with the call instructions (but it is not mandatory, but for the beginning, it is very good).
Now about the Windows MessageBox Windows function named MessageBox, this takes four arguments.
MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
We need to use the xor to fix and prepare the lea for load strings.
The x64 registers: RCX, RDX, R8, R9 are used for integer and pointer arguments in that order left to right.
Let’s parse some simple examples with xor versus registers in order to see the sized data:
xor ecx,ecx ; is this: int index = 0
xor r9d,r9d ; is this: unsigned index = 0
The next step is the lea:
The FASM manual tells us:
The source operand must be a memory operand, and the destination operand must be a general register.
lea dx,[bx+si+1] ; load effective address to dx
Now I explain the basic rules as simple as possible, but the derivations are very complex and they become the rules of addressing.
Here are the basic rules:
The Intel assembler uses the opposite order (destination <- source) for operands.
Operands can be immediate (that is, constant expressions that evaluate to an inline value), register (a value in the processor number registers), or memory (a value stored in memory). An indirect operand contains the address of the actual operand value.
In FASM, when you write “[X]”, you are referring to the variable X.
If you write just X, you are referring to its address of X.
The lea is like the & in C programming.