summaryrefslogtreecommitdiff
path: root/interface/crt0.s
blob: c24d2d99d04e514571479e7f9e5e4c174cf0b4e3 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
.global _start

_start:

push %ebx
push %ecx

//cmp $0,_impure_ptr
//jne skipzero

//movl $0xf5000000, _impure_ptr
//mov  $0xf5000000,%ebx

//allzero: 
//movl $0, (%ebx)
//add $4, %ebx
//cmp $0xf5001000,%ebx
//jne allzero

//skipzero:

mov _impure_ptr,%eax
mov $0xf5000000,%ebx

copy: 
mov (%eax),%ecx
mov %ecx,(%ebx)
add $4, %ebx
add $4, %eax
cmp $0xf5001000,%ebx
jne copy

movl $0xf5000000, _impure_ptr

pop %ecx
pop %ebx

# environment adress was passed on stack

pop %eax                      
mov %eax, environ

# call main (argc and argv are on the stack)
call main

# push exit code and pass to _exit syscall
push %eax
call exit

# this should never be reached!
.wait:
    hlt
jmp .wait