├── .gitattributes
├── .gitignore
├── OSKMon.asm
├── OSKMon.cbmprj
├── OSKMonVIC.cbmprj
├── README.md
├── libAssembleCommand.asm
├── libBASICRoutines.asm
├── libBinaryCommand.asm
├── libCharacterASCIIConst.asm
├── libCommandCommand.asm
├── libDecimalCommand.asm
├── libDissassembleCommand.asm
├── libErrorCodes.asm
├── libErrorHandler.asm
├── libExitCommand.asm
├── libFillCommand.asm
├── libGoCommand.asm
├── libHelpCommand.asm
├── libHexadecimalCommand.asm
├── libHuntCommand.asm
├── libInterpretCommand.asm
├── libLoadCommand.asm
├── libMemoryCommand.asm
├── libOSKRoutines.asm
├── libOctalCommand.asm
├── libOpCodesArray.asm
├── libOutputCommand.asm
├── libROMRoutines.asm
├── libRegisterCommand.asm
├── libSaveCommand.asm
└── libTransferCommand.asm
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows thumbnail cache files
2 | Thumbs.db
3 | ehthumbs.db
4 | ehthumbs_vista.db
5 |
6 | # Folder config file
7 | Desktop.ini
8 |
9 | # Recycle Bin used on file shares
10 | $RECYCLE.BIN/
11 |
12 | # Windows Installer files
13 | *.cab
14 | *.msi
15 | *.msm
16 | *.msp
17 |
18 | # Windows shortcuts
19 | *.lnk
20 |
21 | # =========================
22 | # Operating System Files
23 | # =========================
24 |
--------------------------------------------------------------------------------
/OSKMon.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* OldSkoolCoder Machine Code Monitor *
3 | ;* *
4 | ;* Writtern By John C. Dale *
5 | ;* *
6 | ;* Date 16th April 2018 *
7 | ;*******************************************************************************
8 | ;* *
9 | ;* Change History *
10 | ;* 16th Apr 2018 : Created new project for use in the new Machine Code Monitor *
11 | ;* Video Series *
12 | ;* 18th Apr 2018 : Added Break, Tokaniser and Register Command *
13 | ;* 2nd May 2018 : Added Assembler Command *
14 | ;* 14th May 2018 : Added Dissassembler Command *
15 | ;* 18th May 2018 : Added Command Command *
16 | ;* 20th May 2018 : Added Fill Command *
17 | ;* 22nd May 2018 : Added Gosub Command *
18 | ;* 2nd June 2018 : Added Hunt Command *
19 | ;* 6th June 2018 : Added Interpret Command *
20 | ;* 21st June 2018 : Added Load Command *
21 | ;* 22nd June 2018 : Added Memory Command *
22 | ;* 22nd June 2018 : Added MemoryPut Command *
23 | ;* 23rd June 2018 : Added Output Command *
24 | ;* 24th June 2018 : Added Save Command *
25 | ;* 24th June 2018 : Added Transfer Command *
26 | ;* 24th June 2018 : Added Exit Command *
27 | ;* 26th June 2018 : Added Decimal Command *
28 | ;* 26th June 2018 : Added Hexadecimal Command *
29 | ;* 26th June 2018 : Added Binary Command *
30 | ;* 26th June 2018 : Added Octal Command *
31 | ;*******************************************************************************
32 |
33 | ;*******************************************************************************
34 | ;* Includes *
35 | ;*******************************************************************************
36 |
37 | ifdef TGT_C64
38 | *= $9000
39 | CARTSTART = $9000
40 | endif
41 |
42 |
43 | ifdef TGT_VIC20_8K
44 | *= $B000
45 | CARTSTART = $B000
46 | endif
47 |
48 | jmp STARTMON
49 |
50 | incasm "libOpCodesArray.asm"
51 | incasm "libCharacterASCIIConst.asm"
52 | incasm "libROMRoutines.asm"
53 |
54 | ;*******************************************************************************
55 | ;* Variables *
56 | ;*******************************************************************************
57 |
58 | ADDVEC = 247
59 | CINV = $0314
60 | CBINV = $0316
61 | NMINV = $0318
62 |
63 | HT = $14
64 | HTVEC = $0014
65 |
66 | ;*******************************************************************************
67 | ;* Code *
68 | ;*******************************************************************************
69 |
70 | STARTMON
71 | ldy #>TITLE ; Load Title Start Location
72 | lda #
BREAK_VECTOR
76 | sei
77 | sta CBINV ; Set Break Vectors
78 | sty CBINV + 1
79 | cli
80 | brk
81 |
82 | ;*******************************************************************************
83 | ;* Break Operation *
84 | ;*******************************************************************************
85 |
86 | BREAK_VECTOR
87 | pla ; Get X Reg from Stack
88 | sta YREG
89 | pla ; Get Y Reg from Stack
90 | sta XREG
91 | pla ; Get Acc From Stack
92 | sta ACCREG
93 | pla ; Get Status Register From Stack
94 | sta STREG
95 | pla ; Get Program Counter Lo From Stack
96 | sta PCLOREG
97 | pla ; Get Program Counter Hi From Stack
98 | sta PCHIREG
99 | tsx ; Get Current Status Register
100 | stx STPTREG
101 | lda CINV ; Get current IRQ Pointer Vector
102 | ldy CINV + 1
103 | sta IRQINT
104 | sty IRQINT + 1
105 | lda NMINV ; Get Current NMI Pointer Vector
106 | ldy NMINV + 1
107 | sta NMIINT
108 | sty NMIINT + 1
109 | lda PCLOREG ; Load PC Counter Lo
110 | sec
111 | sbc #2 ; Subtract 2
112 | sta PCLOREG ; Store back to PC Counter Lo
113 | bcs @BREAK
114 | dec PCHIREG ; Dec PC Counter Hi if Carry Clear
115 | @BREAK
116 | jmp COM_REGISTER
117 |
118 | TITLE
119 | ifdef TGT_C64
120 | BYTE CHR_ClearScreen
121 | TEXT "oldskoolcoder machine code monitor"
122 | BYTE 13, CHR_CursorDown
123 | TEXT "for the commodore 64 by j.c.dale"
124 | BYTE 13, CHR_CursorDown
125 | TEXT "(c) april 2018 oldskoolcoder"
126 | BYTE CHR_CursorDown
127 | brk
128 | endif
129 |
130 | ifdef TGT_VIC20_8K
131 | BYTE CHR_ClearScreen
132 | TEXT "machine code monitor"
133 | BYTE 13, CHR_CursorDown
134 | TEXT "for vic20 by j.c.dale"
135 | BYTE 13, CHR_CursorDown
136 | TEXT "(c) april 2018 osk"
137 | BYTE CHR_CursorDown
138 | brk
139 | endif
140 |
141 |
142 | ;*******************************************************************************
143 | ;* Storage Locations *
144 | ;*******************************************************************************
145 |
146 | YREG = $02A7 ; Store location for Y Register
147 | XREG = YREG + 1 ; Store location for X Register
148 | ACCREG = XREG + 1 ; Store location for Accumulator Register
149 | STREG = ACCREG + 1 ; Store location for Status Register
150 | PCLOREG = STREG + 1 ; Store location for Program Counter Lo
151 | PCHIREG = PCLOREG + 1 ; Store location for Program Counter Hi
152 | STPTREG = PCHIREG + 1 ; Store location for Stack Pointer Register
153 | IRQINT = STPTREG + 1 ; Store location for IRQ Vector Address
154 | NMIINT = IRQINT + 2 ; Store location for NMI Vector Address
155 | TEMP = NMIINT + 2 ; Store location for Temp Vector Address
156 |
157 | STREGISTER = TEMP + 1
158 |
159 | COM_P = STREGISTER + 1
160 | COM_NB = COM_P + 1
161 | COM_MODE = COM_NB + 1 ; Store location for Mode
162 | COM_CODE = COM_MODE + 1
163 | COM_L = COM_CODE + 1
164 | COM_TEXT = COM_L + 1 ; Storage Location For Command Buffer Text
165 |
166 | DIS_END = COM_TEXT + 26 ; Store location for End Vector Address
167 | NEXT = DIS_END + 2 ; Store location for Next Vector Address
168 | LOCATION = NEXT + 2 ; Store location for Location Vector Address
169 | MODE_JUMP_VEC = LOCATION + 2 ; Store location for MODE Jump Vector Address
170 |
171 | incasm "libOSKRoutines.asm"
172 | incasm "libRegisterCommand.asm"
173 | incasm "libAssembleCommand.asm"
174 | incasm "libDissassembleCommand.asm"
175 | incasm "libCommandCommand.asm"
176 | incasm "libFillCommand.asm"
177 | incasm "libGoCommand.asm"
178 | incasm "libHuntCommand.asm"
179 | incasm "libInterpretCommand.asm"
180 | incasm "libLoadCommand.asm"
181 | incasm "libMemoryCommand.asm"
182 | incasm "libOutputCommand.asm"
183 | incasm "libSaveCommand.asm"
184 | incasm "libTransferCommand.asm"
185 | incasm "libExitCommand.asm"
186 | incasm "libDecimalCommand.asm"
187 | incasm "libHexadecimalCommand.asm"
188 | incasm "libBinaryCommand.asm"
189 | incasm "libOctalCommand.asm"
190 | incasm "libHelpCommand.asm"
191 |
--------------------------------------------------------------------------------
/OSKMon.cbmprj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 2
7 | oskmon.prg
8 | 2049
9 | False
10 | False
11 | False
12 | False
13 | True
14 |
15 | OldSkoolCoders Machine Code Monitor
16 |
17 | oskmon.prg
18 | False
19 |
20 | False
21 | C64 CARTRIDGE
22 |
23 | 40
24 | 1
25 | 0
26 | 0
27 | False
28 | False
29 | CHIP
30 | 0
31 |
32 |
33 | False
34 | False
35 | False
36 |
37 |
38 |
39 |
40 | libAssembleCommand.asm
41 | libBASICRoutines.asm
42 | libBinaryCommand.asm
43 | libCharacterASCIIConst.asm
44 | libCommandCommand.asm
45 | libDecimalCommand.asm
46 | libDissassembleCommand.asm
47 | libErrorCodes.asm
48 | libErrorHandler.asm
49 | libExitCommand.asm
50 | libFillCommand.asm
51 | libGoCommand.asm
52 | libHelpCommand.asm
53 | libHexadecimalCommand.asm
54 | libHuntCommand.asm
55 | libInterpretCommand.asm
56 | libLoadCommand.asm
57 | libMemoryCommand.asm
58 | libOctalCommand.asm
59 | libOpCodesArray.asm
60 | libOSKRoutines.asm
61 | libOutputCommand.asm
62 | libRegisterCommand.asm
63 | libROMRoutines.asm
64 | libSaveCommand.asm
65 | libTransferCommand.asm
66 | OSKMon.asm
67 |
68 | 0
69 | 0
70 |
71 |
72 |
73 | libAssembleCommand.asm
74 |
75 | 2
76 | True
77 |
78 |
79 |
80 | False
81 | False
82 |
83 |
84 | libBASICRoutines.asm
85 |
86 | 2
87 | True
88 |
89 |
90 |
91 | False
92 | False
93 |
94 |
95 | libBinaryCommand.asm
96 |
97 | 2
98 | True
99 |
100 |
101 |
102 | False
103 | False
104 |
105 |
106 | libCharacterASCIIConst.asm
107 |
108 | 2
109 | True
110 |
111 |
112 |
113 | False
114 | False
115 |
116 |
117 | libCommandCommand.asm
118 |
119 | 2
120 | True
121 |
122 |
123 |
124 | False
125 | False
126 |
127 |
128 | libDecimalCommand.asm
129 |
130 | 2
131 | True
132 |
133 |
134 |
135 | False
136 | False
137 |
138 |
139 | libDissassembleCommand.asm
140 |
141 | 2
142 | True
143 |
144 |
145 |
146 | False
147 | False
148 |
149 |
150 | libErrorCodes.asm
151 |
152 | 2
153 | True
154 |
155 |
156 |
157 | False
158 | False
159 |
160 |
161 | libErrorHandler.asm
162 |
163 | 2
164 | True
165 |
166 |
167 |
168 | False
169 | False
170 |
171 |
172 | libExitCommand.asm
173 |
174 | 2
175 | True
176 |
177 |
178 |
179 | False
180 | False
181 |
182 |
183 | libFillCommand.asm
184 |
185 | 2
186 | True
187 |
188 |
189 |
190 | False
191 | False
192 |
193 |
194 | libGoCommand.asm
195 |
196 | 2
197 | True
198 |
199 |
200 |
201 | False
202 | True
203 |
204 |
205 | libHelpCommand.asm
206 |
207 | 2
208 | True
209 |
210 |
211 |
212 | False
213 | False
214 |
215 |
216 | libHexadecimalCommand.asm
217 |
218 | 2
219 | True
220 |
221 |
222 |
223 | False
224 | False
225 |
226 |
227 | libHuntCommand.asm
228 |
229 | 2
230 | True
231 |
232 |
233 |
234 | False
235 | False
236 |
237 |
238 | libInterpretCommand.asm
239 |
240 | 2
241 | True
242 |
243 |
244 |
245 | False
246 | False
247 |
248 |
249 | libLoadCommand.asm
250 |
251 | 2
252 | True
253 |
254 |
255 |
256 | False
257 | False
258 |
259 |
260 | libMemoryCommand.asm
261 |
262 | 2
263 | True
264 |
265 |
266 |
267 | False
268 | False
269 |
270 |
271 | libOctalCommand.asm
272 |
273 | 2
274 | True
275 |
276 |
277 |
278 | False
279 | False
280 |
281 |
282 | libOpCodesArray.asm
283 |
284 | 2
285 | True
286 |
287 |
288 |
289 | False
290 | True
291 |
292 |
293 | libOSKRoutines.asm
294 |
295 | 2
296 | True
297 |
298 |
299 |
300 | False
301 | True
302 |
303 |
304 | libOutputCommand.asm
305 |
306 | 2
307 | True
308 |
309 |
310 |
311 | False
312 | False
313 |
314 |
315 | libRegisterCommand.asm
316 |
317 | 2
318 | True
319 |
320 |
321 |
322 | False
323 | False
324 |
325 |
326 | libROMRoutines.asm
327 |
328 | 2
329 | True
330 |
331 |
332 |
333 | False
334 | False
335 |
336 |
337 | libSaveCommand.asm
338 |
339 | 2
340 | True
341 |
342 |
343 |
344 | False
345 | False
346 |
347 |
348 | libTransferCommand.asm
349 |
350 | 2
351 | True
352 |
353 |
354 |
355 | False
356 | False
357 |
358 |
359 | OSKMon.asm
360 |
361 | 2
362 | True
363 |
364 |
365 |
366 | True
367 | True
368 |
369 |
370 |
--------------------------------------------------------------------------------
/OSKMonVIC.cbmprj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 10
7 | oskmonvic.prg
8 | 4609
9 | False
10 | False
11 | False
12 | False
13 | True
14 |
15 |
16 | John Conrad Dale (OldSkoolCoder)
17 | oskmonvic.prg
18 | False
19 |
20 | False
21 | C64 CARTRIDGE
22 |
23 | 40
24 | 1
25 | 0
26 | 0
27 | False
28 | False
29 | CHIP
30 | 0
31 |
32 |
33 | False
34 | False
35 | False
36 |
37 |
38 |
39 |
40 | libAssembleCommand.asm
41 | libBASICRoutines.asm
42 | libBinaryCommand.asm
43 | libCharacterASCIIConst.asm
44 | libCommandCommand.asm
45 | libDecimalCommand.asm
46 | libDissassembleCommand.asm
47 | libErrorCodes.asm
48 | libErrorHandler.asm
49 | libExitCommand.asm
50 | libFillCommand.asm
51 | libGoCommand.asm
52 | libHelpCommand.asm
53 | libHexadecimalCommand.asm
54 | libHuntCommand.asm
55 | libInterpretCommand.asm
56 | libLoadCommand.asm
57 | libMemoryCommand.asm
58 | libOctalCommand.asm
59 | libOpCodesArray.asm
60 | libOSKRoutines.asm
61 | libOutputCommand.asm
62 | libRegisterCommand.asm
63 | libROMRoutines.asm
64 | libSaveCommand.asm
65 | libTransferCommand.asm
66 | OSKMon.asm
67 |
68 | 0
69 | 0
70 |
71 |
72 |
73 | libAssembleCommand.asm
74 |
75 | 2
76 | True
77 |
78 |
79 |
80 | False
81 | False
82 |
83 |
84 | libBASICRoutines.asm
85 |
86 | 2
87 | True
88 |
89 |
90 |
91 | False
92 | False
93 |
94 |
95 | libBinaryCommand.asm
96 |
97 | 2
98 | True
99 |
100 |
101 |
102 | False
103 | False
104 |
105 |
106 | libCharacterASCIIConst.asm
107 |
108 | 2
109 | True
110 |
111 |
112 |
113 | False
114 | False
115 |
116 |
117 | libCommandCommand.asm
118 |
119 | 2
120 | True
121 |
122 |
123 |
124 | False
125 | False
126 |
127 |
128 | libDecimalCommand.asm
129 |
130 | 2
131 | True
132 |
133 |
134 |
135 | False
136 | False
137 |
138 |
139 | libDissassembleCommand.asm
140 |
141 | 2
142 | True
143 |
144 |
145 |
146 | False
147 | False
148 |
149 |
150 | libErrorCodes.asm
151 |
152 | 2
153 | True
154 |
155 |
156 |
157 | False
158 | False
159 |
160 |
161 | libErrorHandler.asm
162 |
163 | 2
164 | True
165 |
166 |
167 |
168 | False
169 | False
170 |
171 |
172 | libExitCommand.asm
173 |
174 | 2
175 | True
176 |
177 |
178 |
179 | False
180 | False
181 |
182 |
183 | libFillCommand.asm
184 |
185 | 2
186 | True
187 |
188 |
189 |
190 | False
191 | False
192 |
193 |
194 | libGoCommand.asm
195 |
196 | 2
197 | True
198 |
199 |
200 |
201 | False
202 | False
203 |
204 |
205 | libHelpCommand.asm
206 |
207 | 2
208 | True
209 |
210 |
211 |
212 | False
213 | False
214 |
215 |
216 | libHexadecimalCommand.asm
217 |
218 | 2
219 | True
220 |
221 |
222 |
223 | False
224 | False
225 |
226 |
227 | libHuntCommand.asm
228 |
229 | 2
230 | True
231 |
232 |
233 |
234 | False
235 | False
236 |
237 |
238 | libInterpretCommand.asm
239 |
240 | 2
241 | True
242 |
243 |
244 |
245 | False
246 | False
247 |
248 |
249 | libLoadCommand.asm
250 |
251 | 2
252 | True
253 |
254 |
255 |
256 | False
257 | False
258 |
259 |
260 | libMemoryCommand.asm
261 |
262 | 2
263 | True
264 |
265 |
266 |
267 | False
268 | False
269 |
270 |
271 | libOctalCommand.asm
272 |
273 | 2
274 | True
275 |
276 |
277 |
278 | False
279 | False
280 |
281 |
282 | libOpCodesArray.asm
283 |
284 | 2
285 | True
286 |
287 |
288 |
289 | False
290 | False
291 |
292 |
293 | libOSKRoutines.asm
294 |
295 | 2
296 | True
297 |
298 |
299 |
300 | False
301 | True
302 |
303 |
304 | libOutputCommand.asm
305 |
306 | 2
307 | True
308 |
309 |
310 |
311 | False
312 | False
313 |
314 |
315 | libRegisterCommand.asm
316 |
317 | 2
318 | True
319 |
320 |
321 |
322 | False
323 | True
324 |
325 |
326 | libROMRoutines.asm
327 |
328 | 2
329 | True
330 |
331 |
332 |
333 | False
334 | False
335 |
336 |
337 | libSaveCommand.asm
338 |
339 | 2
340 | True
341 |
342 |
343 |
344 | False
345 | False
346 |
347 |
348 | libTransferCommand.asm
349 |
350 | 2
351 | True
352 |
353 |
354 |
355 | False
356 | False
357 |
358 |
359 | OSKMon.asm
360 |
361 | 2
362 | True
363 |
364 |
365 |
366 | True
367 | True
368 |
369 |
370 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OSKMon : Tutorial 32
2 |
3 | ## OldSkoolCoder Machine Code Monitor
4 |
5 | This repository shows how a common set of code can be made to be used on two different systems, C64 and VIC 20
6 |
7 | this code is a machine code monitor for both systems and allows the user to create machine code programs directly onto the computer.
8 |
9 | Enjoy
10 |
11 | ### List of Command avaliable in OSKMon
12 |
13 | The parameters in the command formats are represented as follows :-
14 |
15 | * **(addr)** A two byte hex address, e.g. 0400
16 | * **(dev)** A single byte dex device number, e.g. 08 (DISC)
17 | * **(opcode)** A valid 6510 assembly mnemonic, e.g. LDA
18 | * **(operand)** A valid operand for the proceeding instruction, e.g. #$01
19 | * **(value)** A single byte hex value, e.g. FF
20 | * **(data)** A string of literal data enclosed in quotes of hex values. Successive items are separated with commas.
21 | * **(ref)** A two byte hex address, e.g. 2000
22 | * **(offset)** A two byte offset value, e.g. 3000
23 |
24 | #### A – ASSEMBLE
25 | Format : `A (addr) (opcode) (operand)`
26 |
27 | Purpose :
28 | >To assemble code starting from a specific address.
29 | >The command allows you to input assembly code line by line, and have it stored as machine code.
30 | >When the command is entered, the appropriate code is written in memory beginning at the specified address.
31 | >The address of the available memory location beyond that required by the specific op-code and operand is then prompted awaiting input of additional code.
32 | >To terminate the A command, simply press when the new address is prompted. If you input an illegal op-code or operand, OSKMON will place a question mark after the illegal quantity and will return you to the monitor with the prompt ‘>’ and a new line.
33 | >If you fail to specify either the op-code or operand, OSKMON will ignore the line and return you to the monitor with a ‘>’ on a new line.
34 |
35 | **N.B.** All operands must be given as hex numbers proceeded by a dollar sign ($). i.e. typed as $nn or $nnnn
36 |
37 | Example : To Enter the following machine code :-
38 | `LDA #$19`
39 | `JSR $FFD2`
40 | `RTS`
41 |
42 | Beginning at address $C000
43 | Type : **`A C000 LDA#$19 `**
44 | Display :
45 | `, C000 LDA #$19`
46 | `A C002`
47 |
48 | Type : **`JSR $FFD2 `**
49 | Display :
50 | `, C000 LDA #$19`
51 | `, C002 JSR FFD2`
52 | `A C005`
53 |
54 | Type : **`RTS `**
55 | Display :
56 | `, C000 LDA #$19`
57 | `, C002 JSR FFD2`
58 | `, C005 RTS`
59 | `, C006`
60 |
61 | *Result* : The machine code equivalent of the specified assembly language is stored in the memory from location $C000 to $C005 inclusive.
62 |
63 | #### C – COMMAND
64 | Format : `C (opcode)`
65 |
66 | Purpose :
67 | >To show you all the addressing modes of that command.
68 | >This command allows you to see what addressing modes are available.
69 |
70 | Example : To show all the addressing modes for CMP.
71 |
72 | Type : **`C CMP `**
73 | Display :
74 | CMP $DCBA ABSOLUTE
75 | CMP $DCBA,X ABSOLUTE,X
76 | CMP $DCBA,Y ABSOLUTE,Y
77 | CMP #$BA IMMEDIATE
78 | CMP ($BA,X) (INDIRECT,X)
79 | CMP ($BA),Y (INDIRECT),Y
80 | CMP $BA ZERO-PAGE
81 | CMP $BA,X ZERO-PAGE,X
82 |
83 | Result : There are eight possible addressing modes for op-code CMP.
84 |
85 | #### D – DISSASSEMBLE
86 | Format : `D (addr) (addr)`
87 |
88 | Purpose :
89 | >To disassemble code between a range of addresses
90 | >The D command enables you to convert the code that is stored in the computer’s memory back into assembly language notations. You may specify a range of addresses to be disassembled. The lines specified will be displayed on the screen one at a time and the screen will scroll.
91 | >The key will terminate the scrolling and you will remain in the disassemble mode. While you are in Disassemble mode, a line of code on the screen can be modified by a simply correcting or retyping the line and pressing .
92 | >The A Command is automatically activated. When you have made the change, you remain in the A mode with the cursor positioned after the address on the line following the correct line. To terminate the assembly mode, clear the screen and press .
93 |
94 | Example : To disassemble the lines of code input in the example of the assemble command, and then to change the address in the second line to $FFD0
95 |
96 | Type : `D C000 C005 `
97 | Display :
98 | `>, C000 LDA #$19`
99 | `>, C002 JSR $FFD2`
100 | `>, C005 RTS`
101 |
102 | *Action* : Move the cursor so that it is positioned over the 2 in $FFD2
103 |
104 | Type : `0 `
105 | Display :
106 | `>, C000 LDA #$19`
107 | `>, C002 JSR $FFD0`
108 | `>A C005 RTS`
109 |
110 | *Result* : The code from location C000 to C005 is disassembled. The change is made and then stored with the key. You are left in the assemble mode.
111 |
112 | #### F – FILL
113 | Format : `F (addr) (addr) (value)`
114 | Purpose :
115 | >To Fill memory between two specified addresses with a given value.
116 | The F command enabled you to put a known value into a specified block of memory. This is useful for initialising data structure for the blanking out the contents of any RAM area.
117 | Simply specify the range of the block of memory and the pattern you wish to write in that block. Naturally you should not specify addresses from `$0000` to `$01FF` (Page Zero and one) or `$9000` to `$A000` (where OSKMON is stored)
118 |
119 | Example : To write $EA (a no-op instruction) from location $2000 to $3000 inclusive.
120 |
121 | Type: `F 2000 3000 EA `
122 | *Result* : The no-op instruction ($EA) is written in all the addresses from $2000 to $3000.
123 |
124 | #### G – GO
125 | Format : `G or G (addr)`
126 | Purpose :
127 | >To execute a program beginning at the location currently in the program counter or beginning from a specified address.
128 | >The G command may be used alone or stated with an address. When G is used alone, the C64’s 6510 cpu will execute the program in memory beginning with the location currently in the program counter. (To display the contents of the program counter, use the R command as described later in this manual).
129 |
130 | Example : assume that you have a program in memory and wish to begin execution from location $2000
131 |
132 | Type : `G 2000 `
133 | *Result* : The register will be restored. The PC will be set to $2000. The program will begin executing at $2000
134 |
135 | #### H – HUNT
136 | Format : `H (addr) (addr) (data)` [up to 11 pieces of data or 25 characters]
137 | Purpose :
138 | >To search through a specified block of memory and locate all occurrences of particular data or character strings.
139 | >The H command easily locates and specified character pattern that’s in the computer’s memory and displays it on the screen. You use this command to locate data, which is specified in hex, or to find text strings up to 25 characters long (1/2 a line).
140 | >All locations within the specified range which contain the requested characters will be found. If there are more occurrences than will fit on the screen, the screen will scroll. The key will slow the rate of scrolling. When all occurrences within the range have been located, you will be returned to OSKMON.
141 |
142 | Example 1 : Assume that the data string A92F3C is stored in memory somewhere between locations $C000 and location $C0FF. To locate the string.
143 |
144 | Type : `H C000 C0FF A9 2F 3C `
145 | *Result* : Memory is searched between $C000 and $C0FF and the locations where A92F3C is stored, are displayed.
146 |
147 | Example 2 : Assume that the data string ‘PRESS PLAY ON’ is stored in memory somewhere between locations $E000 and location $FFFF. To locate the string.
148 |
149 | Type : `H C000 C0FF ‘PRESS PLAY ON `
150 | *Result* : Memory is searched between $E000 and $FFFF and the locations where ‘PRESS PLAY ON’ is stored, are displayed.
151 |
152 | #### I – INTERPRET
153 | Format : `I (addr) (addr)`
154 | Purpose :
155 | >To locate and display printable txt characters within a specified block of memory.
156 | >The I Command will display any of the 96 printable CBM ASCII code equivalents occurring within the specified block of memory. All other characters in the block will be indicated by a dot ‘.’
157 | >If the specified block fills the screen, the screen will scroll. The key will terminate the scrolling and the key will slow the rate of scrolling.
158 |
159 | Example : To show the characters in memory from $A09E to $A19E
160 |
161 | Type : `I A09E A19E `
162 |
163 | #### L – LOAD
164 | Format : `L “FILENAME” (dev)`
165 | Purpose :
166 | >To load a program file into memory from a specified device.
167 | >The L Command enables you to read a load file or a program file which is stored on a cassette or disc and write it into the C64’s RAM. For disc files, the address of the first location in RAM into which the load file will be read must be the first two bytes of a file. Tape files have the start address as part of the header block.
168 |
169 | Example : Assume you have a disc program file names TEST which is 258 bytes long, the first two bytes of which are 00CA. To read this file into memory.
170 |
171 | Type : `L “TEST” 08 `
172 | *Result* : The program named TEST which is on the diskette in the disc unite is loaded into memory from CA00 to CB00 inclusive.
173 |
174 | #### M – MEMORY
175 | Format : `M (addr) (addr)`
176 | Purpose :
177 | >To display the hec code which is stored in a given block of memory.
178 | >The M command will display the contents of memory from the start address in the command up to and including the contents of the end address. The display will have the address and ten hex bytes on a line.
179 | >If only one address is given in the command, ten bytes will be displayed beginning with the contents of the specified address.
180 | >The contents of the memory may be changed by typing over the displayed values and then pressing the key.
181 |
182 | Example : display the ten bytes of memory beginning at location $c000 and to change the $00 to $FF
183 |
184 | Type : `M C000 C005 `
185 | Display :
186 | `>: C000 A0 00 EA EA EA EA EA EA EA EA`
187 |
188 | Action : Position the cursor over the first 0 or 00. Type FF and press
189 |
190 | *Result* : the ten bytes of the memory beginning at location $C000 should now read :- A0 FF EA EA EA EA EA EA EA EA
191 |
192 | #### O – OUTPUT
193 | Format : `O (Y or N)`
194 | Purpose : To set the printer up for printing if ‘Y’. or to stop printer printing by answering ‘N’.
195 |
196 | Type : `OY` or `ON` ``
197 |
198 | #### R – REGISTER
199 | Format : `R`
200 | Purpose :
201 | >To display the contents of the registers.
202 | >The R command enables you to view the current status of the following registers in the C64’s 6520 CPU.
203 | >* Program Counter = PC
204 | >* IRQ Jump Vectors = IRQ
205 | >* NMI Jump Vectors = NMI
206 | >* Status Register = SR
207 | >* Accumulator = AC
208 | >* Index Register X = XR
209 | >* Index Register Y = YR
210 | >* Stack Pointer = SP
211 |
212 | >This can be useful when you are debugging a program because the R enables you to see if the registers contain the values you are expecting. You may also change the values in the register whilst in the R mode by simply typing over a value and pressing .
213 | >The register display is automatically generated when OSKMON is started up or when a BRK is reached in G mode.
214 |
215 | Example : To display the contents of the registers
216 |
217 | Type : `R`
218 | Display :
219 | >R
220 | >B*
221 | PC IRQ NMI SR AC XR YR SP
222 | >;DC84 EA31 FE72 B1 0C 00 93 F6
223 |
224 | #### S – SAVE
225 | Format : `S “FILENAME” (dev) (addr) (addr)`
226 | Purpose :
227 | >To write the contents of a specified RAM area to a particular device.
228 | >The S command enables you to save a program on diskette or cassette, so that it can be used at a later time. The command consisted of the name of the file, the number of the device to be written too and the start and end address of the RAM block.
229 | >The filename must be enclosed in quotation marks and must obey the syntax rules of the C64 files, i.e. it must begin with an alphabetical character and be more than 16 characters long. The device number of the cassette unit is 01 and of the disc unit, 08. The final address must be one larger than the location of the last byte you wish to write.
230 | **WARNING**
231 | >If the final address is not one larger than the location of the last byte you wish to save, the last byte will be lost.
232 | >If the specified device is not present you will get an error message and be returned to BASIC.
233 |
234 | Example : Assume that you have a program in memory from location $C000 to $C0FF. To write that program to the diskette in the disc drive, naming that program TEST1.
235 |
236 | Type : `S “TEST1” 08 C000 C100 `
237 | *Result* : A file names TEST1 will be written on the diskette. It will contain the code which is in RAM locations $C000 to $C0FF inclusive.
238 |
239 | #### T – TRANSFER
240 | Format : `T (addr) (addr) (addr)`
241 | Purpose :
242 | >To transfer the contents of a block of memory from one area of RAM to another.
243 | The T command enables you to relocate your program or data to another part of memory. This can be useful if you which to expand a program or to use part of a program elsewhere without re-typing.
244 | >The command consists of three addresses. The first two indicate the block of memory to be duplicated. The third address indicates the starting address for the copy.
245 |
246 | Example : Assume that you have a block of data in memory from location $3000 to $3500. Toe move that data to a new location beginning at $4000.
247 |
248 | Type : `T 3000 3500 4000 `
249 | *Result* : the data in block $3000 to $3500, is now copied to $4000 to $4500
250 |
251 | #### X – EXIT
252 | Format : `X`
253 | Purpose :
254 | >The terminate OSKMON and return control back to BASIC.
255 | >The use of X command returns you back to BASIC. Your program will remain in memory.
256 |
257 | Example : To exit OSKMON
258 |
259 | Type : `X `
260 | *Result* : You will return to BASIC and any BASIC program you had in memory will be retained, you will be prompted by READY.
261 |
262 | #### # - DECIMAL to HEXADECIMAL CONVERTOR
263 | Format : `# (No.)` (Range 0 – 65535)
264 | Purpose :
265 | >This is to help you convert DECIMAL into HEX and BINARY.
266 |
267 | Example : To convert 245 to HEX and BINARY
268 |
269 | Type : `# 245 `
270 | Display :
271 | `># 245`
272 | `>$=00F5`
273 | `>%=00000000 11110101`
274 |
275 | #### $ - HEXADECIMAL TO DECIMAL CONVERTOR
276 | Format : `$ (addr)` (Range 0000 – FFFF)
277 | Purpose :
278 | >This is to help you convert HEXADECIMAL into DECIMAL and BINARY.
279 |
280 | Example : To convert $01FE to DECIMAL and BINARY
281 |
282 | Type : `$01FE `
283 | Display :
284 | `>$01FE`
285 | `>#=500`
286 | `>%=00000001 11111110`
287 |
288 | #### % - BINARY to DECIMAL CONVERTOR
289 | Format : `% (16 Bit No.)` (two sets of eight)
290 | Purpose :
291 | >This is to help you convert BINARY into DECIMAL and HEX.
292 |
293 | Example : To convert 11111111 11111111 to DECIMAL and HEX
294 |
295 | Type : `%11111111 11111111 `
296 | Display :
297 | `>%11111111 11111111`
298 | `>$=FFFF`
299 | `>#=65535`
300 |
--------------------------------------------------------------------------------
/libAssembleCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Assemble Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : A (addr) (opcode) (operand)
5 | ;*******************************************************************************
6 |
7 | COM_ASSEMBLE
8 | jsr IBYTE2 ; get address word
9 | stx ADDVEC ; store address
10 | sta ADDVEC + 1
11 | ldy #0 ; initialise length = 0
12 | ASS1
13 | jsr INPUT_COMMAND ; get next command character
14 | cmp #CHR_Return ; is RETURN?
15 | beq ASS2 ; Yes
16 | sta COM_TEXT,y ; No, store character into buffer
17 | iny ; add 1 to number of characters
18 | jmp ASS1 ; get next character
19 |
20 | ASS2
21 | sty COM_L ; store buffer length
22 | cpy #0 ; no characters stored?
23 | bne @ASS2 ; No,
24 | jmp READY ; Yes, return back to command line
25 |
26 | @ASS2
27 | jsr MODE_HUNT ; Determine which addressing mode this command is
28 | sta COM_MODE
29 | cmp #MODE_ERROR ; check for invalid addressign mode
30 | bne @ASS3 ; No, valid mode
31 | jmp ERROR ; Yes, display error
32 |
33 | @ASS3
34 | jsr OPCODE_SEARCH ; Search for OpCode
35 | sta COM_CODE
36 | jsr NOBYT ; Detemine Number Of Bytes for the mode
37 | ldy #0 ; Initialise Index
38 | lda COM_CODE ; load OpCode
39 | sta (ADDVEC),y ; store in address location
40 | lda COM_NB ; Load Number Of Bytes
41 | cmp #1 ; Is only 1 byte
42 | bne @ASS4 ; No, Continue On
43 | jmp ASSEND ; Goto Assembler Line End
44 |
45 | @ASS4
46 | lda COM_MODE ; Load Mode
47 | cmp #MODE_RELATIVE ; Is it Relative
48 | bne @ASS5 ; No, try another
49 | jsr BRANCH ; Run Branch Routine
50 | lda COM_MODE ; Load Mode
51 | cmp #MODE_ERROR ; Is Mode Error
52 | bne @ASS5 ; No, Continue
53 | jmp ERROR ; Yes, Display Error
54 |
55 | @ASS5
56 | lda COM_MODE ; Load Mode
57 | cmp #MODE_RELATIVE ; Is it Relative
58 | bne @ASS6 ; No, Try Another
59 | ldy #1 ; Load Index of 1
60 | lda COM_L ; Load Command L
61 | sta (ADDVEC),y ; Store after OpCode
62 | jmp ASSEND ; Jump To Assembler Line End
63 |
64 | @ASS6
65 | lda COM_MODE ; Load Mode
66 | sec
67 | sbc #MODE_IMPLIED ; Subtract Lowest Mode Value 'a'
68 | asl ; Multiply By 2
69 | tay ; Move To Y Index
70 | lda MODE_JUMP_TABLE,y ; Load Lo Jump Value
71 | sta MODE_JUMP_VEC ; Store in Lo Jump Vector
72 | lda MODE_JUMP_TABLE+1,y ; Load Hi Jump Value
73 | sta MODE_JUMP_VEC + 1 ; Store in Hi Jump Vector
74 | jsr JSRG ; GoSub Jump Vector
75 | lda COM_NB ; Load No Of Bytes
76 | cmp #2 ; is it 2
77 | bne @JSRG ; No, Try Again
78 | lda LOCATION ; Yes, Load Location
79 | ldy #1 ; Load Y with 1
80 | sta (ADDVEC),y ; Store In Opcode + 1
81 |
82 | @JSRG
83 | lda COM_NB ; Load No Of Bytes
84 | cmp #3 ; Is It 3
85 | bne ASSEND ; No, goto Assembler Line End
86 | ldy #1 ; Initialise Y = 1
87 | lda LOCATION ; Load Location
88 | sta (ADDVEC),y ; Store in Opcode + 1
89 | lda LOCATION + 1 ; Load Location + 1
90 | iny ; Increase Index Y
91 | sta (ADDVEC),y ; Store In OpCode + 2
92 |
93 | ASSEND
94 | jsr ASS6 ;
95 | jsr ADDNB ; Add No Of Bytes To Address Location
96 | jsr PrintCarrageReturnAndLineFeed
97 | lda #">" ; Command Line
98 | jsr krljmp_CHROUT$ ; Print Character
99 | lda #"a" ; Assemble Command
100 | jsr krljmp_CHROUT$ ; Print Character
101 | jsr SPACE ; print Space
102 | lda ADDVEC ; Load Address Vector Lo
103 | ldx ADDVEC + 1 ; Load Address Vector Hi
104 | jsr PBYTE2 ; Print Next Address Location
105 | jsr SPACE ; Print space
106 |
107 | ASSLINE
108 | lda #CHR_Return ; Load Carriage Return
109 | jsr krljmp_CHROUT$ ; Print Character
110 | lda #CHR_CursorUp ; Load Cursor Up
111 | jsr krljmp_CHROUT$ ; Print Character
112 | ldy #0 ; Initialise Index
113 |
114 | ASS3
115 | lda #CHR_CursorRight ; Load Cursor Right
116 | sta $0277,y ; Store in the Keyboard Buffer
117 | iny ; increase index
118 | cpy #8 ; is it 8
119 | bne ass3 ; No, do it again
120 | sty 198 ; Yes, Store number characters
121 | jmp TOKANISER_COMMAND ; Goto Command Line
122 |
123 | JSRG
124 | jmp (MODE_JUMP_VEC) ; Jump To Assembler Mode Indirect Jump
125 |
126 | ;*******************************************************************************
127 | ;* MODE Execution Table *
128 | ;*******************************************************************************
129 | MODE_JUMP_TABLE
130 | WORD amoda
131 | WORD amodb
132 | WORD amodb
133 | WORD amodb
134 | WORD amode
135 | WORD amodf
136 | WORD amode
137 | WORD amode
138 | WORD amodi
139 | WORD amodi
140 | WORD amodi
141 | WORD amodl
142 |
143 | AMODA
144 | rts ; Implied Mode, No Bytes need getting
145 |
146 | AMODB
147 | ldy #5 ; Absolute Mode, Get Word Value
148 | jsr GET_HEX_2BYTE_VALUE
149 | stx LOCATION ; Store Location Lo Byte
150 | sta LOCATION + 1 ; Store Location Hi Byte
151 | rts
152 |
153 | AMODE
154 | ldy #6 ; Immediate Mode, Get Byte Value
155 | jmp AMODI + 2
156 |
157 | AMODF
158 | ldy #6 ; Indirect Mode, Get Byte Value
159 | jmp AMODB + 2
160 |
161 | AMODI
162 | ldy #5 ; Zero Page Mode, Get Byte Value
163 | jsr GET_HEX_1BYTE_VALUE
164 | sta LOCATION
165 | rts
166 |
167 | BRANCH
168 | jsr AMODB ; Relative Mode, Get Word Value
169 | lda LOCATION ; Get Location Lo Vector
170 | sec
171 | sbc ADDVEC ; Subtract Address Lo Vector
172 | sta LOCATION ; Store back into Location Lo
173 | lda LOCATION + 1 ; Get Location Hi Vector
174 | sbc ADDVEC + 1 ; Subtract Address Hi
175 | sta LOCATION + 1 ; Store back into location Hi
176 | sec
177 | lda LOCATION
178 | sbc #2 ; Subtract 2 from Location Lo Vector
179 | sta LOCATION
180 | lda LOCATION + 1
181 | sbc #0
182 | sta LOCATION + 1
183 | cmp #0 ; Is Hi Byte Zero
184 | beq AMODL1 ; Yes, Continue Working Out Relative Position
185 | cmp #255 ; Is Hi Byte Negative Value
186 | beq @BRANCH ; Yes, Continue Working Out Negative Relative Position
187 | jmp AMODL1 ; Continue
188 |
189 | @BRANCH
190 | lda LOCATION ; Get Location Lo Value
191 | bpl AMODL1 ; Value Positive
192 | jmp AMODL2 ; Value Negative
193 |
194 | AMODL
195 | lda LOCATION ; Get Location Lo Value
196 | bmi AMODL1 ; Value Negative
197 | jmp AMODL2 ; Value Positive
198 |
199 | AMODL1
200 | lda #MODE_ERROR ; This is in Error
201 | sta COM_MODE
202 | rts
203 |
204 | AMODL2
205 | lda LOCATION ; Get Relative Branch Value
206 | sta COM_L ; Store in Command Length
207 | rts
208 |
209 | ;*******************************************************************************
210 | ;* MODE Evaluation of the A line entered *
211 | ;*******************************************************************************
212 | MODE_HUNT
213 | lda COM_L ; Load String Command Length
214 | cmp #3 ; Is only 3 characters -- E.g. tax
215 | bne MODE_NOTIMPLIED ; No, Test Again ^^^
216 | lda #MODE_IMPLIED ; This is an Implied OpCode
217 | rts
218 |
219 | MODE_NOTIMPLIED
220 | cmp #6 ; Is Only 6 Characters - E.g. lda$60
221 | bne MODE_NOTZEROPAGE ; No, Test Again ^^^^^^
222 | lda #MODE_ZEROPAGE ; This is a ZeroPage OpCode
223 | rts
224 |
225 | MODE_NOTZEROPAGE
226 | cmp #7 ; Is Only 7 Characters - E.g. lda#$00
227 | bne MODE_NOTIMMEDIATE ; No, Test Again ^^^^^^^
228 | lda #MODE_IMMEDIATE ; This is an Immediate OpCode
229 | rts
230 |
231 | MODE_NOTIMMEDIATE
232 | lda COM_TEXT+7 ; Look at keyboard buffer Index 7 - E.g. lda$70,x
233 | cmp #"x" ; is it an x ^
234 | bne MODE_NOTZEROPAGEX ; No, Test Again
235 | lda #MODE_ZEROPAGE_X ; This is a ZeroPage Indexed By X
236 | rts
237 |
238 | MODE_NOTZEROPAGEX
239 | cmp #"y" ; is it an Y - E.g. lda$70,y
240 | bne MODE_NOTZEROPAGEY ; No, Test Again ^
241 | lda #MODE_ZEROPAGE_Y ; This is a ZeroPage Indexed By Y
242 | rts
243 |
244 | MODE_NOTZEROPAGEY
245 | cmp #CHR_Comma ; is it a Comma - E.g. lda($70,x)
246 | bne MODE_NOTINDIRECTX ; No, Test Again ^
247 | lda #MODE_INDIRECT_X ; This is a InDirect OpCode Indexed By X
248 | rts
249 |
250 | MODE_NOTINDIRECTX
251 | cmp #CHR_ClosedBracket ; Is it a Closed Bracket - E.g. lda($70),y
252 | bne MODE_NOTINDIRECTY ; No, Test Again ^
253 | lda #MODE_INDIRECT_Y ; This is an IndDirect OpCode Index By Y
254 | rts
255 |
256 | MODE_NOTINDIRECTY
257 | ldy COM_L ; Load Number Characters in Buffer
258 | dey ; Minus One
259 | lda COM_TEXT,y ; Load That Character - E.g. lda$1234,x
260 | cmp #"x" ; Is it x ^
261 | bne MODE_NOTABSOLUTEX ; No, Try Again
262 | lda #MODE_ABSOLUTE_X ; This is an Absolute OpCode Index By X
263 | rts
264 |
265 | MODE_NOTABSOLUTEX
266 | cmp #"y" ; Is it Y - E.g. lda$1234,y
267 | bne MODE_NOTABSOLUTEY ; No, Try Again ^
268 | lda #MODE_ABSOLUTE_Y ; This is an Absolute OpCode Index By Y
269 | rts
270 |
271 | MODE_NOTABSOLUTEY
272 | cmp #CHR_ClosedBracket ; Is it a Closed Bracket - E.g. jmp($1234)
273 | bne MODE_NOTINDIRECT ; No, Try Again ^
274 | lda #MODE_INDIRECT ; This is an InDirect OpCode
275 | rts
276 |
277 | MODE_NOTINDIRECT
278 | lda COM_TEXT ; Load First Character - E.g. bne$1234
279 | cmp #"b" ; Is it a b ^
280 | bne MODE_NOTRELATIVE ; No, Try Again
281 | lda COM_TEXT+1 ; load Second Character - E.g. bit$1234
282 | cmp #"i" ; Is it i ^
283 | beq MODE_NOTRELATIVE ; Yes, then not a branch OpCode
284 | lda #MODE_RELATIVE
285 | rts
286 |
287 | MODE_NOTRELATIVE
288 | lda COM_L ; Load Number Of Charaters In Buffer - E.g. lda$1234
289 | cmp #8 ; Does it equal 8
290 | bne MODE_NOTABSOLUTE ; No, Try Again
291 | lda #MODE_ABSOLUTE ; Yes, then its a Absolute OpCode
292 | rts
293 |
294 | MODE_NOTABSOLUTE
295 | lda #MODE_ERROR ; We Could Not Evaluate The Addressing Mode
296 | rts
297 |
298 | ASS6
299 | jsr PrintCarrageReturnAndLineFeed ; Print Carriage Return
300 | lda #CHR_CursorUp ; Cursor up
301 | jsr krljmp_CHROUT$ ; Print Character
302 | lda #CHR_CursorUp ; Cursor up
303 | jsr krljmp_CHROUT$ ; Print Character
304 | jmp DIS1 ; Disassemble Last OpCode to Format Correctly
305 |
306 | ;*******************************************************************************
307 | OPCODE_SEARCH
308 | lda #OpCodes
311 | sta HT + 1
312 |
313 | GET_NEXT_OPCODE
314 | ldy #0 ; Initialise Index
315 |
316 | GET_NEXT_OPCODE_CHAR
317 | lda (HT),y ; Load Character
318 | cmp #0 ; End Of Array
319 | beq OPCODE_ERROR ; Yes, Jump To End of Function
320 | cmp COM_TEXT,y ; Compare with Keyboard buffer character
321 | bcc WORKOUT_NEXT_OPCODE ; The character is less
322 | beq OPCODE_CHECK ; The character is equal
323 |
324 | OPCODE_ERROR
325 | jmp ERROR ; No OpCode Found, Display Error
326 |
327 | OPCODE_CHECK
328 | iny ; Match Character, lets try next character
329 | cpy #3 ; Have we hit OpCode Max Characters
330 | bne GET_NEXT_OPCODE_CHAR ; No, not hit OpCode limit
331 | lda (HT),y ; Yes, we have a match, Get OpCode Mode
332 | cmp COM_MODE ; Is it the same as what we have evaluated
333 | bne WORKOUT_NEXT_OPCODE ; No, then find next Mode Type for OpCode
334 | iny ; Increase Index By 1
335 | lda (HT),y ; Get OpCode Value
336 | rts
337 |
338 | WORKOUT_NEXT_OPCODE
339 | lda HT ; Load OpCode Lo Address
340 | clc
341 | adc #5 ; Add 5, for next Record
342 | sta HT ; Store Back into Lo Address
343 | bcc @WORKOUT_NEXT_OPCODE ; Did we use the Carry
344 | inc HT + 1 ; Yes, Increase Hi Record By 1
345 |
346 | @WORKOUT_NEXT_OPCODE
347 | jmp GET_NEXT_OPCODE ; Jump back to Test Next OpCode
348 |
--------------------------------------------------------------------------------
/libBASICRoutines.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Get Number From Command Line Routine *
3 | ;* Output Variables : *
4 | ;* Accumulator has HiByte Value *
5 | ;* X Register has LoByte Value *
6 | ;*******************************************************************************
7 |
8 | LineNumberLo = $14
9 | LineNumberHi = $15
10 |
11 | GetNumberFromCommandLine
12 | jsr CHRGOT
13 | bcs GNFCL_Return ; No number on command line
14 | jsr bas_LineGet$ ; Get Integer Value From Command Line
15 | lda LineNumberHi ; Stores Hi Integer Value
16 | ldx LineNumberLo ; Stores Lo Integer Value
17 | clc
18 |
19 | GNFCL_Return
20 | rts
21 |
22 | ;*******************************************************************************
23 | ;* My Verion of BASIC Routine $AB1E, but mine does not stop at Page Boundary *
24 | ;* Input Variables : *
25 | ;* Accumulator has LoByte Value *
26 | ;* Y Register has HiByte Value *
27 | ;*******************************************************************************
28 | ABIE
29 | sty 248 ; Store Hi String Vector Byte
30 | sta 247 ; Store Lo String Vector Byte
31 |
32 | @ABIELooper
33 | ldy #0 ; Initialise Index
34 | lda (247),y ; Get String Character
35 | cmp #0 ; Is it End Of String Byte 0
36 | beq @ABIE_EXIT ; Yes, Exit Function
37 | jsr krljmp_CHROUT$ ; No, Print Character
38 | inc 247 ; Increase Lo By 1
39 | bne @ABIE ; Did I cross Page Boundary
40 | inc 248 ; Yes, Increase Hi Byte By 1
41 |
42 | @ABIE
43 | jmp @ABIELooper ; Loop round for next Character
44 |
45 | @ABIE_EXIT
46 | jmp ready ; Exit back to Command Line
47 |
--------------------------------------------------------------------------------
/libBinaryCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Binary Convertor Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : % (16 bit no.)
5 | ;*******************************************************************************
6 |
7 | ;** binary conv. -- syntax :- % (16 bit no.) **
8 |
9 | COM_BINARY
10 | ldy #0 ; Initialise Storage
11 | sty HT + 1 ; Hi Byte
12 | sty HT ; Lo Byte
13 |
14 | BIN2
15 | jsr krljmp_CHRIN$ ; Get Character From Keyboard Buffer
16 | cmp #CHR_Return ; Is it Return
17 | bne BIN3 ; No, process this character
18 | jmp ERROR ; Yes, Then Display Error
19 |
20 | BIN3
21 | sec ; Set Carry
22 | sbc #"1" ; Subtract ASCII Code "1"
23 | rol HT ; Rotate Left Lo byte
24 | rol HT + 1 ; Rotate Left Hi Byte
25 | iny ; Increase Y
26 | cpy #16 ; Have done this 16 times
27 | bne BIN2 ; No, then process next character
28 | jsr PrintCarrageReturnAndLineFeed
29 | jsr DECPR ; Display Decimal Number
30 | jsr PrintCarrageReturnAndLineFeed
31 | jsr HEXPR ; Display HexaDecimal Number
32 | jsr PrintCarrageReturnAndLineFeed
33 | jsr OCTPR ; Display Octal Number
34 | jmp READY ; Goto Command Line
35 |
36 | ;*******************************************************************************
37 | BINPR
38 | lda #"%"
39 | jsr krljmp_CHROUT$ ; Print Character
40 | lda #CHR_Equals
41 | jsr krljmp_CHROUT$ ; Print Character
42 | jsr SPACE
43 | lda HT ; Load Lo Value
44 | sta ADDVEC ; Store in Lo Address
45 | lda HT + 1 ; Load Hi Value
46 | sta ADDVEC + 1 ; Store In Hi Address
47 | ldy #0 ; Initialise Counter
48 |
49 | BINPR4
50 | asl ADDVEC ; Logical Shift Left into Carry
51 | rol ADDVEC + 1 ; Rotate Left Hi Byte
52 | lda #0 ; Load 0
53 | adc #"0" ; Add Ascii "0" = "0" or "1" (if Carry Set)
54 | jsr krljmp_CHROUT$ ; Print Character
55 | iny ; increase counter
56 | cpy #8 ; 8 times hit
57 | bne BINPR5 ; No, so process next Bit
58 | jsr SPACE
59 |
60 | BINPR5
61 | cpy #16 ; 16 bits hit
62 | bne BINPR4 ; No, Process next Bit
63 | rts
--------------------------------------------------------------------------------
/libCharacterASCIIConst.asm:
--------------------------------------------------------------------------------
1 | ; ---------------------------------------------------------------------
2 | ; - Character ASCII Set Constants
3 | ; - Date 26th November 2016
4 | ; - Created By John C. Dale
5 | ; ---------------------------------------------------------------------
6 |
7 | CHR_White = 5
8 | CHR_DisableCommodoreKey = 8
9 | CHR_EnableCommodoreKey = 9
10 | CHR_Return = 13
11 | CHR_SwitchToLowerCase = 14
12 | CHR_CursorUp = 145
13 | CHR_ReverseOn = 18
14 | CHR_Home = 19
15 | CHR_Overwrite = 20
16 | CHR_Red = 28
17 | CHR_CursorRight = 29
18 | CHR_Green = 30
19 | CHR_Blue = 31
20 | CHR_Space = 32
21 | CHR_ShiftReturn = 141
22 | CHR_SwitchToUpperCase = 142
23 | CHR_Black = 144
24 | CHR_CursorDown = 17
25 | CHR_ReverseOff = 146
26 | CHR_ClearScreen = 147
27 | CHR_Insert = 148
28 | CHR_Purple = 156
29 | CHR_CursorLeft = 157
30 | CHR_Yellow = 158
31 | CHR_Cyan = 159
32 | CHR_ShiftSpace = 160
33 | CHR_Quote = 34
34 | CHR_Equals = 61
35 | CHR_Colon = 58
36 | CHR_Comma = 44
37 | CHR_ExclamationMark = 33
38 | CHR_OpenBracket = 40
39 | CHR_ClosedBracket = 41
40 |
--------------------------------------------------------------------------------
/libCommandCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Command Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : C (opcode)
5 | ;*******************************************************************************
6 |
7 | COM_COMMAND
8 | ldy #0 ; Initialise Index
9 |
10 | @COMMAND1
11 | jsr INPUT_COMMAND ; Get Command Character
12 | sta COM_TEXT,y ; Store into Buffer
13 | iny ; Increase Index
14 | cpy #3 ; Only capture 3 characters
15 | bne @COMMAND1 ; No, not hit 3 yet
16 | jsr PrintCarrageReturnAndLineFeed ; Print Line
17 | lda #OPCodes ; Initialise OpCode Array Hi
20 | sta HT + 1
21 |
22 | COM1
23 | ldy #0 ; Initialise Index
24 |
25 | COM2
26 | lda (HT),y ; Get Character From Array
27 | cmp #0 ; Are we at end Of array
28 | beq COM9 ; Yes, then Jump Out
29 | cmp COM_TEXT,y ; Compare with Buffer Text Item
30 | bcc COM4 ; If less then goto next OpCode
31 | beq COM9 ; If Equal, test next character
32 | jmp READY ; No OpCode Found, Jump to Ready Prompt
33 |
34 | COM9
35 | iny ; Increase Index
36 | cpy #3 ; Have we hit 3 characters
37 | bne COM2 ; Nope, continue testing
38 | lda (HT),y ; Load Mode from array
39 | sta COM_MODE ; Store in Command Mode
40 | jmp COM6 ; Goto Display OpCode Variants
41 |
42 | COM4
43 | clc
44 | lda HT ; Add 5 to OpCode Array for next opcode
45 | adc #5
46 | sta HT
47 | bcc COM10
48 | inc HT + 1
49 |
50 | COM10
51 | jmp COM1 ; Search New Opcode
52 |
53 | COM6
54 | lda COM_MODE ; Load Command Mode
55 | sec
56 | sbc #MODE_IMPLIED ; Subtract First Mode to create index
57 | sta COM_MODE ; Store back into Command Mode
58 | asl ; multiply by 2
59 | tax ; Move to X Index
60 | lda DISASSEMBLE_JUMP_TABLE,x ; Get Lo Byte Jump Location
61 | sta MODE_JUMP_VEC ; Store away
62 | lda DISASSEMBLE_JUMP_TABLE+1,x ; Get Hi Byte Jump Location
63 | sta MODE_JUMP_VEC + 1 ; Store away
64 |
65 | lda #PLACE ; Load Demo Address Location Hi
68 | sta ADDVEC + 1 ; Store In Address Hi
69 | lda HT + 1
70 | sta DIS_END + 1
71 | lda HT
72 | sta DIS_END
73 | ldy #0 ; initialise Index
74 |
75 | COM8
76 | lda COM_TEXT,y ; Load OpCode Character
77 | jsr krljmp_CHROUT$ ; Print Character
78 | iny ; Increase Y
79 | cpy #3 ; Dont Pass 3 characters
80 | bne COM8 ; Go back for next character
81 | jsr SPACE ; Print Space
82 |
83 | COM7
84 | jsr JSRG ; GoSub Jump Vector
85 | sec
86 | jsr krljmp_PLOT$ ; Get Cursor Location
87 | clc
88 | ldy #12 ; Change Y Position to Col 12
89 | jsr krljmp_PLOT$ ; Set New Cursor Location
90 | lda COM_mode ; Load OpCode Mode
91 | asl ; Multiply by 2
92 | tax ; Transfer to X
93 | lda COM_CTXT+1,x ; Load Control Text Vector Hi
94 | tay ; Move To Y
95 | lda COM_CTXT,x ; Load Control Text Vector Lo
96 | jsr bas_PrintString$; Print The String @ Location Y*256+A
97 | jsr PrintCarrageReturnAndLineFeed ; Print Line
98 | lda DIS_END + 1
99 | sta HT + 1
100 | lda DIS_END
101 | sta HT
102 | jmp COM4 ; Is there another Mode to show
103 |
104 | PLACE
105 | WORD $dcba
106 |
107 | COM_CTXT
108 | WORD imp
109 | WORD abs
110 | WORD absx
111 | WORD absy
112 | WORD immi
113 | WORD indi
114 | WORD indx
115 | WORD indy
116 | WORD zer
117 | WORD zerx
118 | WORD zery
119 | WORD rela
120 | IMP
121 | TEXT "implied/accumulator"
122 | brk
123 | ABS
124 | TEXT "absolute"
125 | brk
126 | ABSX
127 | TEXT "absolute,x"
128 | brk
129 | ABSY
130 | TEXT "absolute,y"
131 | brk
132 | IMMI
133 | TEXT "immediate"
134 | brk
135 | INDI
136 | TEXT "indirect"
137 | brk
138 | INDX
139 | TEXT "(indirect,x)"
140 | brk
141 | INDY
142 | TEXT "(indirect),y"
143 | brk
144 | ZER
145 | TEXT "zero-page"
146 | brk
147 | ZERX
148 | TEXT "zero-page,x"
149 | brk
150 | ZERY
151 | TEXT "zero-page,y"
152 | brk
153 | RELA
154 | TEXT "relative"
155 | brk
156 |
--------------------------------------------------------------------------------
/libDecimalCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Decimal Convertor Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : # (number)
5 | ;*******************************************************************************
6 |
7 | ;** decimal conv. -- syntax :- # (number) **
8 |
9 | COM_DECIMAL
10 | jsr bas_InLine$ ; Get 16 Bit Decimal Number from command line
11 | lda #0
12 | ldx #2
13 | sta $7a
14 | stx $7b
15 | jsr bas_FrmNum$ ; Convert from Floating Point Number in FAC1
16 | jsr bas_GetAddr$ ; Get 16 Bit Address from FAC1
17 | jsr PrintCarrageReturnAndLineFeed
18 | jsr HEXPR ; Print Hexadecimal Number
19 | jsr PrintCarrageReturnAndLineFeed
20 | jsr BINPR ; Print Binary Number
21 | jsr PrintCarrageReturnAndLineFeed
22 | jsr OCTPR ; Display Octal Number
23 | jmp READY
24 |
25 | ;*******************************************************************************
26 | DECPR
27 | lda #"#" ; Load Hash
28 | jsr krljmp_CHROUT$ ; Print Character
29 | lda #CHR_Equals ; Load Equals
30 | jsr krljmp_CHROUT$ ; Print Character
31 | jsr SPACE
32 | lda HT + 1 ; Load Hi Value
33 | ldx HT ; Load Lo Value
34 | jmp bas_LinePrint$ ; Print Decimal Number
--------------------------------------------------------------------------------
/libDissassembleCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Disassemble Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : D (addr) (addr)
5 | ;*******************************************************************************
6 |
7 | COM_DISASSEMBLE
8 | jsr IBYTE2 ; Get Start Address Word
9 | sta ADDVEC + 1 ; Store Hi Byte
10 | stx ADDVEC ; Store Lo Byte
11 | jsr IBYTE2 ; Get End Address Word
12 | sta DIS_END + 1 ; Store Hi Byte
13 | stx DIS_END ; Store Lo Byte
14 |
15 | DIS2
16 | jsr DIS1 ; Dissassemble One Line of Code
17 | jsr ADDNB ; Update Memeory Address
18 | lda $c5 ; Listen to Keyboard Map
19 | cmp #63 ; Test for RUN/STOP Key
20 | bne DIS9 ; Not the Key, then continue
21 | jmp READY ; Jump back to Command Line
22 |
23 | DIS9
24 | lda ADDVEC + 1 ; Load Current Memory Address
25 | cmp DIS_END + 1 ; Test if its bigger that END Address
26 | beq DIS10 ; Yes, its the same
27 | jmp DIS2 ; No, Carry on Dissassembling
28 |
29 | DIS10
30 | lda ADDVEC ; Load Current Memory Address
31 | cmp DIS_END ; Test if its Bigger than END Address
32 | bcc DIS2 ; if less than, continue dissassemble
33 | jmp READY ; Goto Comamnd Line
34 |
35 | DIS1
36 | ldy #0 ; initialise index
37 | lda (ADDVEC),y ; Load OpCode from Memory Address
38 | sta COM_P ; Store in Common P Address
39 | jsr modsea ; Get the appropriate mode for this OpCode
40 | jsr PrintCarrageReturnAndLineFeed
41 | lda #">" ; Load Command Line
42 | jsr krljmp_CHROUT$ ; Print Character
43 | jsr Print_Comma ; Print Comma
44 | jsr SPACE
45 | lda ADDVEC ; Load Lo Byte of Address
46 | ldx ADDVEC + 1 ; Load Hi Byte of Address
47 | jsr PBYTE2 ; Print Hexadecimal Word
48 | jsr SPACE
49 | jsr NOBYT ; Update Memory Address for next Line
50 |
51 | DIS3
52 | ldy #0 ; Initialise Index
53 |
54 | @DIS3
55 | lda COM_TEXT,y ; load OpCode Character
56 | jsr krljmp_CHROUT$ ; Print Character
57 | iny ; increase Y
58 | cpy #3 ; OpCode is only 3
59 | bne @DIS3 ; No, then continue printing
60 | jsr SPACE
61 | lda COM_MODE ; Load Mode
62 | sec
63 | sbc #MODE_IMPLIED ; Subtract Initial Mode to get index
64 | asl ; Multiply by 2
65 | tay ; Transfer to Y index
66 | lda DISASSEMBLE_JUMP_TABLE,y ; Get Dissassembly Print Routine
67 | sta HT
68 | lda DISASSEMBLE_JUMP_TABLE+1,y
69 | sta HT + 1
70 | jmp (HTVEC) ; Jump to Dissassembly Print Routine
71 |
72 | MODSEA
73 | lda #OpCodes
76 | sta HT + 1
77 |
78 | DIS4
79 | ldy #4 ; initialise index for OpCode Search
80 |
81 | DIS5
82 | lda (HT),y ; Get OpCode
83 | cmp COM_P ; Is it what we have found
84 | bne dis6 ; No, change vector to next OpCode
85 | dey ; Yes, then decrease index for mode
86 | lda (HT),y ; Load Mode for OpCode
87 | sta COM_MODE ; Store in Command Mode
88 |
89 | DIS7
90 | dey ; Decrease Index
91 | lda (HT),y ; Get OpCode Characters
92 | sta COM_TEXT,y ; Store in Buffer
93 | cpy #255 ; Is Index Ended
94 | bne dis7 ; No, the continue OpCode Instruction Retreival
95 | rts ; Return
96 |
97 | DIS6
98 | ldy #0 ; initialise index
99 | lda (HT),y ; Load Memeory Address Value
100 | beq DIS11 ; Is it Zero, then Error
101 | clc
102 | lda HT ; Update OpCode Search Vector, for next OpCode
103 | adc #5
104 | sta HT
105 | bcc DIS12
106 | inc HT + 1
107 |
108 | DIS12
109 | jmp DIS4 ; Continue OpCode Search
110 |
111 | DIS11
112 | ldy #0 ; Initialise Index
113 |
114 | DIS8
115 | lda #"?" ; Load Error Symbol
116 | sta COM_TEXT,y ; Store in Buffer
117 | iny
118 | cpy #3
119 | bne dis8
120 | lda #MODE_IMPLIED ; Load Implied Mode
121 | sta COM_MODE ; Store in Command Mode
122 | rts
123 |
124 | DISASSEMBLE_JUMP_TABLE
125 | WORD dmoda
126 | WORD dmodb
127 | WORD dmodc
128 | WORD dmodd
129 | WORD dmode
130 | WORD dmodf
131 | WORD dmodg
132 | WORD dmodh
133 | WORD dmodi
134 | WORD dmodj
135 | WORD dmodk
136 | WORD dmodl
137 |
138 | NUM2
139 | ldy #2 ; Set For Hi Byte Index
140 | jsr Print_Dollar ; Print Dollar Sign
141 | lda (ADDVEC),y ; Load Hi Byte Value
142 | tax ; Transfer to X
143 | dey ; Decrease Index
144 | lda (ADDVEC),y ; Load Lo Byte Value
145 | jmp PBYTE2 ; Print Hexadecimal Word
146 |
147 | NUM1
148 | ldy #1 ; Set for Lo Byte Index
149 | jsr Print_Dollar ; Print Dollar Sign
150 | lda (ADDVEC),y ; Load Lo Byte Value
151 | jmp PBYTE1 ; Print Hexadecimal Byte
152 |
153 | Print_Dollar
154 | lda #"$"
155 | BYTE 44
156 |
157 | Print_OpenBracket
158 | lda #CHR_OpenBracket
159 | BYTE 44
160 |
161 | Print_ClosedBracket
162 | lda #CHR_ClosedBracket
163 | BYTE 44
164 |
165 | Print_Comma
166 | lda #CHR_Comma
167 | BYTE 44
168 |
169 | Print_X
170 | lda #"x"
171 | BYTE 44
172 |
173 | Print_Y
174 | lda #"y"
175 | jmp krljmp_CHROUT$ ; Print Character
176 |
177 | DMODA
178 | rts ; Return immediatly
179 |
180 | DMODB
181 | jmp NUM2 ; Print Hexadecimal Word (Absolute Mode)
182 |
183 | DMODC
184 | jsr NUM2 ; Print Hexadecimal Word (Absolute,X Mode)
185 | jsr Print_Comma ; Print Comma
186 | jmp Print_X ; Print X
187 |
188 | DMODD
189 | jsr NUM2 ; Print Hexadecimal Word (Absolute,Y Mode)
190 | jsr Print_Comma ; Print Comma
191 | jmp Print_Y ; Print Y
192 |
193 | DMODE
194 | lda #"#"
195 | jsr krljmp_CHROUT$ ; Print Character
196 | jmp NUM1 ; Print Hexadecimal Byte
197 |
198 | DMODF
199 | jsr Print_OpenBracket ; Print Open Bracket
200 | jsr NUM2 ; Print Hexadecimal Word
201 | jmp Print_ClosedBracket ; Print Closed Bracket
202 |
203 | DMODG
204 | jsr Print_OpenBracket ; Print Open Bracket
205 | jsr NUM1 ; Print Hexadecimal Byte
206 | jsr Print_Comma ; Print Comma
207 | jsr Print_X ; Print X
208 | jmp Print_ClosedBracket ; Print Closed Bracket
209 |
210 | DMODH
211 | jsr Print_OpenBracket ; Print Open Bracket
212 | jsr NUM1 ; Print Hexadecimal Byte
213 | jsr Print_ClosedBracket ; Print Closed Bracket
214 | jsr Print_Comma ; Print Comma
215 | jmp Print_Y ; Print Y
216 |
217 | DMODI
218 | jmp NUM1 ; Print Hexadecimal Byte
219 |
220 | DMODJ
221 | jsr NUM1 ; Print Hexadecimal Byte
222 | jsr Print_Comma ; Print Comma
223 | jmp Print_X ; Print X
224 |
225 | DMODK
226 | jsr NUM1 ; Print Hexadecimal Byte
227 | jsr Print_Comma ; Print Comma
228 | jmp Print_Y ; Print Y
229 |
230 | DMODL
231 | ldy #1
232 | lda (ADDVEC),y ; Load Relative Value
233 | bmi DMODL2 ; Negative Value
234 | clc
235 | adc ADDVEC ; Add Value to Address
236 | sta COM_L
237 | lda ADDVEC + 1
238 | adc #0
239 | sta COM_L + 1
240 | jmp dmodl1 ; Goto Final Workout
241 |
242 | DMODL2
243 | clc
244 | adc ADDVEC ; Sub Value from Address
245 | sta COM_L
246 | lda ADDVEC + 1
247 | sbc #0
248 | sta COM_L + 1
249 |
250 | DMODL1
251 | clc
252 | lda COM_L ; Add Offset to Address
253 | adc #2
254 | sta COM_L
255 | lda COM_L + 1
256 | adc #0
257 | sta COM_L + 1
258 | jsr Print_Dollar ; Print Dollar
259 | ldx COM_L + 1
260 | lda COM_L
261 | jmp PBYTE2 ; Print Hexadecimal Word.
--------------------------------------------------------------------------------
/libErrorCodes.asm:
--------------------------------------------------------------------------------
1 |
2 | ; System Error Codes
3 | ; Kernel System Errors
4 | err_TooManyFiles$ = 1
5 | err_FileOpen$ = 2
6 | err_FileNotOpen$ = 3
7 | err_FileNotFound$ = 4
8 | err_DeviceNotPresent$ = 5
9 | err_NotInputFile$ = 6
10 | err_NotOutputFile$ = 7
11 | err_MissingFileName$ = 8
12 | err_IllegalDeviceNumber$ = 9
13 |
14 | ; BASIC System Errors
15 | err_NextWithoutFor$ = 10
16 | err_Syntax$ = 11
17 | err_ReturnWithoutGosub$ = 12
18 | err_OutOfData$ = 13
19 | err_IllegalQuantity$ = 14
20 | err_Overflow$ = 15
21 | err_OutOfMemory$ = 16
22 | err_UndefdStatement$ = 17
23 | err_BadSubscript$ = 18
24 | err_ReDimedArray$ = 20
25 | err_IllegalDirect$ = 21
26 | err_TypeMismatch$ = 22
27 | err_StringTooLong$ = 23
28 | err_FileData$ = 24
29 | err_FormulaToComplex$ = 25
30 | err_CantContinue$ = 26
31 | err_UndefdFunction$ = 27
32 | err_Verify$ = 28
33 | err_Load$ = 29
34 | err_Break$ = 30
35 |
36 | ; My Custom Error Codes
37 | err_InvalidDeviceNumber$ = 31
38 | err_SaveVerifyMismatch$ = 32
39 | err_DeviceNotReady$ = 33
40 |
--------------------------------------------------------------------------------
/libErrorHandler.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Error Handler *
3 | ;*******************************************************************************
4 | ;* Input Registers : *
5 | ;* X = Error Number *
6 | ;*******************************************************************************
7 |
8 | ErrorHandlerLo = $22
9 | ErrorHandlerHi = $23
10 |
11 | ErrorHandler
12 | txa
13 | pha ; Store Away Error Code
14 | cmp #31
15 | bcc @ROMError ; less than 30
16 | sec
17 | sbc #31 ; Subtract Our Error Code start
18 | asl ; Multiply By Two
19 | tax
20 | lda @ErrorCodes,x
21 | sta ErrorHandlerLo
22 | lda @ErrorCodes + 1,x
23 | sta ErrorHandlerHi
24 | pla ; Retrieve Back Error Code
25 | jmp bas_CustomError$
26 |
27 | @ROMError
28 | pla ; Retrieve Back Error Code
29 | tax
30 | jmp bas_ROMError$
31 |
32 | @ErrorCodes
33 | WORD ERRORCODE_31 ; Error Code 31
34 | WORD ERRORCODE_32 ; Error Code 32
35 | WORD ERRORCODE_33 ; Error Code 33
36 | WORD ERRORCODE_34 ; Error Code 34
37 | WORD ERRORCODE_35 ; Error Code 35
38 | WORD ERRORCODE_36 ; Error Code 36
39 |
40 | ERRORCODE_31
41 | TEXT "invalid device numbeR"
42 |
43 | ERRORCODE_32
44 | TEXT "chain verifying erroR"
45 |
46 | ERRORCODE_33
47 | TEXT "device not readY"
48 |
49 | ERRORCODE_34
50 | TEXT "33 code erroR"
51 |
52 | ERRORCODE_35
53 | TEXT "34 code erroR"
54 |
55 | ERRORCODE_36
56 | TEXT "35 code erroR"
57 |
58 | ;*******************************************************************************
59 | ;* Show Syntax Error *
60 | ;*******************************************************************************
61 | SYNTAX_ERROR
62 | lda #32
63 | sta 129
64 | ldx #11 ; Code for Syntax Error
65 | jmp (jmpvec_Error) ; Display Error Message
66 |
67 |
--------------------------------------------------------------------------------
/libExitCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Exit Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : X
5 | ;*******************************************************************************
6 |
7 | ;** exit -- syntax :- x **
8 | COM_EXIT
9 | jsr bas_LinkProgram$ ; Relink BASIC Program
10 | jmp bas_ReadyPrompt$ ; Jump To Basic READY Prompt
--------------------------------------------------------------------------------
/libFillCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Fill Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : F (addr) (addr) (byte)
5 | ;*******************************************************************************
6 |
7 | COM_FILL
8 | jsr IBYTE2 ; Get Start Address Word
9 | sta ADDVEC + 1
10 | stx ADDVEC
11 | jsr IBYTE2 ; Get End Address Word
12 | sta DIS_END + 1
13 | stx DIS_END
14 | jsr IBYTE1 ; Get Byte
15 | sta TEMP
16 |
17 | FILL1
18 | ldy #0 ; initialise Index
19 | lda TEMP ; Load Byte Value
20 | sta (ADDVEC),y ; Store Value
21 | lda #1 ; Add 1 to Address
22 | sta COM_NB
23 | jsr ADDNB ; Update Address
24 | lda ADDVEC + 1
25 | cmp DIS_END + 1 ; Have we hit the End
26 | beq FILL2 ; Yes
27 | jmp FILL1 ; No, keep going
28 |
29 | FILL2
30 | lda ADDVEC
31 | cmp DIS_END ; Have we deffo hit the end?
32 | bne FILL1 ; No
33 | jmp READY ; Yes
--------------------------------------------------------------------------------
/libGoCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Gosub Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : G (addr)
5 | ;*******************************************************************************
6 |
7 | COM_GOSUB
8 | jsr INPUT_COMMAND ; get command line character
9 | cmp #CHR_Return ; is it return
10 | beq GO3 ; Yes
11 | jsr ibyte1+3 ; get address word
12 | jsr ibyte2+3
13 | sta ADDVEC + 1 ; Store in Address Vector
14 | stx ADDVEC
15 | jmp GO_STACK_ADDRESS
16 |
17 | GO3
18 | ldy #0
19 | lda (ADDVEC),y ; load Address value
20 | cmp #0 ; is it a break BRK instruction
21 | bne GO_STACK_ADDRESS ; No, Continue the command
22 |
23 | PREPARE_TO_GO
24 | lda PCHIREG ; Load PC Counter with Address
25 | pha ; Store it on the stack
26 | lda PCLOREG
27 | pha
28 | sei ; Set Interrupts
29 | lda IRQINT
30 | ldx IRQINT + 1
31 | sta CINV ; Reset IRQ back to brk values
32 | stx CINV + 1
33 | lda NMIINT ; Reset NMI back to BRK Values
34 | ldx NMIINT + 1
35 | sta NMINV
36 | stx NMINV + 1
37 | cli ; Clear Interrupts
38 | lda ACCREG ; Load Registers
39 | ldx XREG
40 | ldy YREG
41 | rts ; Return to Stack Address
42 |
43 | GO_STACK_ADDRESS
44 | sec
45 | lda ADDVEC ; Load Address
46 | sbc #1 ; Minus 1 as rts is always Address -1
47 | sta PCLOREG ; Store Back
48 | lda ADDVEC + 1
49 | sbc #0
50 | sta PCHIREG
51 | jmp PREPARE_TO_GO
--------------------------------------------------------------------------------
/libHelpCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Help Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : ?
5 | ;*******************************************************************************
6 |
7 | ;COM_HELP
8 | ; lda #HELPTEXT
10 | ; jsr bas_PrintString$
11 | ; jmp READY
12 |
13 | ;HELPTEXT
14 | ; BYTE CHR_Return
15 | ; TEXT "assemble : a (addr) (opcode) (operand)", CHR_Return
16 | ; TEXT "command : c (opcode)", CHR_Return
17 | ; TEXT "disassemble : d (addr) (addr)", CHR_Return
18 | ; TEXT "fill : f (addr) (addr) (value)", CHR_Return
19 | ; TEXT "go : g or g (addr)", CHR_Return
20 | ; TEXT "hunt : h (addr) (addr) (data) [up to 11 pieces of data or 25 characters]", CHR_Return
21 | ; TEXT "interpret : i (addr) (addr)", CHR_Return
22 | ; TEXT "load : l ", 34, "filename", 34, " (dev)", CHR_Return
23 | ; TEXT "memory : m (addr) (addr)", CHR_Return
24 | ; TEXT "output : o (y or n)", CHR_Return
25 | ; TEXT "register : r", CHR_Return
26 | ; TEXT "save : s ", 34, "filename", 34, " (dev) (addr) (addr)", CHR_Return
27 | ; TEXT "transfer : t (addr) (addr) (addr)", CHR_Return
28 | ; TEXT "exit : x", CHR_Return
29 | ; TEXT "decimal convertor : # (no.) (range 0 – 65535)", CHR_Return
30 | ; TEXT "hexadecimal convertor : $ (addr) (range 0000 – FFFF)", CHR_Return
31 | ; TEXT "binary convertor : % (16 bit no.) (two sets of eight)", CHR_Return
32 | ; TEXT "octal convertor : @ (6 octal chars) (range 000000-188888)", CHR_Return
33 | ; BRK
--------------------------------------------------------------------------------
/libHexadecimalCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Hexadecimal Convertor Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : $ (addr)
5 | ;*******************************************************************************
6 |
7 | ;** hex conv. -- syntax :- $ (addr) **
8 |
9 | COM_HEXDEC
10 | jsr IBYTE2 ; Get Word Value
11 | sta HT + 1 ; Store Value
12 | stx HT
13 | jsr PrintCarrageReturnAndLineFeed
14 | jsr DECPR ; Print Decimal Conversion
15 | jsr PrintCarrageReturnAndLineFeed
16 | jsr BINPR ; Print Binanry Conversion
17 | jsr PrintCarrageReturnAndLineFeed
18 | jsr OCTPR ; Print Octal Conversion
19 | jmp READY ; Back To Command Line
20 |
21 | ;*******************************************************************************
22 | HEXPR
23 | jsr Print_Dollar ; Prints Dollar Sign
24 | lda #CHR_Equals
25 | jsr krljmp_CHROUT$ ; Prints Equals Sign
26 | jsr SPACE
27 | lda HT
28 | ldx HT + 1
29 | jmp PBYTE2 ; Print Hex Word Value
30 |
--------------------------------------------------------------------------------
/libHuntCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Hunt Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : H (addr) (addr) (text)
5 | ;*******************************************************************************
6 |
7 | COM_HUNT
8 | jsr IBYTE2 ; Get Start Address
9 | sta ADDVEC + 1 ; Store Start Address
10 | stx ADDVEC
11 | jsr IBYTE2 ; Get End Address
12 | sta DIS_END + 1 ; Store End Address
13 | stx DIS_END
14 | ldy #0 ; Initialise String Index
15 | sty COM_L
16 | jsr INPUT_COMMAND ; Get NExt Command Character
17 | cmp #CHR_Quote ; Is it Quotes
18 | beq HUN2 ; Yes, then goto ASCII Search
19 | bne HUN7 ; No, goto byte search
20 |
21 | HUN3
22 | jsr INPUT_COMMAND ; Get Next Command Character
23 | cmp #CHR_Return ; Is it Return
24 | beq HUN4 ; Yes, goto Searching
25 |
26 | HUN7
27 | jsr IBYTE1+3 ; Get Byte Data To Search On
28 | sta COM_TEXT,y ; Store in Buffer
29 | inc COM_L ; increase number of byte counter
30 | ldy COM_L ; load byte counter
31 | ;iny
32 | ;sty COM_L
33 | cpy #11 ; 11 characters
34 | beq HUN8 ; Yes, then error
35 | jmp HUN3 ; No, then get next character
36 |
37 | HUN8
38 | jmp ERROR ; Error
39 |
40 | HUN2
41 | jsr krljmp_CHRIN$ ; Get next ASCII Character
42 | cmp #CHR_Return ; Is it Return
43 | beq HUN4 ; Yes, then start Searching
44 | sta COM_TEXT,y ; Store in buffer
45 | inc COM_L ; increase number of characters
46 | ldy COM_L ; load number of characters
47 | ;iny
48 | ;sty COM_L
49 | cpy #20 ; 20 ?
50 | beq HUN9 ; Yes, goto Error
51 | jmp HUN2 ; Get next character
52 |
53 | HUN9
54 | jmp ERROR ; Error
55 |
56 | HUN4
57 | sty COM_L ; store number of bytes
58 | jsr PrintCarrageReturnAndLineFeed
59 |
60 | HUN5
61 | ldy #0 ; initialise index
62 | HUN13
63 | lda (ADDVEC),y ; load value from memory
64 | cmp COM_TEXT,y ; compare with buffer
65 | beq HUN10 ; its the same, try the next character
66 | lda #1 ; No, set add nb to 1
67 | sta COM_NB ; store it
68 | jsr ADDNB ; increase Address with NB value
69 | jmp HUN6 ; Goto Test to see if we hit the end
70 |
71 | HUN10
72 | iny ; increase index
73 | cpy COM_L ; the same as the buffer
74 | bne HUN13 ; No, continue testing
75 | lda ADDVEC ; Yup, found the string, load addesss
76 | ldx ADDVEC + 1
77 | jsr PBYTE2 ; Print Address where string found
78 | jsr SPACE
79 | lda COM_L ; load string length
80 | sta COM_NB ; store in nb for add
81 | jsr ADDNB ; add to address vectors
82 |
83 | HUN6
84 | lda ADDVEC + 1 ; load addess hi
85 | cmp DIS_END + 1 ; is it the same as end address hi
86 | beq HUN11 ; Yes, better test lo byte
87 | jmp HUN5 ; No, carry on searching
88 |
89 | HUN11
90 | lda ADDVEC ; load address lo
91 | cmp DIS_END ; test end address lo
92 | bcs HUN12 ; greater then, then finish
93 | jmp HUN5 ; less than, carry on searching
94 |
95 | HUN12
96 | jmp READY ; Back to Command Line
97 |
--------------------------------------------------------------------------------
/libInterpretCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Interpret Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : I (addr) (addr)
5 | ;*******************************************************************************
6 |
7 | COM_INTERP
8 | jsr IBYTE2 ; get start address
9 | sta ADDVEC + 1 ; store start address
10 | stx ADDVEC
11 | jsr IBYTE2 ; get end address
12 | sta DIS_END + 1 ; store end address
13 | stx DIS_END
14 |
15 | INT10
16 | jsr INT1 ; display one line of memory
17 |
18 | ifdef TGT_C64
19 | lda #31
20 | endif
21 | ifdef TGT_VIC20_8K
22 | lda #13
23 | endif
24 |
25 | sta COM_NB ; add nb to address
26 | lda $c5 ; get current key mapping
27 | cmp #63 ; is it runstop
28 | bne INT3 ; carry on displaying next line
29 | jmp READY ; goto command line
30 |
31 | INT3
32 | jsr ADDNB ; update address
33 | lda ADDVEC + 1 ; load address hi
34 | cmp DIS_END + 1 ; compare with end address hi
35 | beq INT4 ; if equal test lo byte
36 | jmp INT10 ; display next line
37 |
38 | INT4
39 | lda ADDVEC ; load address lo
40 | cmp DIS_END ; compare with end address lo
41 | bcs INT9 ; greater then,
42 | jmp INT10 ; display next line
43 |
44 | INT9
45 | jmp READY ; jump to command line
46 |
47 | INT1
48 | jsr PrintCarrageReturnAndLineFeed
49 | lda #">"
50 | jsr krljmp_CHROUT$
51 | lda ADDVEC ; load address
52 | ldx ADDVEC + 1
53 | jsr PBYTE2 ; print hexadecimal address
54 | jsr SPACE
55 | lda #CHR_Quote
56 | jsr krljmp_CHROUT$ ; print character
57 | jsr SPACE
58 | ldy #0
59 |
60 | INT2
61 | lda (ADDVEC),y ; load address value
62 | jsr ShowOnlyValidCharacters ; filter out bad characters
63 | jsr krljmp_CHROUT$ ; print character
64 | iny
65 |
66 | ifdef TGT_C64
67 | cpy #31 ; 31 characters reached
68 | endif
69 |
70 | ifdef TGT_VIC20_8K
71 | cpy #13 ; 13 characters reached
72 | endif
73 |
74 | bne INT2 ; no, carry on
75 | rts ; return
76 |
77 | ShowOnlyValidCharacters
78 | cmp #224
79 | bcs int6 ; Branch if greater than, to show invalid character ( >= 224)
80 | cmp #160
81 | bcs int7 ; Branch if greater than, to show valid character ( >= 160 and < 224)
82 | cmp #91
83 | bcs int6 ; Branch if greater than, to show invalid character ( >=91 and < 160)
84 | cmp #34
85 | beq int6 ; Branch if equal to, then show invalid character
86 | cmp #32
87 | bcs int7 ; Branch if Grater than, then show valid character ( >=32 and < 91 and <> 34)
88 |
89 | INT6
90 | lda #46 ; Invalid Character
91 |
92 | INT7
93 | rts
--------------------------------------------------------------------------------
/libLoadCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Load Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : L "(filename)" (dev)
5 | ;*******************************************************************************
6 |
7 | ;** load -- syntax :- l (filename) (dev) **
8 |
9 | COM_LOAD
10 | jsr krljmp_CHRIN$ ; get character
11 | ldy #0 ; initialise index
12 |
13 | LO1
14 | jsr krljmp_CHRIN$ ; get character
15 | cmp #CHR_Quote ; Is it a Quote
16 | beq LO2 ; yes, the goto load routine
17 | sta COM_TEXT,y ; store this character in filename buffer
18 | iny ; increase index
19 | cpy #16 ; 16 characters
20 | bne LO1 ; no, keep getting filename characters
21 | jmp ERROR ; yes, display error
22 |
23 | LO2
24 | sty COM_L ; store length of filename
25 | jsr IBYTE1 ; get hexadecimal byte (device)
26 | tax ; transfer into X for SETLFS routine
27 | ldy #1 ; Load Secondary Command
28 | lda #1 ; Load logical file number #1
29 | jsr krljmp_SETLFS$ ; Set up the LFS
30 | jsr PrintCarrageReturnAndLineFeed
31 | lda COM_L ; Load filename length
32 | ldx #COM_TEXT
34 | jsr krljmp_SETNAM$ ; Set filename for logical file number
35 | lda #0 ; Set for load
36 | jsr krljmp_LOAD$ ; Perform Load
37 | jmp READY ; back to command line
--------------------------------------------------------------------------------
/libMemoryCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Memory Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : M (addr) (addr)
5 | ;*******************************************************************************
6 |
7 | ;** memory -- syntax :- m (addr) (addr) **
8 |
9 | COM_MEMORY
10 | jsr IBYTE2 ; Get start Address
11 | sta ADDVEC + 1
12 | stx ADDVEC
13 | jsr IBYTE2 ; Get End Address
14 | sta DIS_END + 1
15 | stx DIS_END
16 |
17 | MEMNEXTLINE
18 | jsr DISPLAYMEMNEXTLINE ; Display Next Line
19 |
20 | ifdef TGT_C64
21 | lda #10 ; Show 10 bytes per line
22 | endif
23 | ifdef TGT_VIC20_8K
24 | lda #04 ; Show 4 bytes per line
25 | endif
26 |
27 | sta COM_NB ; Store Screen Row Byte Value
28 | lda $c5
29 | cmp #63 ; Check for runstop key
30 | bne MEM1 ; No, carry on
31 | jmp READY ; Yes, Jump back to Command Line
32 |
33 | MEM1
34 | jsr ADDNB ; Add Screen Row Byte Value to Master Location
35 | lda ADDVEC + 1
36 | cmp DIS_END + 1 ; Check if reached End location
37 | bne MEMNEXTLINE ; No, then start new line
38 | lda ADDVEC
39 | cmp DIS_END ; Deffo Check End location
40 | bcs MEM4 ; Yes, Then exit back to command line
41 | jmp MEMNEXTLINE ; No, then start new line
42 |
43 | MEM4
44 | jmp READY ; Jump back to Command Line
45 |
46 | ; Display Memory Line on the screen
47 | DISPLAYMEMNEXTLINE
48 | jsr BUILDMEMLINECOMMANDSTRUCTURE
49 | ldy #0
50 |
51 | DISPLAYMEMNEXTBYTE
52 | lda (ADDVEC),y ; Load Byte
53 | pha ; Temp store on stack
54 | jsr SPACE ; Display Space
55 | pla ; bring back from stack
56 | jsr PBYTE1 ; Display Byte as 00 Hex value
57 | iny ; increase row byte number
58 |
59 | ifdef TGT_C64
60 | cpy #10 ; Check 10 bytes per line
61 | endif
62 | ifdef TGT_VIC20_8K
63 | cpy #04 ; Check 4 bytes per line
64 | endif
65 |
66 | bne DISPLAYMEMNEXTBYTE
67 | rts
68 |
69 | ; This Builds the command line Memory structure (>: 0000)
70 | BUILDMEMLINECOMMANDSTRUCTURE
71 | jsr PrintCarrageReturnAndLineFeed
72 | lda #">"
73 | jsr krljmp_CHROUT$
74 | lda #CHR_Colon
75 | jsr krljmp_CHROUT$
76 | jsr SPACE
77 | lda ADDVEC
78 | ldx ADDVEC + 1
79 | jsr PBYTE2
80 | rts
81 |
82 | ;*******************************************************************************
83 | ;* Memory Put ation *
84 | ;*******************************************************************************
85 | ;* Syntax 64 : : (addr) (byte)(byte)(byte)(byte)(byte)(byte)(byte)(byte)(byte)(byte)
86 | ;* Syntax VIC20 : : (addr) (byte)(byte)(byte)(byte)
87 | ;*******************************************************************************
88 |
89 | COM_MEMORYPUT
90 | jsr IBYTE2 ; Get Memory Address
91 | sta ADDVEC + 1 ; Store Memory Address
92 | stx ADDVEC
93 |
94 | MEMP2
95 | ldy #0
96 | sty COM_L ; Begin Byte Counter at 0
97 |
98 | MEMP1
99 | jsr INPUT_COMMAND ; Get First Character
100 | cmp #CHR_Return ; Do we have a Return Key?
101 | bne MEMP3 ; No, then Continue
102 | jmp READY ; Yes, Go back to Command Line
103 |
104 | MEMP3
105 | jsr IBYTE1 + 3 ; Get Current Byte Value
106 | ldy COM_L ; Load Row Byte Value
107 | sta (ADDVEC),y ; Store byte Value in Address + offset
108 | iny ; Increase Row Byte Value
109 | sty COM_L
110 |
111 | ifdef TGT_C64
112 | cpy #10 ; Check 10 bytes per line
113 | endif
114 | ifdef TGT_VIC20_8K
115 | cpy #04 ; Check 4 bytes per line
116 | endif
117 |
118 | bne MEMP1 ; No, Carry On Then
119 |
120 | ifdef TGT_C64
121 | lda #10 ; Show 10 bytes per line
122 | endif
123 | ifdef TGT_VIC20_8K
124 | lda #04 ; Show 4 bytes per line
125 | endif
126 |
127 | sta COM_NB ; Store Bytes Per Line Allowed
128 | jsr ADDNB ; Work Out New Address Location based on byte per line
129 | jsr BUILDMEMLINECOMMANDSTRUCTURE
130 | jmp ASSLINE
131 |
--------------------------------------------------------------------------------
/libOSKRoutines.asm:
--------------------------------------------------------------------------------
1 | ;******************************************************************************
2 | ;* Output a space *
3 | ;******************************************************************************
4 | ;* Outputs : *
5 | ;* None *
6 | ;******************************************************************************
7 | SPACE
8 | lda #CHR_Space ; Load Space
9 | jmp krljmp_CHROUT$ ; Print Space
10 |
11 | ;******************************************************************************
12 | ;* Print Two Bytes In HEX (PBYTE2) *
13 | ;******************************************************************************
14 | ;* Inputs : *
15 | ;* Acc = Hi Byte *
16 | ;* X Reg = Lo Byte *
17 | ;******************************************************************************
18 |
19 | PBYTE2
20 | pha ; Push Hi byte to stack temporarily
21 | txa ; Transfer Lo byte to accumulator
22 | jsr PBYTE1 ; Print out Lo byte first
23 | pla ; Get back Hi byte from stack and print that
24 |
25 | ;******************************************************************************
26 | ;* Print Byte In HEX (PBYTE1) *
27 | ;******************************************************************************
28 | ;* Inputs : *
29 | ;* Acc = Byte *
30 | ;******************************************************************************
31 |
32 | PBYTE1
33 | pha ; Push Byte to stack temporarily
34 | lsr ; divide by 2
35 | lsr ; divide by 4
36 | lsr ; divide by 8
37 | lsr ; divide by 16
38 | jsr PBYTE ; print most siginificant nibble value (most significant 4 bits)
39 | tax ; transfor Acc to X
40 | pla ; get back orginal value from stack
41 | and #15 ; mask out only least significant nibble (4 bits) and print that
42 |
43 | PBYTE
44 | clc
45 | adc #$F6 ; check if greater than 10
46 | bcc @PBYTE ; if carry is clear
47 | adc #6 ; addes the Ascii code 'A' offset
48 | @PBYTE
49 | adc #$3A ; add ascii code '0' value
50 | jmp krljmp_CHROUT$ ; print out accumulator
51 |
52 | ;******************************************************************************
53 | ;* Inputs Two Bytes In HEX (IBYTE2) *
54 | ;******************************************************************************
55 | ;* Outputs : *
56 | ;* Acc = Hi Byte *
57 | ;* X Reg = Lo Byte *
58 | ;******************************************************************************
59 |
60 | IBYTE2
61 | jsr IBYTE1 ; gets Hi Byte
62 | pha ; store away temporarily
63 | jsr IBYTE1 ; gets Lo Byte
64 | tax ; move to X
65 | pla ; get back Hi Byte
66 | rts
67 |
68 | ;******************************************************************************
69 | ;* Input Byte In HEX (IBYTE1) *
70 | ;******************************************************************************
71 | ;* Outputs : *
72 | ;* Acc = Byte *
73 | ;******************************************************************************
74 |
75 | IBYTE1
76 | jsr INPUT_COMMAND ; get character
77 | cmp #CHR_Return ; is it 'Return'?
78 | bne @IBYTE1 ; No
79 | jmp ERROR ; Yes, jump to Error
80 |
81 | @IBYTE1
82 | jsr IBYTE ; Get Most Significant nibble (4 Bits)
83 | asl ; Multiply by 2
84 | asl ; Multiply by 4
85 | asl ; Multiply by 8
86 | asl ; Multiply by 16
87 | sta TEMP ; Store in Temp Byte
88 | jsr INPUT_COMMAND ; Get Next Character
89 | cmp #CHR_Return ; is it 'Return'?
90 | bne @IBYTE2 ; No
91 | jmp ERROR ; Yes, jump to error
92 |
93 | @IBYTE2
94 | jsr IBYTE ; Get Least Siginificant nibble (4 bits)
95 | ora TEMP ; Merge with what we have already got
96 | rts ; Return complete inputted byte value
97 |
98 | IBYTE
99 | clc
100 | adc #$D0 ; Normalise Number
101 | cmp #10 ; Test for 10
102 | bcc @IBYTE ; Is lower than
103 | sec
104 | sbc #7 ; Relign number
105 | @IBYTE
106 | rts
107 |
108 | ;******************************************************************************
109 | ;* Show Error prompt *
110 | ;******************************************************************************
111 | ;* Outputs : *
112 | ;* None *
113 | ;******************************************************************************
114 | ERROR
115 | lda #"?"
116 | jsr krljmp_CHROUT$ ; Print Out Character
117 |
118 | ;******************************************************************************
119 | ;* Show Ready prompt *
120 | ;******************************************************************************
121 | ;* Outputs : *
122 | ;* None *
123 | ;******************************************************************************
124 | READY
125 | jsr PrintCarrageReturnAndLineFeed
126 |
127 | READY1
128 | lda #">"
129 | jsr krljmp_CHROUT$ ; Print out Character
130 | jmp TOKANISER_COMMAND ; Jump back to Command Line
131 |
132 | ;******************************************************************************
133 | ;* Input Command from command line *
134 | ;******************************************************************************
135 | ;* Outputs : *
136 | ;* Acc = Command *
137 | ;******************************************************************************
138 | INPUT_COMMAND
139 | jsr krljmp_CHRIN$ ; Get Command
140 | cmp #CHR_Return ; Check for 'Enter'
141 | beq @INPUT ; Yes, finish input reading
142 | cmp #CHR_Space
143 | beq INPUT_COMMAND ; Is Space, then ignore and get next character
144 | ;cmp #"!" ; check for '!'
145 | ;bcc INPUT_COMMAND ; go back and fetch next command
146 | ;cmp #"[" ; check for '['
147 | ;bcs INPUT_COMMAND ; go back and fetch next command
148 | @INPUT
149 | rts
150 |
151 | ;******************************************************************************
152 | ;* Get 2 Byte Hex Value from Assembly Temp Text Store *
153 | ;******************************************************************************
154 | ;* Inputs : *
155 | ;* Y Reg = Starting Index in COM_TEXT *
156 | ;* Outputs : *
157 | ;* Acc = Hi Byte *
158 | ;* X Reg = Lo Byte *
159 | ;******************************************************************************
160 | GET_HEX_2BYTE_VALUE
161 | jsr GET_HEX_1BYTE_VALUE ; Get 2 digit hex value
162 | pha ; Store result on Stack
163 | iny ; Increase character position value
164 | jsr GET_HEX_1BYTE_VALUE ; Get 2 digit hex value
165 | tax ; move that to X
166 | pla ; get back value from stact
167 | rts
168 |
169 | ;******************************************************************************
170 | ;* Get 1 Byte Hex Value from Assembly Temp Text Store *
171 | ;******************************************************************************
172 | ;* Inputs : *
173 | ;* Y Reg = Starting Index in COM_TEXT *
174 | ;* Outputs : *
175 | ;* Acc = Byte *
176 | ;******************************************************************************
177 | GET_HEX_1BYTE_VALUE
178 | lda COM_TEXT - 1,y ; Get 1 digit from keyboard buffer
179 | jsr IBYTE ; Run through hex convertor
180 | asl ; x 2
181 | asl ; x 4
182 | asl ; x 8
183 | asl ; x 16
184 | sta TEMP ; Store Result away Temporarily
185 | iny ; increase character position index
186 | lda COM_TEXT - 1,y ; get next character
187 | jsr IBYTE ; Run through hex convertor
188 | ora TEMP ; OR result with previous value
189 | rts
190 |
191 | ;******************************************************************************
192 | ;* NoByt *
193 | ;* This determines how many bytes to add for next instruction based on *
194 | ;* mode. *
195 | ;******************************************************************************
196 | ;* Inputs : *
197 | ;* Outputs : *
198 | ;******************************************************************************
199 | NOBYT
200 | lda #2 ; Default to 2 bytes
201 | sta COM_NB ; Store in Command NoBytes
202 | lda COM_MODE ; Load Mode
203 | cmp #MODE_ABSOLUTE ; is it Absolute
204 | bne NOB2 ; No, try another mode
205 | jmp NOB1 ; Yes, then jump to absolute
206 |
207 | NOB2
208 | cmp #MODE_ABSOLUTE_X; is it Absolute,x
209 | bne NOB3 ; No, try another mode
210 | jmp NOB1 ; jump to absolute
211 |
212 | NOB3
213 | cmp #MODE_ABSOLUTE_Y; is it Absolute,y
214 | bne NOB4 ; No, try another mode
215 | jmp NOB1 ; Jump to Absolute mode
216 |
217 | NOB4
218 | cmp #MODE_INDIRECT ; is it Indirect
219 | bne NOB5 ; No, try another mode
220 |
221 | NOB1
222 | lda #3 ; 3 byte opCodes
223 | sta COM_NB ; Store in Command NoBytes
224 |
225 | NOB5
226 | lda COM_MODE ; Load Mode
227 | cmp #MODE_IMPLIED ; Is it implied
228 | bne NOB6 ; No, Jump out of routine
229 | lda #1 ; Yes, then ist only 1 byte
230 | sta COM_NB ; Store in Command NoBytes
231 |
232 | NOB6
233 | rts
234 |
235 | ;******************************************************************************
236 | ;* Tokanise the command aquired from command line *
237 | ;******************************************************************************
238 | ;* Outputs : *
239 | ;* Y = Command Index *
240 | ;******************************************************************************
241 | TOKANISER_COMMAND
242 | jsr INPUT_COMMAND ; Get Command
243 | cmp #CHR_Return ; Check For 'Return'
244 | beq READY ; Goto Ready Sign
245 | ldy #0 ; Reset Comamnd Counter
246 | TOK1
247 | cmp COMMANDS,y ; Compare with command list
248 | beq TOK2 ; identified the command
249 | iny ; No match, so check next one
250 | cpy #COMMANDPOINTERS - COMMANDS ; Number Of Commands
251 | bne TOK1 ; keep trying
252 | jmp ERROR ; no command found, so error
253 |
254 | TOK2
255 | tya ; Command found
256 | asl ; multply by 2
257 | tay ; move to index offset
258 | lda COMMANDPOINTERS,y ; load command pointer lo
259 | sta HT
260 | lda COMMANDPOINTERS+1,y ; load command pointer hi
261 | sta HT + 1
262 | jmp (HTVEC) ; jump to the command
263 |
264 | ;******************************************************************************
265 | PrintCarrageReturnAndLineFeed
266 | lda #CHR_Return
267 | jmp krljmp_CHROUT$
268 |
269 | ;******************************************************************************
270 | ;* ADDNB *
271 | ;* Add Com_NB to AddVec *
272 | ;******************************************************************************
273 | ;* Inputs : Com_NB : No of bytes to add *
274 | ;* : AddVec : The Vector to Add Com_NB too *
275 | ;* Outputs : AddVec : The resulting Vector *
276 | ;******************************************************************************
277 | ADDNB
278 | lda ADDVEC
279 | clc
280 | adc COM_NB
281 | sta ADDVEC
282 | bcc @ADDNB
283 | inc ADDVEC + 1
284 |
285 | @ADDNB
286 | rts
287 |
288 | COMMANDS
289 | TEXT ">racdfghilmostx"
290 | BYTE $3A, $3B, $2C, $23, $24, $25, $40;, $3F
291 | BYTE $00
292 |
293 | COMMANDPOINTERS
294 | WORD TOKANISER_COMMAND
295 | WORD COM_REGISTER
296 | WORD COM_ASSEMBLE
297 | WORD COM_COMMAND
298 | WORD COM_DISASSEMBLE
299 | WORD COM_FILL
300 | WORD COM_GOSUB
301 | WORD COM_HUNT
302 | WORD COM_INTERP
303 | WORD COM_LOAD
304 | WORD COM_MEMORY
305 | WORD COM_OUTPUT
306 | WORD COM_SAVE
307 | WORD COM_TRANSFER
308 | WORD COM_EXIT
309 | WORD COM_MEMORYPUT
310 | WORD COM_REGISTERPUT
311 | WORD COM_ASSEMBLE
312 | WORD COM_DECIMAL
313 | WORD COM_HEXDEC
314 | WORD COM_BINARY
315 | WORD COM_OCTAL
316 | ;WORD COM_HELP
317 |
--------------------------------------------------------------------------------
/libOctalCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Octal Convertor Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : @ (5 bit no.)
5 | ;*******************************************************************************
6 |
7 | ;** octal conv. -- syntax :- @ (5 bit no.) **
8 |
9 | COM_OCTAL
10 | ldy #0 ; initalise Number
11 | sty HT + 1
12 | sty HT
13 |
14 | OCTAL1
15 | jsr krljmp_CHRIN$ ; Get Character
16 | cmp #CHR_Return ; Is it Return
17 | bne OCTAL2 ; No, then Continue
18 | jmp ERROR ; Yes, Jump to ERROR
19 |
20 | OCTAL2
21 | sec
22 | sbc #"0" ; Subtract "0" from character value leaving just values 1 or 0
23 | lsr ; Logically shift it to carry bit
24 | rol HT ; Rol carry into Number Byte
25 | rol HT + 1
26 |
27 | OCTAL3
28 | ldx #0 ; Initialise Caracter Index
29 |
30 | OCTAL4
31 | jsr krljmp_CHRIN$ ; Get next Character
32 | cmp #CHR_Return ; Is it Return
33 | bne OCTAL5 ; No, then carry on
34 | jmp ERROR ; Yes, then Jump to ERROR
35 |
36 | OCTAL5
37 | sec
38 | sbc #"0" ; Subtract "0" from character value leaving just values 7 -> 0
39 | ror ; Divide by 2
40 | ror ; Divide by 4
41 | ror ; Divide by 8
42 | ror ; rol this bit into carry bit
43 | OCTAL6
44 | rol ; rol the carry into the byte
45 | rol HT
46 | rol HT + 1
47 | inx ; increase character index
48 | cpx #3 ; Check for 4th bit move
49 | bne OCTAL6 ; No, then we are ok to continue
50 | iny ; Yes, increase chacter counter
51 | cpy #5 ; Total of 5 characters
52 | bne OCTAL3 ; No, lets carry on then
53 | ; Yes, then print the results
54 | jsr PrintCarrageReturnAndLineFeed
55 | jsr DECPR ; Print Decimal Number
56 | jsr PrintCarrageReturnAndLineFeed
57 | jsr HEXPR ; Print Hex Number
58 | jsr PrintCarrageReturnAndLineFeed
59 | jsr BINPR ; Print Binary Number
60 | jmp READY
61 |
62 | ;*******************************************************************************
63 | OCTPR
64 | lda #"@"
65 | jsr krljmp_CHROUT$ ; Print Character
66 | lda #61
67 | jsr krljmp_CHROUT$ ; Print Character
68 | jsr SPACE
69 | lda HT ; Load Lo value
70 | sta ADDVEC ; Store Lo Address
71 | lda HT + 1 ; Load Hi Value
72 | sta ADDVEC + 1 ; Store Hi Address
73 |
74 | lda #0 ; Work out fifth Digit
75 | asl ADDVEC
76 | rol ADDVEC + 1
77 | adc #"0"
78 | jsr krljmp_CHROUT$ ; Print '0' -> '7'
79 | ldy #0
80 |
81 | OCTPR1
82 | lda #0
83 | asl ADDVEC ; Mult by 2
84 | rol ADDVEC + 1
85 | rol
86 | asl ADDVEC ; Mult by 4
87 | rol ADDVEC + 1
88 | rol
89 | asl ADDVEC ; Mult by 8
90 | rol ADDVEC + 1
91 | rol ; this should now have 3 bits in
92 | adc #"0"
93 | jsr krljmp_CHROUT$ ; Print '0' -> '7'
94 | iny ; increase character counter
95 | cpy #5 ; At fifth character
96 | bne OCTPR1 ; no, then Carry On
97 | rts ; Yes
98 |
99 |
--------------------------------------------------------------------------------
/libOpCodesArray.asm:
--------------------------------------------------------------------------------
1 | ; Mode Key
2 | ; 'a' = implied
3 | ; 'b' = absolute
4 | ; 'c' = absolute,x
5 | ; 'd' = absolute,y
6 | ; 'e' = #immediate
7 | ; 'f' = (indirect)
8 | ; 'g' = (indirect,x)
9 | ; 'h' = (indirect),y
10 | ; 'i' = zeropage
11 | ; 'j' = zeropage,x
12 | ; 'k' = zeropage,y
13 | ; 'l' = relative
14 | ; 'm' = error mode
15 |
16 | MODE_IMPLIED = $41
17 | MODE_ABSOLUTE = $42
18 | MODE_ABSOLUTE_X = $43
19 | MODE_ABSOLUTE_Y = $44
20 | MODE_IMMEDIATE = $45
21 | MODE_INDIRECT = $46
22 | MODE_INDIRECT_X = $47
23 | MODE_INDIRECT_Y = $48
24 | MODE_ZEROPAGE = $49
25 | MODE_ZEROPAGE_X = $4A
26 | MODE_ZEROPAGE_Y = $4B
27 | MODE_RELATIVE = $4C
28 | MODE_ERROR = $4D
29 |
30 | OPCodes
31 | TEXT "adcb"
32 | BYTE 109
33 | TEXT "adcc"
34 | BYTE 125
35 | TEXT "adcd"
36 | BYTE 121
37 | TEXT "adce"
38 | BYTE 105
39 | TEXT "adcg"
40 | BYTE 97
41 | TEXT "adch"
42 | BYTE 113
43 | TEXT "adci"
44 | BYTE 101
45 | TEXT "adcj"
46 | BYTE 117
47 | TEXT "andb"
48 | BYTE 45
49 | TEXT "andc"
50 | BYTE 61
51 | TEXT "andd"
52 | BYTE 57
53 | TEXT "ande"
54 | BYTE 41
55 | TEXT "andg"
56 | BYTE 33
57 | TEXT "andh"
58 | BYTE 49
59 | TEXT "andi"
60 | BYTE 37
61 | TEXT "andj"
62 | BYTE 53
63 | TEXT "asla"
64 | BYTE 10
65 | TEXT "aslb"
66 | BYTE 14
67 | TEXT "aslc"
68 | BYTE 30
69 | TEXT "asli"
70 | BYTE 6
71 | TEXT "aslj"
72 | BYTE 22
73 | TEXT "bccl"
74 | BYTE 144
75 | TEXT "bcsl"
76 | BYTE 176
77 | TEXT "beql"
78 | BYTE 240
79 | TEXT "bitb"
80 | BYTE 44
81 | TEXT "biti"
82 | BYTE 36
83 | TEXT "bmil"
84 | BYTE 48
85 | TEXT "bnel"
86 | BYTE 208
87 | TEXT "bpll"
88 | BYTE 16
89 | TEXT "brka"
90 | BYTE 0
91 | TEXT "bvcl"
92 | BYTE 80
93 | TEXT "bvsl"
94 | BYTE 112
95 | TEXT "clca"
96 | BYTE 24
97 | TEXT "clda"
98 | BYTE 216
99 | TEXT "clia"
100 | BYTE 88
101 | TEXT "clva"
102 | BYTE 184
103 | TEXT "cmpb"
104 | BYTE 205
105 | TEXT "cmpc"
106 | BYTE 221
107 | TEXT "cmpd"
108 | BYTE 217
109 | TEXT "cmpe"
110 | BYTE 201
111 | TEXT "cmpg"
112 | BYTE 193
113 | TEXT "cmph"
114 | BYTE 209
115 | TEXT "cmpi"
116 | BYTE 197
117 | TEXT "cmpj"
118 | BYTE 213
119 | TEXT "cpxb"
120 | BYTE 236
121 | TEXT "cpxe"
122 | BYTE 224
123 | TEXT "cpxi"
124 | BYTE 228
125 | TEXT "cpyb"
126 | BYTE 204
127 | TEXT "cpye"
128 | BYTE 192
129 | TEXT "cpyi"
130 | BYTE 196
131 | TEXT "decb"
132 | BYTE 206
133 | TEXT "decc"
134 | BYTE 222
135 | TEXT "deci"
136 | BYTE 198
137 | TEXT "decj"
138 | BYTE 214
139 | TEXT "dexa"
140 | BYTE 202
141 | TEXT "deya"
142 | BYTE 136
143 | TEXT "eorb"
144 | BYTE 77
145 | TEXT "eorc"
146 | BYTE 93
147 | TEXT "eord"
148 | BYTE 89
149 | TEXT "eore"
150 | BYTE 73
151 | TEXT "eorg"
152 | BYTE 65
153 | TEXT "eorh"
154 | BYTE 81
155 | TEXT "eori"
156 | BYTE 69
157 | TEXT "eorj"
158 | BYTE 85
159 | TEXT "incb"
160 | BYTE 238
161 | TEXT "incc"
162 | BYTE 254
163 | TEXT "inci"
164 | BYTE 230
165 | TEXT "incj"
166 | BYTE 246
167 | TEXT "inxa"
168 | BYTE 232
169 | TEXT "inya"
170 | BYTE 200
171 | TEXT "jmpb"
172 | BYTE 76
173 | TEXT "jmpf"
174 | BYTE 108
175 | TEXT "jsrb"
176 | BYTE 32
177 | TEXT "ldab"
178 | BYTE 173
179 | TEXT "ldac"
180 | BYTE 189
181 | TEXT "ldad"
182 | BYTE 185
183 | TEXT "ldae"
184 | BYTE 169
185 | TEXT "ldag"
186 | BYTE 161
187 | TEXT "ldah"
188 | BYTE 177
189 | TEXT "ldai"
190 | BYTE 165
191 | TEXT "ldaj"
192 | BYTE 181
193 | TEXT "ldxb"
194 | BYTE 174
195 | TEXT "ldxd"
196 | BYTE 190
197 | TEXT "ldxe"
198 | BYTE 162
199 | TEXT "ldxi"
200 | BYTE 166
201 | TEXT "ldxk"
202 | BYTE 182
203 | TEXT "ldyb"
204 | BYTE 172
205 | TEXT "ldyc"
206 | BYTE 188
207 | TEXT "ldye"
208 | BYTE 160
209 | TEXT "ldyi"
210 | BYTE 164
211 | TEXT "ldyj"
212 | BYTE 180
213 | TEXT "lsra"
214 | BYTE 74
215 | TEXT "lsrb"
216 | BYTE 78
217 | TEXT "lsrc"
218 | BYTE 94
219 | TEXT "lsri"
220 | BYTE 70
221 | TEXT "lsrj"
222 | BYTE 86
223 | TEXT "nopa"
224 | BYTE 234
225 | TEXT "orab"
226 | BYTE 13
227 | TEXT "orac"
228 | BYTE 29
229 | TEXT "orad"
230 | BYTE 25
231 | TEXT "orae"
232 | BYTE 9
233 | TEXT "orag"
234 | BYTE 1
235 | TEXT "orah"
236 | BYTE 17
237 | TEXT "orai"
238 | BYTE 5
239 | TEXT "oraj"
240 | BYTE 21
241 | TEXT "phaa"
242 | BYTE 72
243 | TEXT "phpa"
244 | BYTE 8
245 | TEXT "plaa"
246 | BYTE 104
247 | TEXT "plpa"
248 | BYTE 40
249 | TEXT "rola"
250 | BYTE 42
251 | TEXT "rolb"
252 | BYTE 46
253 | TEXT "rolc"
254 | BYTE 62
255 | TEXT "roli"
256 | BYTE 38
257 | TEXT "rolj"
258 | BYTE 54
259 | TEXT "rora"
260 | BYTE 106
261 | TEXT "rorb"
262 | BYTE 110
263 | TEXT "rorc"
264 | BYTE 126
265 | TEXT "rori"
266 | BYTE 102
267 | TEXT "rorj"
268 | BYTE 118
269 | TEXT "rtia"
270 | BYTE 64
271 | TEXT "rtsa"
272 | BYTE 96
273 | TEXT "sbcb"
274 | BYTE 237
275 | TEXT "sbcc"
276 | BYTE 253
277 | TEXT "sbcd"
278 | BYTE 249
279 | TEXT "sbce"
280 | BYTE 233
281 | TEXT "sbcg"
282 | BYTE 225
283 | TEXT "sbch"
284 | BYTE 241
285 | TEXT "sbci"
286 | BYTE 229
287 | TEXT "sbcj"
288 | BYTE 245
289 | TEXT "seca"
290 | BYTE 56
291 | TEXT "seda"
292 | BYTE 248
293 | TEXT "seia"
294 | BYTE 120
295 | TEXT "stab"
296 | BYTE 141
297 | TEXT "stac"
298 | BYTE 157
299 | TEXT "stad"
300 | BYTE 153
301 | TEXT "stag"
302 | BYTE 129
303 | TEXT "stah"
304 | BYTE 145
305 | TEXT "stai"
306 | BYTE 133
307 | TEXT "staj"
308 | BYTE 149
309 | TEXT "stxb"
310 | BYTE 142
311 | TEXT "stxi"
312 | BYTE 134
313 | TEXT "stxk"
314 | BYTE 150
315 | TEXT "styb"
316 | BYTE 140
317 | TEXT "styi"
318 | BYTE 132
319 | TEXT "styj"
320 | BYTE 148
321 | TEXT "taxa"
322 | BYTE 170
323 | TEXT "taya"
324 | BYTE 168
325 | TEXT "tsxa"
326 | BYTE 186
327 | TEXT "txaa"
328 | BYTE 138
329 | TEXT "txsa"
330 | BYTE 154
331 | TEXT "tyaa"
332 | BYTE 152
333 | brk
--------------------------------------------------------------------------------
/libOutputCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Output Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : O (y or n)
5 | ;*******************************************************************************
6 |
7 | ;** output -- syntax :- o (y or n) **
8 | COM_OUTPUT
9 | jsr INPUT_COMMAND ; Get next character
10 | cmp #"y" ; Is it Y
11 | beq BeginPrinterOutput ; Yes, then set up printer output
12 | jsr krljmp_CLRCHN$ ; Then its a No then
13 | lda #4 ; Load Printer Channel Number
14 | jsr krljmp_CLOSE$ ; Close Output Channel
15 | jmp READY ; Jump to Command Line
16 |
17 | BeginPrinterOutput
18 | lda #4 ; Load File Number
19 | tax ; Transfer to Device Number
20 | ldy #255 ; Set secondary address
21 | jsr krljmp_SETLFS$ ; Set up File Number
22 | lda #0 ; Set No Filename, not required for printer
23 | ldx #255
24 | ldy #255
25 | jsr krljmp_SETNAM$ ; Set filename that does not exist, but still required
26 | jsr krljmp_OPEN$ ; Open channel
27 | ldx #4 ; Set Channel Number
28 | jsr krljmp_CHKOUT$ ; Open Channel for output
29 | jmp READY ; Jump To Command Line, and all output will be printed.
--------------------------------------------------------------------------------
/libROMRoutines.asm:
--------------------------------------------------------------------------------
1 | ifdef TGT_C64
2 | ; BASIC Rom starts at $A000
3 | bas_ROMError$ = $A437
4 | bas_CustomError$ = $A447
5 | bas_DecimalPrint$ = $BDCD
6 | bas_PrintString$ = $AB1E
7 | bas_ReadyPrompt$ = $A474
8 | bas_LineGet$ = $A96B
9 | bas_NEWCommand$ = $A642
10 | bas_FindLine$ = $A613
11 | bas_LinkProgram$ = $A533
12 | bas_InLine$ = $A560
13 | bas_FrmNum$ = $AD8A
14 | bas_GetAddr$ = $B7F7
15 | bas_LinePrint$ = $BDCD
16 | endif
17 |
18 |
19 | ifdef TGT_VIC20_8K
20 | ; BASIC Rom Starts at $C000
21 | bas_ROMError$ = $C437
22 | bas_CustomError$ = $C447
23 | bas_DecimalPrint$ = $DDCD
24 | bas_PrintString$ = $CB1E
25 | bas_ReadyPrompt$ = $C474
26 | bas_LineGet$ = $C96B
27 | bas_NEWCommand$ = $C642
28 | bas_FindLine$ = $C613
29 | bas_LinkProgram$ = $C533
30 | bas_InLine$ = $C560
31 | bas_FrmNum$ = $CD8A
32 | bas_GetAddr$ = $D7F7
33 | bas_LinePrint$ = $DDCD
34 | endif
35 |
36 | ; Kernel Jump Vectors
37 | krljmp_PCINT$ = $FF81
38 | krljmp_IOINIT$ = $FF84
39 | krljmp_RAMTAS$ = $FF87
40 | krljmp_RESTOR$ = $FF8A
41 | krljmp_VECTOR$ = $FF8D
42 | krljmp_SETMSG$ = $FF90
43 | krljmp_SECOND$ = $FF93
44 | krljmp_TKSA$ = $FF96
45 | krljmp_MEMTOP$ = $FF99
46 | krljmp_MEMBOT$ = $FF9C
47 | krljmp_SCNKEY$ = $FF9F
48 | krljmp_SETTMO$ = $FFA2
49 | krljmp_ACPTR$ = $FFA5
50 | krljmp_CIOUT$ = $FFA8
51 | krljmp_UNTALK$ = $FFAB
52 | krljmp_UNLSN$ = $FFAE
53 | krljmp_LISTEN$ = $FFB1
54 | krljmp_TALK$ = $FFB4
55 | krljmp_READST$ = $FFB7
56 | krljmp_SETLFS$ = $FFBA
57 | krljmp_SETNAM$ = $FFBD
58 | krljmp_OPEN$ = $FFC0
59 | krljmp_CLOSE$ = $FFC3
60 | krljmp_CHKIN$ = $FFC6
61 | krljmp_CHKOUT$ = $FFC9
62 | krljmp_CLRCHN$ = $FFCC
63 | krljmp_CHRIN$ = $FFCF
64 | krljmp_CHROUT$ = $FFD2
65 | krljmp_LOAD$ = $FFD5
66 | krljmp_SAVE$ = $FFD8
67 | krljmp_SETTIM$ = $FFDB
68 | krljmp_RDTIM$ = $FFDE
69 | krljmp_STOP$ = $FFE1
70 | krljmp_GETIN$ = $FFE4
71 | krljmp_CLALL$ = $FFE7
72 | krljmp_UDTIM$ = $FFEA
73 | krljmp_SCREEN$ = $FFED
74 | krljmp_PLOT$ = $FFF0
75 | krljmp_BASE$ = $FFF3
76 |
77 | jmpvec_Error = $0300
78 | jmpvec_Main = $0302
79 | jmpvec_Crunch = $0304
80 | jmpvec_List = $0306
81 | jmpvec_Run = $0308
82 |
83 | jmpvec_irq = $0314
84 | jmpvec_brk = $0316
85 | jmpvec_nmi = $0318
86 |
--------------------------------------------------------------------------------
/libRegisterCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Register Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : R
5 | ;*******************************************************************************
6 |
7 | COM_REGISTER
8 | ldy #>REGISTER_TEXT ; Load Address of Registry Header
9 | lda #
113 | ;*******************************************************************************
114 |
115 | COM_REGISTERPUT
116 | jsr IBYTE2 ; Get Hex Word Value
117 | sta PCHIREG ; Store in PC Address
118 | stx PCLOREG
119 |
120 | ifdef TGT_C64
121 | jsr IBYTE2 ; Get Hex Word Value
122 | sei
123 | sta IRQINT + 1 ; Store in IRQ Vector location
124 | stx IRQINT
125 | jsr IBYTE2 ; Get Hex Word Value
126 | sta NMIINT + 1 ; Store in NMI Vector Location
127 | stx NMIINT
128 | cli
129 | endif
130 |
131 | jsr IBYTE1 ; Get Hex Byte Value
132 | sta STREG ; Store in Status Register
133 | jsr IBYTE1 ; Get Hex Byte Value
134 | sta ACCREG ; Store in Accumulator
135 | jsr IBYTE1 ; Get Hex Byte Value
136 | sta XREG ; Store in X Register
137 | jsr IBYTE1 ; Get Hex Byte Value
138 | sta YREG ; Store In Y Register
139 | jsr IBYTE1 ; Get Hex Byte Value
140 | sta STPTREG ; Store in Stck Pointer
141 | jmp READY ; Jump to Command Line
142 |
--------------------------------------------------------------------------------
/libSaveCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Save Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : S "(filename)" (dev) (addr) (addr)
5 | ;*******************************************************************************
6 |
7 | ;** save -- syntax :- s (filename) (dev) (addr) (addr) **
8 | COM_SAVE
9 | jsr krljmp_CHRIN$
10 | ldy #0
11 | SAV1
12 | jsr krljmp_CHRIN$
13 | cmp #CHR_Quote
14 | beq SAV2
15 | sta COM_TEXT,y
16 | iny
17 | cpy #16
18 | bne SAV1
19 | jmp ERROR
20 |
21 | SAV2
22 | sty COM_L
23 | jsr IBYTE1
24 | tax
25 | lda #1
26 | ldy #1
27 | jsr krljmp_SETLFS$
28 | lda COM_L
29 | ldx #COM_TEXT
31 | jsr krljmp_SETNAM$
32 | jsr IBYTE2
33 | sta ADDVEC + 1
34 | stx ADDVEC
35 | jsr IBYTE2
36 | pha
37 | txa
38 | pha
39 | jsr PrintCarrageReturnAndLineFeed
40 | pla
41 | tax
42 | pla
43 | tay
44 | lda #ADDVEC
45 | jsr krljmp_SAVE$
46 | jmp READY
--------------------------------------------------------------------------------
/libTransferCommand.asm:
--------------------------------------------------------------------------------
1 | ;*******************************************************************************
2 | ;* Transfer Operation *
3 | ;*******************************************************************************
4 | ;* Syntax : T (addr) (addr) (addr)
5 | ;*******************************************************************************
6 |
7 | ;** transfer -- syntax :- t (addr) (addr) (addr) **
8 | COM_TRANSFER
9 | jsr IBYTE2 ; Get Start Address Word Value
10 | sta ADDVEC + 1 ; Store Start Address
11 | stx ADDVEC
12 | jsr IBYTE2 ; Get End Address Word Value
13 | sta DIS_END + 1 ; Store End Address
14 | stx DIS_END
15 | jsr IBYTE2 ; Get New Start Address Word Value
16 | sta HTVEC + 1 ; Store New Start Address
17 | stx HTVEC
18 |
19 | StartTransferLooper
20 | ldy #0
21 | lda (ADDVEC),y ; Load Byte from the Old Address
22 | sta (HTVEC),y ; Store Byte in the New Address
23 | lda #1
24 | sta COM_NB
25 | jsr ADDNB ; Update Old Address Counter
26 | clc
27 | inc HTVEC ; Update New Address Counter
28 | bne @TRN2
29 | inc HTVEC + 1
30 |
31 | @TRN2
32 | lda ADDVEC + 1
33 | cmp DIS_END + 1 ; Have we hit the end Address
34 | beq @TRN3 ; Yes, then lets be sure
35 | jmp StartTransferLooper ; No, then please continue
36 |
37 | @TRN3
38 | lda ADDVEC
39 | cmp DIS_END ; have we deffo hit the end address
40 | bcs TransferFinished ; Yes, then, thats all folks!!!!
41 | jmp StartTransferLooper ; No, then carry on with the next byte move
42 |
43 | TransferFinished
44 | jmp READY ; Jump To The Command Line
--------------------------------------------------------------------------------