-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.s
98 lines (77 loc) · 2.43 KB
/
main.s
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
.include "include/hardware.i"
.section .text
.align 2
.global start
start: movea.l #0x01000000,%sp | 16 MB
| clear the first 32MB
movea.l #0x00000000,%a0 | start at 0
move.w #(((4*1024*1024)/4)/65536)-1,%d1
| number of 64KB long blocks
1: move.w #65536-1,%d0 | 64KB of long words
2: clr.l (%a0)+ | clear it
dbra %d0,2b | back for more
dbra %d1,1b | next 64KB block
move.b #1,LED
bsr exceptionsinit | setup execption handlers
bsr serialinit | prepare the console port
bsr timerinit | prepare the timer
| bsr vgainit
bsr keyboardinit
| bsr mouseinit
move.w #1024-1,%d0
movea.l #0x00008000,%a0
1: move.w #0xff00,(%a0)+
dbra %d0,1b
move.l #0x0101,%d0
movec.l %d0,%cacr
move.w #0x2000,%sr
move.b #0,LED
mainloop: lea.l (newlinemsg,%pc),%a0 | blank between commands
bsr conputstr | ...
lea.l (entercmdmsg,%pc),%a0 | grab the greeting in a0
bsr conputstr | send it
movea.l #inputbuffer,%a0 | set the input up
bsr congetstr | read a line
movea.l #inputbuffer,%a0 | a0=input buffer
movea.l #cmdbuffer,%a1 | a1=command buffer
movea.l #typebuffer,%a2 | a2=type buffer
movea.l #valuebuffer,%a3 | a3=value buffer
movea.l #stringbuffer,%a4 | a4=string buffer
bsr parser | parse out the line
beq parsererror | check for error
movea.l #commandarray,%a0 | setup command array in a0
bsr strmatcharray | match against cmd in a1
beq nocommand | no command
move.l %d0,%a5 | move com data ptr to a5
movea.l #typebuffer,%a0 | retrivie the input types
move.l 4(%a5),%d0 | get the required types
beq 1f | dont check if its null
move.l %d0,%a1 | move req types into a1
jsr checktypes | check the types
bne badparams | bad params check failed
1: movea.l (%a5),%a2 | address is first entry
movea.l %a3,%a1 | values in a1
jsr (%a2) | run the comamnd sub
bra mainloop
parsererror: lea (parsererrormsg,%pc),%a0
bsr conputstr
bra mainloop
badparams: lea (badparamsmsg,%pc),%a0
bsr conputstr
bra mainloop
nocommand: lea (nocommandmsg,%pc),%a0
bsr conputstr
bra mainloop
.section .rodata
.align 2
entercmdmsg: .asciz "Monitor: > "
parsererrormsg: .asciz "Parser rror!\r\n"
nocommandmsg: .asciz "No such command\r\n"
badparamsmsg: .asciz "Bad paramters to command\r\n"
.section .bss
.align 2 | longs need aligning
inputbuffer: .space 256
cmdbuffer: .space 256
typebuffer: .space 256
valuebuffer: .space 256
stringbuffer: .space 256