Skip to content

Instantly share code, notes, and snippets.

@terremoth
Created August 7, 2025 05:50
Show Gist options
  • Save terremoth/34dafdea5b0d919c9d95c58089450a92 to your computer and use it in GitHub Desktop.
Save terremoth/34dafdea5b0d919c9d95c58089450a92 to your computer and use it in GitHub Desktop.
Hello World in assembly x64 using AT&T syntax
.section .data
msg:
.asciz "Hello, World!\n"
.section .text
.global main
main:
mov $1, %rax
mov $1, %rdi
lea msg(%rip), %rsi
mov $14, %rdx
syscall
mov $60, %rax
xor %rdi, %rdi
syscall
@terremoth
Copy link
Author

terremoth commented Aug 7, 2025

Compile:

gcc hello.s -o hello

@terremoth
Copy link
Author

terremoth commented Aug 7, 2025

Windows x64 MinGW64 version:

.section .data

msg:
    .asciz "Hello, World!"

.section .text
.global main
.extern puts

main:
    sub $40, %rsp
    lea  msg(%rip), %rcx
    call puts
    xor  %eax, %eax
    add $40, %rsp
    ret

Compile (same way) with:

 gcc hello.s -o hello.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment