Chapter 3.6
Introducing 64-bit Programming
Simple AddTwo example for 64-bit MASM
ExitProcess PROTO
.data
sum DWORD 0
.code
main PROC
mov eax, 5
add eax, 6
mov sum, eax
mov ecx, 0
call ExitProcess
main ENDP
END
The differences from the 32-bit version:
.386.modeland.stackdirectives are not used- Statements using
PROTOdo not have parameters - No
INVOKEdirective, ExitProcess called usingcall mov ecx, 0before calling ExitProcess.INVOKEdid it automatically.ENDdirective does not specify entry point
Using 64-bit registers
To use 64-bit registers, we change EAX into RAX, and also have to define sum as QWORD to be able to move data into it using simple mov
.data
sum QWORD 0
.code
main PROC
mov rax, 5
add rax, 6
mov sum, rax
...