-
Notifications
You must be signed in to change notification settings - Fork 1
/
monitor.a65
211 lines (150 loc) · 4.81 KB
/
monitor.a65
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
.ORG $F000 ; ROM
.ENT $ ; ASM80.COM - emulator start
.ENGINE 6502 ; ASM80.COM - emulator definition
RESET:
; Stack
LDX #$FF
TXS
JSR init
JSR print_hello
LOOP:
JSR read_key
JMP loop
INIT:
JSR serial_init
LDA #$0
STA console_address
STA console_address+1
RTS
READ_KEY:
JSR primm ; print command promnt
DB $0D,$0A,">> ",$00
READ_KEY_LOOP:
JSR read_char ; read character
JSR primm
DB $0D,$0A,$00 ; with new line
CMP #$48 ; H - Help
BEQ cmd_help
CMP #$41 ; A - Set Address
BEQ cmd_address
CMP #$43 ; C - Change Memory
BEQ cmd_change
CMP #$4D ; M - Show Memory
BEQ cmd_show
CMP #$47 ; G - Go
BEQ cmd_go
CMP #$52 ; R - Registers
BEQ cmd_req
JSR cmd_unknown ; something else
RTS
CMD_HELP:
JMP print_help
CMD_ADDRESS:
JMP set_address
CMD_CHANGE:
JMP change_memory
CMD_SHOW:
JMP show_memory
CMD_GO:
JMP go_memory
CMD_REQ:
JMP print_regs
CMD_UNKNOWN:
JSR primm
DB "Unknown command, press H for help",$0D,$0A,$00
RTS
PRINT_HELLO:
JSR primm
DB $0C,"Wellcome to the machine 6502, press H for help, ",$00
JSR primm
DB "(c) 2017 vaclav@slajs.xyz",$0D,$0A,$00
RTS
PRINT_HELP:
JSR primm
DB "Available commands:",$0D,$0A,$00
JSR primm
DB " A - Set Address",$0D,$0A,$00
JSR primm
DB " M - Show Memmory",$0D,$0A,$00
JSR primm
DB " C - Change Memory",$0D,$0A,$00
JSR primm
DB " G - Go To the Address",$0D,$0A,$00
JSR primm
DB " R - Show Registers",$0D,$0A,$00
RTS
PRINT_REGS:
JSR primm
DB "A = ",$00
STA console_data
JSR print_byte
JSR primm
DB ", X = ",$00
STX console_data
JSR print_byte
JSR primm
DB ", Y = ",$00
STY console_data
JSR print_byte
JSR print_nl
RTS
SHOW_MEMORY:
JSR get_address
JSR primm
DB "Data: 0x",$00
; Read byte from address and print it
LDX #$00
LDA (console_address,X)
STA console_data
JSR print_byte
JSR print_nl
RTS
CHANGE_MEMORY:
JSR get_address
JSR primm
DB "Data: 0x",$00
; Read byte from address and print it
LDX #$00
LDA (console_address,X)
STA console_data
JSR print_byte
JSR print_nl
JSR primm
DB "New Data: 0x",$00
JSR read_byte
LDA console_data
; Write byte to address
LDX #$00
STA (console_address,X)
JSR print_nl
RTS
GO_MEMORY:
JSR get_address
JMP (console_address)
SET_ADDRESS:
JSR primm
DB "Enter Address: 0x",$00
JSR read_address
JSR print_nl
RTS
GET_ADDRESS:
; is one of address bytes non zero?
LDA console_address
BNE gt_done
LDA console_address+1
BNE gt_done
JSR set_address
GT_DONE:
RTS
.INCLUDE serial.a65
.INCLUDE console.a65
; -----------------------------------
; ------ Adresses Definitions -------
; -----------------------------------
.ORG $FFFA
DW reset ; NMI
DW reset
DW reset ; RESET
DW reset
DW reset ; IRQ
DW reset