-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.s
90 lines (79 loc) · 2.05 KB
/
exceptions.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
.include "include/hardware.i"
.include "include/vectors.i"
.global exceptionsinit
.section .vectors
.align 2
vectortable: .space 256*4
.section .text
.align 2
exceptionsinit: move.l #buserror,VBUSERROR
move.l #addresserr,VADDRESSERROR
move.l #illegalinst,VILLEGALINSTRUCTION
move.l #zerodivide,VZERODIVIDE
move.l #badpriv,VBADPRIV
move.l #badvector,VBADVECTOR
move.l #spurious,VSPURIOUS
move.l #aline,VALINEEMU
move.l #fline,VFLINEEMU
rts
buserror: lea (buserrormsg,%pc),%a0
lea (8,%sp),%sp | advance to sr/pc
bra 2f
addresserr: lea (addresserrmsg,%pc),%a0
lea (8,%sp),%sp | advance to sr/pc
bra 2f
illegalinst: lea (illegalinstmsg,%pc),%a0
bra 2f
zerodivide: lea (zerodividemsg,%pc),%a0
bra 2f
badpriv: lea (badprivmsg,%pc),%a0
bra 2f
badvector: lea (badvectormsg,%pc),%a0
bra 2f
spurious: lea (spuriousmsg,%pc),%a0
bra 2f
aline: lea (alinemsg,%pc),%a0
bra 2f
fline: lea (flinemsg,%pc),%a0
bra 2f
2: move.b #0xff,LED
bsr conputstr
movea.l #buffer,%a0
lea (srmsg,%pc),%a1
bsr strconcat
move.w (0,%sp),%d0
bsr wordtoascii
lea (spacesmsg,%pc),%a1
bsr strconcat
lea (pcmsg,%pc),%a1
bsr strconcat
move.l (2,%sp),%d0
bsr longtoascii
lea (newlinemsg,%pc),%a1
bsr strconcat
movea.l #buffer,%a0
bsr conputstr
9: move.w #0xffff,%d0
move.b #0,LED
10: dbra %d0,10b
move.w #0xffff,%d0
move.b #0xff,LED
11: dbra %d0,11b
bra 9b
.section .rodata
.align 2
buserrormsg: .asciz "\r\n*** Bus error, halt.\r\n"
addresserrmsg: .asciz "\r\n*** Address error, halt.\r\n"
illegalinstmsg: .asciz "\r\n*** Illegal instruction, halt.\r\n"
zerodividemsg: .asciz "\r\n*** Divide by zero, halt.\r\n"
badprivmsg: .asciz "\r\n*** Privilege Voilation, halt\r\n"
badvectormsg: .asciz "\r\n*** Unitialised interrupt vector, halt\r\n"
spuriousmsg: .asciz "\r\n*** Spurious interrupt, halt\r\n"
alinemsg: .asciz "\r\n*** A-Line emulation, halt\r\n"
flinemsg: .asciz "\r\n*** F-Line emulation, halt\r\n"
srmsg: .asciz "SR: "
pcmsg: .asciz "PC: "
spmsg: .asciz "SP: "
.section .bss
.align 2
buffer: .space 256