summaryrefslogtreecommitdiffstats
path: root/test cases/windows/21 masm/hello.masm
blob: a47dc968fc14710935b8e76b8786d605853074f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
; ---------------------------------------------
; Hello World for Win64 Intel x64 Assembly
;
; by fruel (https://github.com/fruel)
; 13 June 2016
; ---------------------------------------------

GetStdHandle PROTO
ExitProcess PROTO
WriteConsoleA PROTO

.data
msg BYTE "Hello World!",0
bytesWritten DWORD ?

.code
mainCRTStartup proc
    sub rsp, 5 * 8              ; reserve shadow space

    mov rcx, -11                ; nStdHandle (STD_OUTPUT_HANDLE)
    call GetStdHandle

    mov  rcx, rax               ; hConsoleOutput
    lea  rdx, msg               ; *lpBuffer
    mov  r8, LENGTHOF msg - 1   ; nNumberOfCharsToWrite
    lea  r9, bytesWritten       ; lpNumberOfCharsWritten
    mov  QWORD PTR [rsp + 4 * SIZEOF QWORD], 0  ; lpReserved
    call WriteConsoleA

    mov rcx, 0                  ; uExitCode
    call ExitProcess
mainCRTStartup endp
END