-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.asm
53 lines (49 loc) · 873 Bytes
/
main.asm
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
#include "kernel.inc"
.db "KEXC"
.db KEXC_ENTRY_POINT
.dw start
.db KEXC_STACK_SIZE
.dw 50
.db KEXC_KERNEL_VER
.db 0, 6
.db KEXC_NAME
.dw name
.db KEXC_HEADER_END
name:
.db "init", 0
start:
kld(de, inittab)
pcall(openFileRead)
pcall(getStreamInfo)
inc bc
pcall(malloc)
pcall(streamReadToEnd)
pcall(closeStream)
ld d, b \ ld b, c \ ld c, d
inc c
push ix \ pop de
push ix
.loop:
ld a, (ix)
cp '\n'
jr z, .launch
inc ix
djnz .loop
dec c
jr nz, .end
.launch:
xor a
ld (ix), a
pcall(launchProgram)
pcall(contextSwitch)
inc ix
push ix \ pop de
djnz .loop
dec c
jr nz, .loop
.end:
pop ix
pcall(free)
ret
inittab:
.asciiz "/etc/inittab"