-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrash.s
67 lines (64 loc) · 1.08 KB
/
crash.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
;
; "Handle" fatal errors
;
; Steve Maddison, 25/02/2007
;
crash_message: defm "\n\n:-( \0"
crash_reg_header:
defm "A F B C D E H L SP\n\0"
crash:
push af
push hl
ld hl,crash_message
call console_outs
call error_str ; A should contain an error code
call console_outs
ld a,'\n'
call console_outb
ld hl,crash_reg_header
call console_outs
pop hl ; Original value of AF
call print_hex_16
ld a,' '
call console_outb
push bc
pop hl
call print_hex_16
ld a,' '
call console_outb
push de
pop hl
call print_hex_16
ld a,' '
call console_outb
pop hl
call print_hex_16
ld a,' '
call console_outb
ld hl,0
add hl,sp
call print_hex_16
ld a,'\n'
call console_outb
crash_stack_dump:
ld bc,stack_top
inc bc
inc bc
crash_stack_dump_loop:
call print_hex_16
ld a,':'
call console_outb
ld a,(hl)
call print_hex_8
inc hl
ld a,(hl)
call print_hex_8
ld a,'\n'
call console_outb
inc hl
push hl
and a
sbc hl,bc
pop hl
jp nz,crash_stack_dump_loop
halt