-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathctmon65.asm
More file actions
1581 lines (1579 loc) · 30.4 KB
/
ctmon65.asm
File metadata and controls
1581 lines (1579 loc) · 30.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;*********************************************************
; CTMON65
;
; This is the monitor for the Corsham Techologies, LLC
; SS-50 65C02 board. It's a fairly generic monitor that
; can be ported to other 6502 based systems.
;
; Written mostly while on a family vacation in 2018, but
; ideas and code were taken from other Corsham Tech
; projects and various web pages (credit given in the
; code).
;
; Bob Applegate
; bob@corshamtech.com
; www.corshamtech.com
;*********************************************************
;
include "config.inc"
;
; Current version and revision
;
VERSION equ 0
REVISION equ 3
;
;---------------------------------------------------------
; ASCII constants
;
BELL equ $07
BS equ $08
LF equ $0a
CR equ $0d
;
; Max number of bytes per line for hex dump
;
BYTESLINE equ 16
;
; These are various buffer sizes
;
FILENAME_SIZE equ 12
;
; Intel HEX record types
;
DATA_RECORD equ $00
EOF_RECORD equ $01
;
; Zero-page data
;
; zpage
bss
org ZERO_PAGE_START
sptr ds 2
INL ds 1
INH ds 1
putsp ds 2
;
; Non zero-page data
;
bss
org RAM_START
;
; The use of memory starting from here will remain
; constant through different versions of CTMON65.
;
IRQvec ds 2
NMIvec ds 2
;
; Before a L(oad) command, these are set to $FF.
; After loading, if they are different, jump to
; that address.
;
AutoRun ds 2
;
; Pointer to the subroutine that gets the next input
; character. Used for doing disk/console input.
;
inputVector ds 2
;
; Same thing for output.
;
outputVector ds 2
;
; Buffer for GETLINE
;
buffer ds BUFFER_SIZE
;
; Anything from here can be moved between versions.
;
SaveA ds 1
SaveX ds 1
SaveY ds 1
SavePC ds 2
SaveC ds 1
SaveSP ds 1
SAL ds 1
SAH ds 1
EAL ds 1
EAH ds 1
tempA ds 1
filename ds FILENAME_SIZE+1
diskBufOffset ds 1
diskBufLength ds 1
CHKL ds 1
ID ds 1
Temp16L ds 1
Temp16H ds 1
;
; This weird bit of DBs is to allow for the fact that
; I'm putting a 4K monitor into the top half of an
; 8K EEPROM. This forces the actual code to the top
; 4K section.
;
code
org ROM_START-$1000
db "This space for rent.",CR,LF
db "Actually, this just forces the "
db "binary file to be 8K long."
;
org ROM_START
;
;=========================================================
; Jump table to common functions. The entries in this
; table are used by external programs, so nothing can be
; moved or removed from this table. New entries always
; go at the end. Many of these are internal functions
; and I figured they might be handy for others.
;
COLDvec jmp RESET
WARMvec jmp WARM
;
; These are the major and minor revision numbers so that
; code can check to see which CTMON65 version is running.
;
CTMON65ver db VERSION
CTMON65rev db REVISION
db 0
;
; Console related functions
;
CINvec jmp cin
COUTvec jmp cout
CSTATvec jmp cstatus
PUTSILvec jmp putsil
GETLINEvec jmp getline
CRLFvec jmp crlf
OUTHEXvec jmp HexA
;
; Low-level functions to access the SD card system
;
if SD_ENABLED
XPARINITvev jmp xParInit
XPARSETWRITEvec jmp xParSetWrite
XPARSETREADvec jmp xParSetRead
XPARWRITEvec jmp xParWriteByte
XPARREADvec jmp xParReadByte
;
; Higher level SD card functions
;
DISKPINGvec jmp DiskPing
DISKDIRvec jmp DiskDir
DISKDIRNEXTVEC jmp DiskDirNext
DISKOPENREADvec jmp DiskOpenRead
DISKOPENWRITvec jmp DiskOpenWrite
DISKREADvec jmp DiskRead
DISKWRITEvec jmp DiskWrite
DISKCLOSEvec jmp DiskClose
endif ;SD_ENABLED
;
;---------------------------------------------------------
; Cold start entry point
;
RESET ldx #$ff
txs
jsr cinit
jsr xParInit
;
; Reset the NMI and IRQ vectors
;
lda #DefaultNMI&$ff
sta NMIvec
lda #DefaultNMI>>8
sta NMIvec+1
;
lda #DefaultIRQ&$ff
sta IRQvec
lda #DefaultIRQ>>8
sta IRQvec+1
;
; Print start-up message
;
jsr putsil
db CR,LF,LF,LF,LF
db "CTMON65 rev "
db VERSION+'0','.'
db REVISION+'0'
db CR,LF
db "09/20/2018 by Bob Applegate K2UT"
db ", bob@corshamtech.com"
db CR,LF,LF,0
;
;---------------------------------------------------------
; Warm start entry point. This is the best place to jump
; in the code after a user program has ended. Go through
; the vector, of course!
;
WARM ldx #$ff
txs
;
; Prompt the user and get a line of text
;
prompt jsr setOutputConsole
jsr setInputConsole
jsr putsil
db CR,LF
db "CTMON65> "
db 0
prompt2 jsr cin
cmp #CR
beq prompt
cmp #LF
beq prompt2 ;don't prompt
sta tempA
;
; Now cycle through the list of commands looking for
; what the user just pressed.
;
lda #commandTable&$ff
sta sptr
lda #commandTable/256
sta sptr+1
jsr searchCmd ;try to find it
;
; Hmmm... wasn't one of the built in commands, so
; see if it's an extended command.
;
if EXTENDED_CMDS
lda ExtensionAddr
sta sptr
lda ExtensionAddr+1
sta sptr+1
jsr searchCmd ;try to find it
endif
;
; If that returns, then the command was not found.
; Print that it's unknown.
;
jsr putsil
db " - Huh?",0
cmdFound jmp prompt
;
;=====================================================
; Vector table of commands. Each entry consists of a
; single ASCII character (the command), a pointer to
; the function which handles the command, and a pointer
; to a string that describes the command.
;
commandTable db '?'
dw showHelp
dw quesDesc
;
db 'C'
dw doContinue
dw cDesc
;
db 'D'
dw doDiskDir
dw dDesc
;
db 'E' ;edit memory
dw editMemory
dw eDesc
;
db 'H' ;hex dump
dw hexDump
dw hDesc
;
db 'J' ;jump to address
dw jumpAddress
dw jDesc
;
db 'L' ;load Intel HEX file
dw loadHex
dw lDesc
;
db 'M' ;perform memory test
dw memTest
dw mDesc
;
db 'P' ;ping remote disk
dw pingDisk
dw pDesc
;
db 'S' ;save memory as hex file
dw saveHex
dw sDesc
;
db 'T' ;type a file on SD
dw typeFile
dw tDesc
;
db 0 ;marks end of table
;
;=====================================================
; Descriptions for each command in the command table.
; This wastes a lot of space... I'm open for any
; suggestions to keep the commands clear but reducing
; the amount of space this table consumes.
;
quesDesc db "? ........... Show this help",0
cDesc db "C ........... Continue execution",0
dDesc db "D ........... Disk directory",0
eDesc db "E xxxx ...... Edit memory",0
hDesc db "H xxxx xxxx . Hex dump memory",0
jDesc db "J xxxx ...... Jump to address",0
lDesc db "L ........... Load HEX file",0
mDesc db "M xxxx xxxx . Memory test",0
pDesc db "P ........... Ping disk controller",0
sDesc db "S xxxx xxxx . Save memory to file",0
tDesc db "T ........... Type disk file",0
;
;=====================================================
; This subroutine will search for a command in a table
; and call the appropriate handler. See the command
; table near the start of the code for what the format
; is. If a match is found, pop off the return address
; from the stack and jump to the code. Else, return.
;
searchCmd ldy #0
cmdLoop lda (sptr),y
beq cmdNotFound
cmp tempA ;compare to user's input
beq cmdMatch
iny ;start of function ptr
iny
iny ;start of help
iny
iny ;move to next command
bne cmdLoop
;
; It's found! Load up the address of the code to call,
; pop the return address off the stack and jump to the
; handler.
;
cmdMatch iny
lda (sptr),y ;handler LSB
pha
iny
lda (sptr),y ;handler MSB
sta sptr+1
pla
sta sptr
pla ;pop return address
pla
jmp (sptr)
;
; Not found, so just return.
;
cmdNotFound rts
;
;=====================================================
; Handles the command to prompt for an address and then
; jump to it.
;
jumpAddress jsr putsil
db "Jump to ",0
jsr getStartAddr
bcs cmdRet ;branch on bad address
jsr crlf
jmp (SAL) ;else jump to address
;
cmdRet jmp prompt
;
;=====================================================
; Do a hex dump of a region of memory.
;
; Slight bug: the starting address is rounded down to
; a multiple of 16. I'll fix it eventually.
;
hexDump jsr putsil
db "Hex dump ",0
jsr getAddrRange
bcs cmdRet
jsr crlf
;
; Move start address to sptr but rounded down to the
; 16 byte boundary. While it's really cool to start at
; the exact address specified by the user, it adds
; code that really doesn't add much (any?) value.
;
lda SAH
sta sptr+1
lda SAL
and #$f0 ;force to 16 byte
sta sptr
;
;-----------------------------------------------------
; This starts each line. Set flag to indcate we're
; doing the hex portion, print address, etc.
;
hexdump1 jsr crlf
lda sptr+1
jsr HexA ;print the address
lda sptr
jsr HexA
jsr space2 ;two spaces after address
;
;-----------------------------------------------------
; This loop gets the next byte, prints the value in
; hex and adds the appropriate ASCII character to the
; buffer.
;
ldy #0 ;offset from sptr
hexdump3 ldx #0 ;bytes on line
hexdump2 lda (sptr),y ;get byte
jsr HexA ;print hex version of it
jsr space ;space before next value
;
; Put the byte into the buffer. If it is not printable
; ASCII then substitute a dot instead.
;
cmp #' '
bcc hexdot
cmp #'~'
bcc hexpr
hexdot lda #'.'
hexpr sta buffer,x ;save for later
;
; See if the end of the user defined area was just dumped
;
hexdumpchk lda sptr
cmp EAL
bne hexdump4
lda sptr+1
cmp EAH
beq hexdumpend
;
; Not done yet, so see if at end of the line
;
hexdump4 jsr INCPT ;move to next address
inx
cpx #BYTESLINE
bne hexdump2
;
; At end, so dump ASCII contents
;
jsr dumpBuffer
jmp hexdump1
;
; At the end but still need to dump the ASCII version.
;
hexdumpend inx ;count last byte output
jsr dumpBuffer
jsr crlf
ret1 jmp prompt
;
;=====================================================
; A helper function that prints the ASCII data in the
; buffer. On entry X contains the number of bytes
; in the buffer.
;
dumpBuffer cpx #BYTESLINE ;is buffer full?
beq hexdump91 ;jump if so
lda #' ' ;else fill with spaces
sta buffer,x
jsr space3 ;and space over
inx
bne dumpBuffer
;
hexdump91 jsr space3 ;separate the two passes
ldx #0
hexdump99 lda buffer,x
jsr cout ;print char in buffer
inx
cpx #BYTESLINE
bne hexdump99
rts
;
;=====================================================
; Edit memory. This waits for a starting address to be
; entered. It will display the current address and its
; contents. Possible user inputs and actions:
;
; Two hex digits will place that value in memory
; RETURN moves to next address
; BACKSPACE moves back one address
;
editMemory jsr putsil
db "Edit memory ",0
jsr getStartAddr
bcs ret1
lda SAL ;move address into...
sta sptr ;...POINT
lda SAH
sta sptr+1
;
; Display the current location
;
editMem1 jsr crlf
lda sptr+1
jsr HexA
lda sptr
jsr HexA
jsr space
ldy #0
lda (sptr),y ;get byte
jsr HexA ;print it
jsr space
;
jsr getHex
bcs editMem2 ;not hex
ldy #0
sta (sptr),y ;save new value
;
; Bump POINT to next location
;
editMem3 inc sptr
bne editMem1
inc sptr+1
jmp editMem1
;
; Not hex, so see if another command
;
editMem2 cmp #CR
beq editMem3 ;move to next
cmp #BS
bne ret1 ;else exit
;
; Move back one location
;
sec
lda sptr
sbc #1
sta sptr
bcs editMem1
dec sptr+1
jmp editMem1
;
;=====================================================
; This handles the Load hex command.
;
loadHex lda #$ff
sta AutoRun+1
;
jsr putsil
db CR,LF
db "Enter filename, or Enter to "
db "load from console: ",0
;
jsr getFileName ;get filename
lda filename ;null?
beq loadHexConsole ;load from console
;
; Open the file
;
ldy #filename&$ff
ldx #filename/256
jsr DiskOpenRead
bcc loadHexOk ;opened ok
;
openfail jsr putsil
db CR,LF
db "Failed to open file"
db CR,LF,0
cmdRet3 jmp prompt
;
loadHexOk jsr setInputFile ;redirect input
jmp loadStart
;
; They are loading from the console
;
loadHexConsole jsr putsil
db CR,LF
db "Waiting for file, or ESC to"
db " exit..."
db CR,LF,0
jsr setInputConsole
;
; The start of a line. First character should be a
; colon, but toss out CRs, LFs, etc. Anything else
; causes an abort.
;
loadStart jsr redirectedGetch ;get start of line
cmp #CR
beq loadStart
cmp #LF
beq loadStart
cmp #':' ;what we expect
bne loadAbort
;
; Get the header of the record
;
lda #0
sta CHKL ;initialize checksum
;
jsr getHex ;get byte count
bcs loadAbort
sta SaveX ;save byte count
jsr updateCrc
jsr getHex ;get the MSB of offset
bcs loadAbort
sta sptr+1
jsr updateCrc
jsr getHex ;get LSB of offset
bcs loadAbort
sta sptr
jsr updateCrc
jsr getHex ;get the record type
bcs loadAbort
jsr updateCrc
;
; Only handle two record types:
; 00 = data record
; 01 = end of file record
;
cmp #DATA_RECORD
beq loadDataRec
cmp #EOF_RECORD
beq loadEof
;
; Unknown record type
;
loadAbort jsr putsil
db CR,LF
db "Aborting"
db CR,LF,0
loadExit jsr setInputConsole
jmp prompt
;
; EOF is easy
;
loadEof jsr getHex ;get checksum
jsr putsil
db CR,LF
db "Success!"
db CR,LF,0
;
; If the auto-run vector is no longer $ffff, then jump
; to whatever it points to.
;
lda AutoRun+1
cmp #$ff ;unchanged?
beq lExit1
jmp (AutoRun) ;execute!
;
lExit1 jmp loadExit
;
; Data records have more work. After processing the
; line, print a dot to indicate progress. This should
; be re-thought as it could slow down loading a really
; big file if the console speed is slow.
;
loadDataRec ldx SaveX ;byte count
ldy #0 ;offset
loadData1 stx SaveX
sty SaveY
jsr getHex
bcs loadAbort
jsr updateCrc
ldy SaveY
ldx SaveX
sta (sptr),y
iny
dex
bne loadData1
;
; All the bytes were read so get the checksum and see
; if it agrees. The checksum is a twos-complement, so
; just add the checksum into what we've been calculating
; and if the result is zero then the record is good.
;
jsr getHex ;get checksum
clc
adc CHKL
bne loadAbort ;non-zero is error
;
lda #'.' ;sanity indicator when
jsr cout ;...loading from file
jmp loadStart
;
;=====================================================
; Handles the command to save a region of memory as a
; file on the SD.
;
saveHex jsr getAddrRange ;get range to dump
bcs lExit1 ;abort on error
;
; Get the filename to save to
;
jsr putsil
db CR,LF
db "Enter filename, or Enter to "
db "load from console: ",0
;
jsr getFileName ;get filename
lda filename ;null?
beq saveHexConsole ;dump to console
;
; They selected a file, so try to open it.
;
ldx #filename>>8
ldy #filename&$ff
jsr DiskOpenWrite ;attempt to open file
bcc sopenok ;branch if opened ok
jmp openfail
;
sopenok jsr setOutputFile
jmp savehex2
;
; They are saving to the console. Set up the output
; vector and do the job.
;
saveHexConsole jsr setOutputConsole
;
; Compute the number of bytes to dump
;
savehex2 sec
lda EAL
sbc SAL
sta Temp16L
lda EAH
sbc SAH
sta Temp16H
bcc SDone ;start > end
ora 0
bmi SDone ;more than 32K seems wrong
;
; Add one to the count
;
inc Temp16L
bne slab1
inc Temp16H
;
; Move pointer to zero page
;
slab1 lda SAL
sta sptr
lda SAH
sta sptr+1
;
; Top of each loop. Start by seeing if there are any bytes
; left to dump.
;
Sloop1 lda Temp16H
bne Sgo ;more to do
lda Temp16L
bne Sgo ;more to do
;
; At end of the region, so output an end record. This
; probably looks like overkill but keep in mind this
; might be going to a file so we can't use the normal
; string put functions.
;
lda #':'
jsr redirectedOutch
lda #0
jsr HexToOutput
jsr HexToOutput
jsr HexToOutput
lda #1
jsr HexToOutput
lda #$ff
jsr HexToOutput
;
; If output to file, flush and close the file.
;
lda filename
beq SDone ;it's going to console
jsr CloseOutFile
SDone jmp prompt ;back to the monitor
;
; This dumps the next line. See how many bytes are left to do
; and if more than BYTESLINE, then just do BYTESLINE.
;
Sgo lda Temp16H
bne Sdef ;do default number of bytes
lda Temp16L
cmp #BYTESLINE
bcc Scnt ;more than max per line
Sdef lda #BYTESLINE
Scnt sta tempA ;for decrementing
sta ID ;for subtracting
;
; Put out the header
;
lda #':'
jsr redirectedOutch
;
lda tempA
sta CHKL ;start checksum
jsr HexToOutput
;
lda sptr+1 ;starting address
jsr updateCrc
jsr HexToOutput
lda sptr
jsr updateCrc
jsr HexToOutput
;
lda #0 ;record type - data
jsr HexToOutput
;
; Now print the proper number of bytes
;
Sloop2 ldy #0
lda (sptr),y ;get byte
jsr updateCrc
jsr HexToOutput
jsr INCPT ;increment pointer
;
sdec dec tempA
bne Sloop2
;
; Now print checksum
;
lda CHKL
eor #$ff ;one's complement
clc
adc #1 ;two's complement
jsr HexToOutput
;
; Output a CR/LF
;
lda #CR
jsr redirectedOutch
lda #LF
jsr redirectedOutch
;
; If saving to disk, output a dot to indicate progress.
;
lda filename
beq shf2
;
lda #'.'
jsr cout ;goes to console
;
shf2 sec
lda Temp16L
sbc ID
sta Temp16L
lda Temp16H
sbc #0
sta Temp16H
;
jmp Sloop1
;
;=====================================================
; Get a disk filename.
;
getFileName ldx #0
getFilename1 jsr cin ;get next key
cmp #CR ;end of the input?
beq getFnDone
cmp #BS ;backspace?
beq getFnDel
cpx #FILENAME_SIZE ;check size
beq getFilename1 ;at length limit
sta filename,x ;else save it
jsr cout
inx
bne getFilename1
;
getFnDel dex
bmi getFnU ;no charac here
lda #BS
jsr cout
lda #' '
jsr cout
lda #BS
jsr cout
dex
getFnU inx ;can't go past start
bpl getFilename1
getFnDone lda #0 ;terminate line
sta filename,x
jmp crlf
;
;=====================================================
; Add the byte in A to the output buffer. If the
; buffer is full, flush it to disk.
;
putNextFileByte ldx diskBufOffset
cpx #BUFFER_SIZE ;buffer full?
bne pNFB ;no
;
; The buffer is full, so write it out.
;
pha ;save byte
lda #BUFFER_SIZE
ldx #buffer>>8
ldy #buffer&$ff
jsr DiskWrite
;
ldx #0 ;reset index
pla
pNFB sta buffer,x
inx
stx diskBufOffset
rts
;
;*********************************************************
; Dump the current registers based on values in the Save*
; locations.
;
DumpRegisters jsr putsil
db "PC:",0
lda SavePC+1
jsr HexA
lda SavePC
jsr HexA
;
jsr putsil
db " A:",0
lda SaveA
jsr HexA
;
jsr putsil
db " X:",0
lda SaveX
jsr HexA
;
jsr putsil
db " Y:",0
lda SaveY
jsr HexA
;
jsr putsil
db " SP:",0
lda SaveSP
jsr HexA
;
; Last is the condition register. For this, print the
; actual flags. Lower case for clear, upper for set.
;
jsr putsil
db " Flags:",0
if FULL_STATUS
;
; N - bit 7
;
lda #$80 ;bit to test
ldx #'N' ;set ACII char
jsr testbit
;
; V - bit 6
;
lda #$40 ;bit to test
ldx #'V' ;set ACII char
jsr testbit
;
lda #'-' ;unused bit
jsr cout
;
; B - bit 4
;
lda #$10 ;bit to test
ldx #'B' ;set ACII char
jsr testbit
;
; D - bit 3
;
lda #$08 ;bit to test
ldx #'D' ;set ACII char
jsr testbit
;
; I - bit 2
;
lda #$04 ;bit to test
ldx #'I' ;set ACII char
jsr testbit
;
; Z - bit 1
;
lda #$02 ;bit to test
ldx #'Z' ;set ACII char
jsr testbit
;
; C - bit 0
;
lda #$01 ;bit to test
ldx #'C' ;set ACII char
;
; Fall through...
;
;*********************************************************
; Given a bit mask in A and an upper case character
; indicating the flag name in X, see if the flag is set or
; not. Output upper case if set, lower case if not.
;
testbit and SaveC ;is bit set?
bne testbit1 ;yes
txa
ora #$20 ;make lower case
jmp cout
testbit1 txa
jmp cout
else
lda SaveSP
jmp HexA
endif
;
;=====================================================