summary refs log tree commit diff
path: root/src/linux-start.s
blob: 6392e45abafbad32f1100228175e8408ad50ee74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
.section .text
.globl _start
.type _start, @function
_start:
	xorq %rbp, %rbp # frame ptr (%rbp) = null. marks stack bottom.

	movq (%rsp), %rdi # argc = first 4 bytes of stack.
	leaq 8(%rsp), %rsi # argv = address of first arg ptr.

	call main

	movl %eax, %edi # status = ret val.
	movl $60, %eax # SYS_exit = 60.
	syscall

	hlt # if syscall fails hang.