Last active
March 26, 2024 15:14
-
-
Save mcandre/4d7654bf994d0c13f6503b0ef25a3105 to your computer and use it in GitHub Desktop.
64-bit GNU assembler Hello World for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build: | |
# | |
# as -o hello.obj | |
# ld -o hello.exe hello.obj -L C:\\tools\\mingw64\\x86_64-w64-mingw32\\lib -lkernel32 | |
# | |
# Requires MinGW | |
.extern GetStdHandle | |
.extern WriteFile | |
.extern ExitProcess | |
.section .rodata | |
msg: .ascii "Hello World!\r\n" | |
.equ msg_len, .-msg | |
.equ stdout_query, -11 | |
.section .data | |
stdout: .long 0 | |
bytes_written: .long 0 | |
.section .text | |
.global start | |
start: | |
mov $stdout_query, %rcx | |
call GetStdHandle | |
mov %rax, (stdout) | |
mov (stdout), %rcx | |
mov $msg, %rdx | |
mov $msg_len, %r8 | |
mov $bytes_written, %r9 | |
push $0 | |
call WriteFile | |
xor %rcx, %rcx | |
call ExitProcess |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment