summaryrefslogtreecommitdiff
path: root/lib/entry.S
blob: 87ad9c7eb51d3074efad817d1ecf859ca5677e48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
// user-level startup routine
//
	.text
	.globl _start
	.globl	main
	.globl	exit

// entry point - this is where the kernel starts us running
_start:
	// we immediately call main()
	call main

	// if we come back from that, it means the user
	// program didn't call exit(), in which case the
	// value returned from main() is the exit status

	// push that value onto the stack and call exit()
	subl	$12, %esp
	pushl	%eax
	call	exit

	// if we come back from that, something bad has
	// happened, so we just lock up
1:	jmp 1b