There is an example code in this introduction, like below:
; Sample x64 Assembly Program
; Chris Lomont 2009 www.lomont.org
extrn ExitProcess: PROC ; external functions in system libraries
extrn MessageBoxA: PROC
.data
caption db '64-bit hello!', 0
message db 'Hello World!', 0
.code
Start PROC
sub rsp,28h ; shadow space, aligns stack
mov rcx, 0 ; hWnd = HWND_DESKTOP
lea rdx, message ; LPCSTR lpText
lea r8, caption ; LPCSTR lpCaption
mov r9d, 0 ; uType = MB_OK
call MessageBoxA ; call MessageBox API function
mov ecx, eax ; uExitCode = MessageBox(...)
call ExitProcess
Start ENDP
End
The above code is inside hello.asm
and on Windows, it can be compiled with:
ml64 hello.asm /link /subsystem:windows /defaultlib:kernel32.lib /defaultlib:user32.lib /entry:Start
I don't have access to Windows and MASM, since I'm on Linux and work with NASM. I think if I compile the code on Linux, I would be able to run it with Wine
. But yet, I couldn't figure out how to compile it with NASM on Linux and also I couln't figure out what are the NASM options which are equivalent to the MASM ones. Can anybody help me?