Skip to content

Instantly share code, notes, and snippets.

@moyix
Last active November 8, 2017 20:01
Show Gist options
  • Save moyix/7578bc512aaa2b8681e602244f97e7e9 to your computer and use it in GitHub Desktop.
Save moyix/7578bc512aaa2b8681e602244f97e7e9 to your computer and use it in GitHub Desktop.
A syscall quiz
all: quiz
quiz.o: quiz.asm
nasm -f elf64 $< -o $@
quiz: quiz.o
ld -Tdata=0x8000000000 $< -o $@
[bits 64]
global _start
_start:
mov rdx, 12
mov rcx, 0x8000000000
or rcx, R
mov rbx, 1
mov rax, 4
int 80h
mov rdx, 12
mov rcx, S
mov rbx, 1
mov rax, 4
int 80h
mov rdx, 12
mov rsi, T
mov rdi, 1
mov rax, 1
syscall
mov rax, 60
syscall
R:
db "Oh no world", 0x0a
; NB: will be linked with
; ld -Tdata=0x8000000000
[SECTION .data]
S:
db "Hello world", 0x0a
T:
db "Goodbye foo", 0x0a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment