-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpanic.a
More file actions
31 lines (26 loc) · 1.33 KB
/
panic.a
File metadata and controls
31 lines (26 loc) · 1.33 KB
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
; panic.a - fatal error handler for 6809
include "globals.i"
include "via6522.i"
ORG $0000 ; This is a relocatable module.
EXEC init
; Default panic handler, outputs to [g_stderr].
panic: begin ; 6809 SWI entry point.
nop ; Needed because of error in pcr assembly, above.
ldx 10,s ; Get saved PC from stack (points at panic string).
; Count the length of the panic string.
ldd #0 ; Clear D (length counter).
count: lda ,x+ ; Get next byte of string.
beq done ; Is this the end of the string?
addd #1 ; Increment length counter.
bra count
; Output the panic string to stderr.
done: ldx 10,s ; Get panic string (== saved PC) from stack again.
jsr [g_stderr] ; Output the panic string.
loopstop: bra loopstop ; Loop here forever, with interrupts disabled.
end
; Initialisation routine to set up the panic handler and stderr.
init: begin
leax panic,pcr ; Copy the address of the panic handler
stx g_swivec ; to the SWI vector.
rts ; Done, return to the loader.
end