summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/linux-start.obin0 -> 776 bytes
-rw-r--r--src/linux-start.s16
-rw-r--r--src/netbsd-start.s (renamed from src/start.s)3
3 files changed, 17 insertions, 2 deletions
diff --git a/src/linux-start.o b/src/linux-start.o new file mode 100644 index 0000000..72750c8 --- /dev/null +++ b/src/linux-start.o
Binary files differ
diff --git a/src/linux-start.s b/src/linux-start.s new file mode 100644 index 0000000..6392e45 --- /dev/null +++ b/src/linux-start.s
@@ -0,0 +1,16 @@
1.section .text
2.globl _start
3.type _start, @function
4_start:
5 xorq %rbp, %rbp # frame ptr (%rbp) = null. marks stack bottom.
6
7 movq (%rsp), %rdi # argc = first 4 bytes of stack.
8 leaq 8(%rsp), %rsi # argv = address of first arg ptr.
9
10 call main
11
12 movl %eax, %edi # status = ret val.
13 movl $60, %eax # SYS_exit = 60.
14 syscall
15
16 hlt # if syscall fails hang.
diff --git a/src/start.s b/src/netbsd-start.s index 683bfe7..e4e960e 100644 --- a/src/start.s +++ b/src/netbsd-start.s
@@ -4,7 +4,7 @@
4_start: 4_start:
5 xorq %rbp, %rbp # frame ptr (%rbp) = null. marks stack bottom. 5 xorq %rbp, %rbp # frame ptr (%rbp) = null. marks stack bottom.
6 6
7 movl (%rsp), %edi # argc = first 4 bytes of stack. 7 movq (%rsp), %rdi # argc = first 4 bytes of stack.
8 leaq 8(%rsp), %rsi # argv = address of first arg ptr. 8 leaq 8(%rsp), %rsi # argv = address of first arg ptr.
9 9
10 call main 10 call main
@@ -13,5 +13,4 @@ _start:
13 movl $1, %eax # SYS_exit = 1. 13 movl $1, %eax # SYS_exit = 1.
14 syscall 14 syscall
15 15
16 .size _start, .-_start
17 hlt # if syscall fails hang. 16 hlt # if syscall fails hang.