-
Notifications
You must be signed in to change notification settings - Fork 2
/
monitor.s
96 lines (88 loc) · 1.51 KB
/
monitor.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
; zero page addresses
.dsect
.org $20
MONITOR_READ: reserve 1 ; store a word read from TTY_READLINE here
MONITOR_READ_HI: reserve 1
MONITOR_WRITE: reserve 1
MONITOR_WRITE_HI: reserve 1
.dend
monitor:
puts s_reset
puts s_reset_2
puts s_reset_3
monitor_loop:
jsr readline
stz TTY_READLINE
jsr monitor_read_word
lda (TTY_READLINE)
cmp #'='
beq monitor_write_mem
cmp #'R'
beq monitor_run
; else
bra monitor_read_mem
_monitor_done:
jsr tty_scroll
jmp monitor_loop
monitor_run:
jsr putchar
jsr tty_scroll
jmp (MONITOR_READ)
monitor_read_mem:
; else, print the byte
lda MONITOR_READ_HI
jsr print_hex_byte
lda MONITOR_READ
jsr print_hex_byte
lda #':'
jsr putchar
lda #' '
jsr putchar
lda (MONITOR_READ)
jsr print_hex_byte
bra _monitor_done
monitor_write_mem:
inc TTY_READLINE
lda MONITOR_READ
sta MONITOR_WRITE
lda MONITOR_READ_HI
sta MONITOR_WRITE_HI
jsr monitor_read_word
lda MONITOR_READ
sta (MONITOR_WRITE)
bra _monitor_done
monitor_read_word:
pha
phx
stz MONITOR_READ
stz MONITOR_READ_HI
_read_next_char:
lda (TTY_READLINE)
ldx #0
_hex_loop:
cpx #$10
beq _nomatch
cmp s_hex,x
beq _match
inx
jmp _hex_loop
_match:
_shift_nibble:
.rept 4
asl MONITOR_READ
rol MONITOR_READ_HI
.endr
txa
clc
adc MONITOR_READ
sta MONITOR_READ
inc TTY_READLINE
jmp _read_next_char
_nomatch:
plx
pla
rts
.align 8
s_reset: .asciiz "0000<CR>->inspect"
s_reset_2: .asciiz "0000=12<CR>->set"
s_reset_3: .asciiz "0000R<CR>->run"