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

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

	call main # see main.c.

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

	.size _start, .-_start
	hlt # if syscall fails hang.