...
1#define STDOUT $1
2#define IMAGE_BASE 0x04000000
3
4#ifdef __Linux__
5#define SYS_exit $1
6#define SYS_write $4
7#elif defined(__Darwin__)
8#define SYS_exit $0x02000001
9#define SYS_write $0x02000004
10#else
11#error Unsupported operating system.
12#endif
13
14.org IMAGE_BASE
15.entry start
16
17start:
18 movq STDOUT, %rdi
19 leaq msg(%rip), %rsi
20 movq $13, %rdx
21 movq SYS_write, %rax
22 syscall
23 xorl %edi, %edi
24 movq SYS_exit, %rax
25 syscall
26
27msg:
28 .ascii "hello, world\n"
View as plain text