### Dumb assembly test program that already taught me something ### interesting about AMD64: it has stack alignment constraints like ### ARM. It’ll still segfault if you run it without a command-line ### argument; that’s not a bug. .intel_syntax noprefix .globl main ## This push rax is to align the stack so printf doesn’t ## segfault in movaps with a source address of rsp + 0x50. main: push rax mov rdi, [rsi + 8] # argv[1] call atoi lea rdi, [rip + formatstr] # AMD’s shitty PC-relative syntax mov rsi, rax # return value of atoi call printf # not how GCC does it but hopefully OK pop rax xor eax, eax ret formatstr: .asciz "(%d)\n"