Skip to content

Instantly share code, notes, and snippets.

@vpetrigo
Created December 10, 2016 18:43
Show Gist options
  • Save vpetrigo/63ed542e10302a1bee6880e18e41f001 to your computer and use it in GitHub Desktop.
Save vpetrigo/63ed542e10302a1bee6880e18e41f001 to your computer and use it in GitHub Desktop.
Minimal ASM files
# Build command: gcc linux.s -o linux.out
.intel_syntax noprefix
.extern puts
.text
.globl main
main:
lea rdi, message
call puts
ret
message: .asciz "Hello, World!"
; Command for the command line by using MinGW64:
; nasm -f win64 windows.asm -o windows.o && ld -o windows.exe windows.o -L /mingw64/x86_64-w64-mingw32/lib -lkernel32 -lmsvcrt
; ExitProcess is essential here
; otherwise you'd get SEGFAULT
extern ExitProcess
extern puts
section .data
message db "Hello, World!", 0
section .text
main:
lea rcx, [message]
call puts
mov ecx, eax
call ExitProcess
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment