-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupermon816c_no_srec.asm
4840 lines (4836 loc) · 172 KB
/
supermon816c_no_srec.asm
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
.opt proc65816,caseinsensitive,swapbin
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;* *
;* SUPERMON 816 MACHINE LANGUAGE MONITOR FOR THE W65C816S MICROPROCESSOR *
;* ——————————————————————————————————————————————————————————————————————————————— *
;* Copyright ©1991-2023 by BCS Technology Limited. All rights reserved. *
;* *
;* Redistribution & use of this software in source and/or binary forms, with or *
;* without modifications, are permitted, provided that the following conditions *
;* are met: *
;* *
;* 1) Redistributions of source code must retain the above copyright notice, this *
;* list of conditions & the below disclaimer. *
;* *
;* 2) Redistribution in binary form must reproduce the above copyright notice, *
;* this list of conditions & the below disclaimer in the documentation & other *
;* materials included with the distribution. *
;* *
;* 3) The names of the copyright holder and/or its contributors shall not be used *
;* to endorse or promote any product derived from this software, unless written *
;* permission to do so has been granted by the copyright holder. *
;* *
;* DISCLAIMER *
;* —————————— *
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS & CONTRIBUTORS “AS IS”. Any *
;* express or implied warranties, including, but not limited to, the implied war- *
;* ranties of merchantability & fitness for a particular purpose are disclaimed. *
;* In no event shall the copyright owner and/or contributors be liable for any *
;* direct, indirect, incidental, special, exemplary, or consequential damages *
;* (including, but not limited to, procurement of substitute goods or services; *
;* loss of use, data, or profits; or business interruption) however caused & on *
;* any theory of liability, whether in contract, strict liability, or tort (incl- *
;* uding negligence or otherwise) arising in any way out of the use of this soft- *
;* ware, even if advised of the possibility of such damage. *
;* *
;* If any provision set forth herein is not acceptable to you, DO NOT USE THIS *
;* SOFTWARE & immediately delete it & all accompanying documentation from your *
;* system. *
;* ——————————————————————————————————————————————————————————————————————————————— *
;* Supermon 816 is a salute to Jim Butterfield (1936-2007). *
;* *
;* Jim, who was the unofficial spokesman for Commodore International during the *
;* heyday of the company's 8 bit supremacy, was the author of the Supermon machine *
;* language monitor for the PET & CBM computers. When the best-selling Commodore *
;* 64 was introduced, Jim adapted his software to the new machine & gave the adap- *
;* tation the name Supermon 64. *
;* *
;* Although Supermon 816 is not an adaptation of Supermon 64, it was decided to *
;* keep the Supermon name alive, since Supermon 816's general operation & user in- *
;* terface is similar to that of Supermon 64. Supermon 816 is 100 percent native- *
;* mode 65C816 code & was developed from a blank canvas. *
;* *
;* Supermon 816's source code was edited and assembled with the assembler in the *
;* Kowalski simulator, version 1.3.4. The latest version of the simulator can be *
;* downloaded at https://rictor.org/sbc/kowalski.html (scroll to the bottom of the *
;* page for the download). The simulator runs on Microsoft Windows only. *
;* ——————————————————————————————————————————————————————————————————————————————— *
;* Supermon 816 is a full featured machine language monitor. It can: *
;* *
;* A — Assemble code. *
;* C — Compare memory regions. *
;* D — Disassemble code. *
;* F — Fill memory region (fill cannot span banks in this version). *
;* G — Execute code (stops at BRK). *
;* H — Search (hunt) memory. *
;* J — Execute code as a subroutine (stops at BRK or RTS). *
;* M — Dump & display memory range. *
;* R — Dump & display 65C816 registers. *
;* T — Copy (transfer) memory region. *
;* > — Modify (“poke”) memory. *
;* ; — Modify 65C816 registers. *
;* *
;* Supermon 816 accepts binary (%), octal (@), decimal (+) and hexadecimal ($) as *
;* input for numeric parameters. Additionally, the H and > operations accept an *
;* ASCII string in place of numeric values by preceding the string with ', e.g.: *
;* *
;* h 042000 042FFF 'BCS Technology Limited *
;* *
;* If no radix symbol is entered hex is assumed. *
;* *
;* Numeric conversion is also available. For example, typing: *
;* *
;* +1234567 [CR] *
;* *
;* at the monitor's prompt will display: *
;* *
;* $12D687 *
;* +1234567 *
;* @04553207 *
;* %100101101011010000111 *
;* *
;* In the above example, [CR] means the console keyboard's return or enter key. *
;* *
;* All numeric values are internally processed as 32-bit unsigned integers. Addr- *
;* esses may be entered as 8-, 16- or 24-bit values. During instruction assembly, *
;* immediate mode operands may be forced to 16 bits by preceding the operand with *
;* an exclamation point if the instruction can accept a 16-bit operand, e.g.: *
;* *
;* a 1f2000 lda !#4 *
;* *
;* The above will assemble as: *
;* *
;* A 1F2000 A9 04 00 LDA #$0004 *
;* *
;* Entering: *
;* *
;* a 1f2000 ldx !#+157 *
;* *
;* will assemble as: *
;* *
;* A 1F2000 A2 9D 00 LDX #$009D *
;* *
;* Absent the ! in the operand field, the above would have been assembled as: *
;* *
;* A 1F2000 A2 9D LDX #$9D *
;* *
;* If an immediate mode operand is greater than $FF, assembly of a 16-bit operand *
;* is implied. *
;* *
;* Type X at the Supermon 816 prompt to exit to the operating environment. *
;* ——————————————————————————————————————————————————————————————————————————————— *
;* *
;* Notes on Instruction Syntax *
;* ——————————————————————————— *
;* The Eyes and Lichty programming manual uses the following syntax for the PEA *
;* and PEI instructions: *
;* *
;* PEA <word> *
;* PEI (<dp>) *
;* *
;* PEA's operand is a 16-bit value. PEI's operand is a direct page address and *
;* hence is an 8-bit value. *
;* *
;* The Eyes and Lichty syntax for both instructions is incorrect. PEA's operand *
;* is 16-bit data that will be pushed, making PEA an immediate-mode instruction. *
;* When assembling instructions, PEA must be entered as follows: *
;* *
;* PEA #<word> *
;* *
;* or... *
;* *
;* PEA #<byte> *
;* *
;* In the latter usage, <byte> will be “promoted” to a word. *
;* *
;* PEI's operand is a direct-page (<dp>) location whose content has no special *
;* significance. PEI pushes, as a word, whatever is stored at <dp> and <dp+1>, *
;* which consitutes direct-page addressing. Therefore, when assembling instruc- *
;* tions, PEI must entered as follows: *
;* *
;* PEI <dp> *
;* *
;* The COP instruction is treated as immediate mode for syntactical reasons. The *
;* correct syntax for COP is: *
;* *
;* COP #<sig> *
;* *
;* where <sig> is the 8-bit signature. Supermon 816 doesn't check the signature's *
;* value, other than to verify it is 8 bits. *
;* *
;* Although the official WDC assembly language syntax for the jump (JMP) instruc- *
;* tion allows use of a “long” (24-bit) address, Supermon 816 doesn't support that *
;* addressing mode. Use JML instead. JML's operand will always be assembled as a *
;* 24-bit address. JMP's operand will always be treated as a 16-bit address. An *
;* attempt to assemble JMP with a 24-bit address will cause an error. *
;* *
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;
; * * * * * * * * * * * *
; * VERSION INFORMATION *
; * * * * * * * * * * * *
;
softvers .macro
.byte "1" ;major
.byte "."
.byte "1" ;minor
.byte "."
.byte "3r" ;revision
.endm
;
;REVISION TABLE
;
;Ver Rev Date Description
;———————————————————————————————————————————————————————————————————————————————
;1.1 2015/07/31 A) Added code to accept Motorola S-record loads. This version
; continues with the VT-100 console driver.
;
; 2021/02/22 A) Fix an error in the monitor instruction encode/decode table
; that prevented ORA <abs>,Y from being assembled & caused
; the instruction to be disassembled as ORA <abs>.
;
; 2021/05/16 A) Fixed an error in the function that generates an offset for
; use in assembling BRL & PER. In cases in which the target
; was out of range for a forward branch or reference, the
; function was not correctly computing the offset needed &
; was instead indicating an out-of-range error.
;
; 2023/08/14 A) Corrected an inadvertent coding error in the GETBYTE sub-
; routine.
;
; 2024/06/18 A) Revision ‘3r’: S-record loader removed to reduce footprint
; to less than 4KB.
;———
;1.0 2013/11/01 A) Original derived from the POC V1.1 single-board computer
; firmware.
;
; 2013/11/04 A) Fixed a problem where the B-accumulator wasn't always being
; be copied to shadow storage after return from execution of
; a J command.
;
; 2014/06/03 A) Detail change in the INPUT subroutine; no effect on funct-
; ionality.
;
; B) Expanded the program notes.
;
; 2014/06/08 A) Special version with VT-100 support.
;———————————————————————————————————————————————————————————————————————————————
;
;
; COMMENT ABBREVIATIONS
; —————————————————————————————————————
; BCD binary-coded decimal
; DP direct page or page zero
; EOF end-of-field
; EOI end-of-input
; LSB least significant byte/bit
; LSD least significant digit
; LSN least significant nybble
; LSW least significant word
; MPU microprocessor
; MSB most significant byte/bit
; MSD most significant digit
; MSN most significant nybble
; MSW most-significant word
; RAM random access memory
; WS whitespace, i.e., blanks & tabs
; —————————————————————————————————————
; A word is defined as 16 bits.
;
; MPU REGISTER SYMBOLS
; ———————————————————————
; .A accumulator LSB
; .B accumulator MSB
; .C 16 bit accumulator
; .X X-index
; .Y Y-index
; DB data bank
; DP direct page
; PB program bank
; PC program counter
; SP stack pointer
; SR MPU status
; ———————————————————————
;
; MPU STATUS REGISTER SYMBOLS
; ———————————————————————————
; C carry
; D decimal mode
; I maskable interrupts
; m accumulator/memory size
; N result negative
; V sign overflow
; x index registers size
; Z result zero
; ———————————————————————————
;
;===============================================================================
;
;SYSTEM INTERFACE DEFINITIONS
;
; ——————————————————————————————————————————————————————————————————
; This section defines the interface between Supermon 816 & the host
; system. Change these definitions to suit your system, but do not
; change any label names. All definitions must have valid values in
; order to assemble & run Supermon 816.
; ——————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————
_origin_ =$008000 ;assembly address...
;
; Set _ORIGIN_ to Supermon 816's desired assembly address.
; ————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
vecexit =$00ffff ;exit to environment address...
;
; Set VECEXIT to where Supermon 816 should go when it exits. Supermon 816
; will do a JML (long jump) to this address, which means VECEXIT must be a
; 24 bit address.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
vecbrki =$0000 ;BRK handler indirect vector...
;
; Supermon 816 will modify this vector so that execution of a BRK instruc-
; tion is intercepted & the registers are captured. Your BRK front end
; should jump through this vector after pushing the registers as follows:
;
; phb ;save DB
; phd ;save DP
; rep #%00110000 ;16 bit registers
; pha
; phx
; phy
; jmp (vecbrki) ;indirect vector
;
; When a G or J command is issued, the above sequence will be reversed be-
; fore a jump is made to the code to be executed. Upon exit from Supermon
; 816, the original address at VECBRKI will be restored. Note that this
; vector must be in bank $00.
;
; If your BRK front end doesn't conform to the above you will have to mod-
; ify Supermon 816 to accommodate the differences. The most likely needed
; changes will be in the order in which registers are pushed to the stack.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
hwstack =$00ffff ;top of hardware stack...
;
; Supermon 816 initializes the stack pointer to this address when the cold
; start at JMON is called to enter the monitor. The stack pointer will be
; undisturbed when entry into Supermon 816 is through JMONBRK.
;
; JMON & JMONBRK are defined in the Supermon 816's jump table.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
zeropage =$00 ;Supermon 816's direct page...
;
; Supermon 816 uses direct page starting at this address. Be sure that no
; conflict occurs with other software, as an overwrite of any of these
; locations may be fatal to Supermon 816.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
getcha =$00ffff ;get datum from TIA-232 channel A...
; GETCHA refers to an operating system API call that returns a datum in
; the 8 bit accumulator. Supermon 816 assumes that GETCHA is a non-block-
; ing subroutine & returns with carry clear to indicate that a datum is in
; .A, or with carry set to indicate that no datum was available. GETCHA
; will be called with a JSR instruction.
;
; Supermon 816 expects .X & .Y to be preserved upon return from GETCHA.
; You may have to modify Supermon 816 at all calls to GETCHA if your "get
; datum" routine works differently than described.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
getchb =$00ffff ;get datum from TIA-232 channel B...
;
; GETCHB refers to an operating system API call that returns a datum in
; the 8 bit accumulator. Supermon 816 assumes that GETCHB is a non-block-
; ing subroutine & returns with carry clear to indicate that a datum is in
; .A, or with carry set to indicate that no datum was available. GETCHB
; will be called with a JSR instruction.
;
; Supermon 816 expects .X & .Y to be preserved upon return from GETCHB.
; You may have to modify Supermon 816 at all calls to GETCHB if your "get
; datum" routine works differently than described.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
putcha =$00ffff ;print character on console...
;
; PUTCHA refers to an operating system API call that prints a character to
; the console screen. The character to be printed will be in .A, which
; will be set to 8-bit width. Supermon 816 assumes that PUTCHA will block
; until the character can be processed. PUTCHA will be called with a JSR
; instruction.
;
; Supermon 816 expects .X & .Y to be preserved upon return from PUTCHA.
; You may have to modify Supermon 816 at all calls to PUTCHA if your "put
; character" routine works differently than described.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
chanbctl =$00ffff ;TIA-232 channel B control...
;
; CHANBCTL refers to an operating system API call that enables or disables
; the TIA-232 channel B receiver. If this call is not present in the tar-
; get system's API then it will be necessary to comment out references to
; it. CHANBCTL is a BCS Technology Limited NXP driver feature. Refer to
; the function header comments for details.
; ————————————————————————————————————————————————————————————————————————
;
; ————————————————————————————————————————————————————————————————————————
stopkey =$03 ;display abort key...
;
; Supermon 816 will poll for a "stop key" during display operations, such
; as code disassembly & memory dumps, so as to abort further processing &
; return to the command prompt. STOPKEY must be defined with the ASCII
; value that the "stop key" will emit when typed. The polling is via a
; call to GETCHA (described above). The default STOPKEY definition of $03
; is for ASCII <ETX> or [Ctrl-C]. An alternative definition could be $1B,
; which is ASCII <ESC> or [ESC].
; ————————————————————————————————————————————————————————————————————————
;
ibuffer =$008000 ;input buffer &...
auxbuf =ibuffer+s_ibuf+s_byte ;auxiliary buffer...
;
; ———————————————————————————————————————————————————————————————————————
; Supermon 816 will use the above definitions for workspace in various
; ways. These buffers may be located anywhere in RAM that is convenient.
; The buffers are stateless, which means that unless Supermon 816 has
; control of your system they may be overwritten without consequence.
; ———————————————————————————————————————————————————————————————————————
;
;===============================================================================
;
;ASCII CONTROL DEFINITIONS (menmonic order)
;
a_bel =$07 ;<BEL> alert/ring bell
a_bs =$08 ;<BS> backspace
a_cr =$0d ;<CR> carriage return
a_del =$7f ;<DEL> delete
a_esc =$1b ;<ESC> escape
a_ht =$09 ;<HT> horizontal tabulation
a_lf =$0a ;<LF> linefeed
;
;
; miscellaneous (description order)...
;
a_blank =' ' ;blank (whitespace)
a_asclch ='z' ;end of lowercase ASCII
a_lctouc =%01011111 ;LC to UC conversion mask
a_asclcl ='a' ;start of lowercase ASCII
;
;===============================================================================
;
;GLOBAL ATOMIC CONSTANTS
;
;
; data type sizes...
;
s_byte =1 ;byte
s_word =2 ;word (16 bits)
s_xword =3 ;extended word (24 bits)
s_dword =4 ;double word (32 bits)
s_rampag =$0100 ;65xx RAM page
;
;
; data type sizes in bits...
;
s_bibyte =8 ;byte
s_bnybbl =4 ;nybble
;
;
; miscellaneous...
;
bitabs =$2c ;absolute BIT opcode
bitzp =$24 ;zero page BIT opcode
;
;===============================================================================
;
;W65C816S NATIVE MODE STATUS REGISTER DEFINITIONS
;
s_mpudbx =s_byte ;data bank size
s_mpudpx =s_word ;direct page size
s_mpupbx =s_byte ;program bank size
s_mpupcx =s_word ;program counter size
s_mpuspx =s_word ;stack pointer size
s_mpusrx =s_byte ;status size
;
;
; status register flags...
;
sr_car =%00000001 ;C
sr_zer =sr_car << 1 ;Z
sr_irq =sr_zer << 1 ;I
sr_bdm =sr_irq << 1 ;D
sr_ixw =sr_bdm << 1 ;x
sr_amw =sr_ixw << 1 ;m
sr_ovl =sr_amw << 1 ;V
sr_neg =sr_ovl << 1 ;N
;
; NVmxDIZC
; xxxxxxxx
; ||||||||
; |||||||+———> 1 = carry set/generated
; ||||||+————> 1 = result = zero
; |||||+—————> 1 = IRQs ignored
; ||||+——————> 0 = binary arithmetic mode
; |||| 1 = decimal arithmetic mode
; |||+———————> 0 = 16 bit index
; ||| 1 = 8 bit index
; ||+————————> 0 = 16 bit .A & memory
; || 1 = 8 bit .A & memory
; |+—————————> 1 = sign overflow
; +——————————> 1 = result = negative
;
;
; register size masks (used with REP & SEP)...
;
m_seta =sr_amw ;accumulator/memory
m_setx =sr_ixw ;index
m_setr =m_seta|m_setx ;accumulator/memory & index
;
;===============================================================================
;
;"SIZE-OF" CONSTANTS
;
s_addr =s_xword ;24 bit address
s_auxbuf =32 ;auxiliary buffer
s_ibuf =69 ;input buffer
s_mnemon =3 ;MPU ASCII mnemonic
s_mnepck =2 ;MPU encoded mnemonic
s_mvinst =3 ;MVN/MVP instruction
s_opcode =s_byte ;MPU opcode
s_oper =s_xword ;operand
s_pfac =s_dword ;primary math accumulator
s_sfac =s_dword+s_word ;secondary math accumulators
;
;===============================================================================
;
;"NUMBER-OF" CONSTANTS
;
n_dbytes =21 ;default disassembly bytes
n_dump =16 ;bytes per memory dump line
n_mbytes =s_rampag-1 ;default memory dump bytes
n_hccols =10 ;compare/hunt display columns
n_opcols =3*s_oper ;disassembly operand columns
n_opslsr =4 ;LSRs to extract instruction size
n_shfenc =5 ;shifts to encode/decode mnemonic
;
;===============================================================================
;
;NUMERIC CONVERSION CONSTANTS
;
a_hexdec ='A'-'9'-2 ;hex to decimal difference
c_bin ='%' ;binary prefix
c_dec ='+' ;decimal prefix
c_hex ='$' ;hexadecimal prefix
c_oct ='@' ;octal prefix
k_hex ='f' ;hex ASCII conversion
m_bits =s_pfac*s_bibyte ;operand bit size
m_cbits =s_sfac*s_bibyte ;workspace bit size
bcdumask =%00001111 ;isolate BCD units mask
btoamask =%00110000 ;binary to ASCII mask
;
;===============================================================================
;
;ASSEMBLER/DISASSEMBLER CONSTANTS
;
a_mnecvt ='?' ;encoded mnemonic conversion base
aimmaska =%00011111 ;.A immediate opcode test #1
aimmaskb =%00001001 ;.A immediate opcode test #2
asmprfx ='A' ;assemble code prefix
ascprmct =9 ;assembler prompt "size-of"
disprfx ='.' ;disassemble code prefix
flimmask =%11000000 ;force long immediate flag
opc_cpxi =$e0 ;CPX # opcode
opc_cpyi =$c0 ;CPY # opcode
opc_ldxi =$a2 ;LDX # opcode
opc_ldyi =$a0 ;LDY # opcode
opc_mvn =$54 ;MVN opcode
opc_mvp =$44 ;MVP opcode
opc_rep =$c2 ;REP opcode
opc_sep =$e2 ;SEP opcode
pfmxmask =sr_amw | sr_ixw ;MPU m & x flag bits mask
;
;
; assembler prompt buffer offsets...
;
apadrbkh =s_word ;instruction address bank MSN
apadrbkl =apadrbkh+s_byte ;instruction address bank LSN
apadrmbh =apadrbkl+s_byte ;instruction address MSB MSN
apadrmbl =apadrmbh+s_byte ;instruction address MSB LSN
apadrlbh =apadrmbl+s_byte ;instruction address LSB MSN
apadrlbl =apadrlbh+s_byte ;instruction address LSB LSN
;
;
; addressing mode preamble symbols...
;
amp_flim ='!' ;force long immediate
amp_imm ='#' ;immediate
amp_ind ='(' ;indirect
amp_indl ='[' ;indirect long
;
;
; addressing mode symbolic translation indices...
;
am_nam =%0000 ;no symbol
am_imm =%0001 ;#
am_adrx =%0010 ;<addr>,X
am_adry =%0011 ;<addr>,Y
am_ind =%0100 ;(<addr>)
am_indl =%0101 ;[<dp>]
am_indly =%0110 ;[<dp>],Y
am_indx =%0111 ;(<addr>,X)
am_indy =%1000 ;(<dp>),Y
am_stk =%1001 ;<offset>,S
am_stky =%1010 ;(<offset>,S),Y
am_move =%1011 ;<sbnk>,<dbnk>
;
;
; operand size translation indices...
;
ops0 =%0000 << 4 ;no operand
ops1 =%0001 << 4 ;8 bit operand
ops2 =%0010 << 4 ;16 bit operand
ops3 =%0011 << 4 ;24 bit operand
bop1 =%0101 << 4 ;8 bit relative branch
bop2 =%0110 << 4 ;16 bit relative branch
vops =%1001 << 4 ;8 or 16 bit operand
;
;
; operand size & addressing mode extraction masks...
;
amodmask =%00001111 ;addressing mode index
opsmask =%00110000 ;operand size
vopsmask =%11000000 ;BOPx & VOPS flag bits
;
;
; instruction mnemonic encoding...
;
mne_adc =$2144 ;ADC
mne_and =$2bc4 ;AND
mne_asl =$6d04 ;ASL
mne_bcc =$2106 ;BCC
mne_bcs =$a106 ;BCS
mne_beq =$9186 ;BEQ
mne_bit =$aa86 ;BIT
mne_bmi =$5386 ;BMI
mne_bne =$33c6 ;BNE
mne_bpl =$6c46 ;BPL
mne_bra =$14c6 ;BRA
mne_brk =$64c6 ;BRK
mne_brl =$6cc6 ;BRL
mne_bvc =$25c6 ;BVC
mne_bvs =$a5c6 ;BVS
mne_clc =$2348 ;CLC
mne_cld =$2b48 ;CLD
mne_cli =$5348 ;CLI
mne_clv =$bb48 ;CLV
mne_cmp =$8b88 ;CMP
mne_cop =$8c08 ;COP
mne_cpx =$cc48 ;CPX
mne_cpy =$d448 ;CPY
mne_dec =$218a ;DEC
mne_dex =$c98a ;DEX
mne_dey =$d18a ;DEY
mne_eor =$9c0c ;EOR
mne_inc =$23d4 ;INC
mne_inx =$cbd4 ;INX
mne_iny =$d3d4 ;INY
mne_jml =$6b96 ;JML
mne_jmp =$8b96 ;JMP
mne_jsl =$6d16 ;JSL
mne_jsr =$9d16 ;JSR
mne_lda =$115a ;LDA
mne_ldx =$c95a ;LDX
mne_ldy =$d15a ;LDY
mne_lsr =$9d1a ;LSR
mne_mvn =$7ddc ;MVN
mne_mvp =$8ddc ;MVP
mne_nop =$8c1e ;NOP
mne_ora =$14e0 ;ORA
mne_pea =$11a2 ;PEA
mne_pei =$51a2 ;PEI
mne_per =$99a2 ;PER
mne_pha =$1262 ;PHA
mne_phb =$1a62 ;PHB
mne_phd =$2a62 ;PHD
mne_phk =$6262 ;PHK
mne_php =$8a62 ;PHP
mne_phx =$ca62 ;PHX
mne_phy =$d262 ;PHY
mne_pla =$1362 ;PLA
mne_plb =$1b62 ;PLB
mne_pld =$2b62 ;PLD
mne_plp =$8b62 ;PLP
mne_plx =$cb62 ;PLX
mne_ply =$d362 ;PLY
mne_rep =$89a6 ;REP
mne_rol =$6c26 ;ROL
mne_ror =$9c26 ;ROR
mne_rti =$5566 ;RTI
mne_rtl =$6d66 ;RTL
mne_rts =$a566 ;RTS
mne_sbc =$20e8 ;SBC
mne_sec =$21a8 ;SEC
mne_sed =$29a8 ;SED
mne_sei =$51a8 ;SEI
mne_sep =$89a8 ;SEP
mne_sta =$1568 ;STA
mne_stp =$8d68 ;STP
mne_stx =$cd68 ;STX
mne_sty =$d568 ;STY
mne_stz =$dd68 ;STZ
mne_tax =$c8aa ;TAX
mne_tay =$d0aa ;TAY
mne_tcd =$292a ;TCD
mne_tcs =$a12a ;TCS
mne_tdc =$216a ;TDC
mne_trb =$1cea ;TRB
mne_tsb =$1d2a ;TSB
mne_tsc =$252a ;TSC
mne_tsx =$cd2a ;TSX
mne_txa =$166a ;TXA
mne_txs =$a66a ;TXS
mne_txy =$d66a ;TXY
mne_tya =$16aa ;TYA
mne_tyx =$ceaa ;TYX
mne_wai =$50b0 ;WAI
mne_wdm =$7170 ;WDM
mne_xba =$10f2 ;XBA
mne_xce =$3132 ;XCE
;
;
; encoded instruction mnemonic indices...
;
mne_adcx =16 ;ADC
mne_andx =29 ;AND
mne_aslx =44 ;ASL
mne_bccx =15 ;BCC
mne_bcsx =65 ;BCS
mne_beqx =59 ;BEQ
mne_bitx =70 ;BIT
mne_bmix =36 ;BMI
mne_bnex =31 ;BNE
mne_bplx =42 ;BPL
mne_brax =5 ;BRA
mne_brkx =39 ;BRK
mne_brlx =43 ;BRL
mne_bvcx =23 ;BVC
mne_bvsx =68 ;BVS
mne_clcx =20 ;CLC
mne_cldx =27 ;CLD
mne_clix =35 ;CLI
mne_clvx =71 ;CLV
mne_cmpx =53 ;CMP
mne_copx =55 ;COP
mne_cpxx =78 ;CPX
mne_cpyx =88 ;CPY
mne_decx =18 ;DEC
mne_dexx =74 ;DEX
mne_deyx =84 ;DEY
mne_eorx =61 ;EOR
mne_incx =21 ;INC
mne_inxx =77 ;INX
mne_inyx =87 ;INY
mne_jmlx =40 ;JML
mne_jmpx =54 ;JMP
mne_jslx =45 ;JSL
mne_jsrx =63 ;JSR
mne_ldax =1 ;LDA
mne_ldxx =73 ;LDX
mne_ldyx =83 ;LDY
mne_lsrx =64 ;LSR
mne_mvnx =48 ;MVN
mne_mvpx =58 ;MVP
mne_nopx =56 ;NOP
mne_orax =6 ;ORA
mne_peax =2 ;PEA
mne_peix =33 ;PEI
mne_perx =60 ;PER
mne_phax =3 ;PHA
mne_phbx =10 ;PHB
mne_phdx =26 ;PHD
mne_phkx =38 ;PHK
mne_phpx =51 ;PHP
mne_phxx =75 ;PHX
mne_phyx =85 ;PHY
mne_plax =4 ;PLA
mne_plbx =11 ;PLB
mne_pldx =28 ;PLD
mne_plpx =52 ;PLP
mne_plxx =76 ;PLX
mne_plyx =86 ;PLY
mne_repx =49 ;REP
mne_rolx =41 ;ROL
mne_rorx =62 ;ROR
mne_rtix =37 ;RTI
mne_rtlx =46 ;RTL
mne_rtsx =67 ;RTS
mne_sbcx =14 ;SBC
mne_secx =19 ;SEC
mne_sedx =25 ;SED
mne_seix =34 ;SEI
mne_sepx =50 ;SEP
mne_stax =7 ;STA
mne_stpx =57 ;STP
mne_stxx =80 ;STX
mne_styx =89 ;STY
mne_stzx =91 ;STZ
mne_taxx =72 ;TAX
mne_tayx =82 ;TAY
mne_tcdx =24 ;TCD
mne_tcsx =66 ;TCS
mne_tdcx =17 ;TDC
mne_trbx =12 ;TRB
mne_tsbx =13 ;TSB
mne_tscx =22 ;TSC
mne_tsxx =79 ;TSX
mne_txax =8 ;TXA
mne_txsx =69 ;TXS
mne_txyx =90 ;TXY
mne_tyax =9 ;TYA
mne_tyxx =81 ;TYX
mne_waix =32 ;WAI
mne_wdmx =47 ;WDM
mne_xbax =0 ;XBA
mne_xcex =30 ;XCE
;
;===============================================================================
;
;MISCELLANEOUS CONSTANTS
;
halftab =4 ;1/2 tabulation spacing
memprfx ='>' ;memory dump prefix
memsepch =':' ;memory dump separator
memsubch ='.' ;memory dump non-print char
srinit =%00000000 ;SR initialization value
;
;===============================================================================
;
;DIRECT PAGE STORAGE
;
reg_pbx =zeropage ;PB shadow
reg_pcx =reg_pbx+s_mpupbx ;PC shadow
reg_srx =reg_pcx+s_mpupcx ;SR shadow
reg_ax =reg_srx+s_mpusrx ;.C shadow
reg_xx =reg_ax+s_word ;.X shadow
reg_yx =reg_xx+s_word ;.Y shadow
reg_spx =reg_yx+s_word ;SP shadow
reg_dpx =reg_spx+s_mpuspx ;DP shadow
reg_dbx =reg_dpx+s_mpudpx ;DB shadow
;
;
; general workspace...
;
addra =reg_dbx+s_mpudbx ;address #1
addrb =addra+s_addr ;address #2
faca =addrb+s_addr ;primary accumulator
facax =faca+s_pfac ;extended primary accumulator
facb =facax+s_pfac ;secondary accumulator
facc =facb+s_sfac ;tertiary accumulator
operand =facc+s_sfac ;instruction operand
auxbufix =operand+s_oper ;auxiliary buffer index
ibufidx =auxbufix+s_byte ;input buffer index
bitsdig =ibufidx+s_byte ;bits per numeral
numeral =bitsdig+s_byte ;numeral buffer
radix =numeral+s_byte ;radix index
admodidx =radix+s_byte ;addressing mode index
charcnt =admodidx+s_byte ;character counter
instsize =charcnt+s_word ;instruction size
mnepck =instsize+s_word ;encoded mnemonic
opcode =mnepck+s_mnepck ;current opcode
status =opcode+s_byte ;I/O status flag
xrtemp =status+s_byte ;temp .X storage
eopsize =xrtemp+s_byte ;entered operand size
flimflag =eopsize+s_byte ;forced long immediate...
;
; xx000000
; ||
; |+—————————> 0: .X/.Y = 8 bits
; | 1: .X/.Y = 18 bits
; +——————————> 0: .A = 8 bits
; 1: .A = 16 bits
;
; ————————————————————————————————————————————————————————————————————————
; During assembly, FLIMFLAG indicates the operand size used with an immed-
; iate mode instruction, thus causing the following disassembly to display
; the assembled operand size. During disassembly, FLIMFLAG will mirror
; the effect of the most recent REP or SEP instruction.
; ————————————————————————————————————————————————————————————————————————
;
iopsize =flimflag+s_byte ;operand size
range =iopsize+s_byte ;allowable radix range
vopsflag =range+s_byte ;VOPS & ROPS mode bits
;
;
; copy/fill workspace (overlaps some of the above)...
;
mcftwork =faca ;start of copy/fill code
mcftopc =mcftwork+s_byte ;instruction opcode
mcftbnk =mcftopc+s_byte ;banks
;
;===============================================================================
;
;VT-100 CONSOLE DISPLAY CONTROL MACROS
;
; ———————————————————————————————————————————————————————————————————————
; The following macros execute terminal control procedures that perform
; such tasks as clearing the screen, switching between normal & reverse
; video, etc. These macros are for VT-100 & compatible displays. Only
; the functions needed by Supermon 816 are included.
; ———————————————————————————————————————————————————————————————————————
;
_csi_ .macro ;Control Sequence Introducer
.byte a_esc, "["
.endm
;
;
; clearing data...
;
bs .macro ;destructive backspace
.byte a_bs," ",a_bs
.endm
;
cl .macro ;clear to end of line
_csi_
.byte "0K"
.endm
;
;
; cursor control...
;
cn .macro ;cursor on
_csi_
.byte "?25h"
.endm
;
co .macro ;cursor off
_csi_
.byte "?25l"
.endm
;
cr .macro ;carriage return
.byte a_cr
.endm
;
lf .macro ;carriage return/line feed
.byte a_cr,a_lf
.endm
;
;
; display attributes...
;
bf .macro ;reverse foreground
_csi_
.byte "7m"
.endm
;
sf .macro ;normal foreground
_csi_
.byte "0m"
.endm
;
;
; miscellaneous control...
;
rb .macro ;ring "bell"
.byte a_bel
.endm
;
;===============================================================================
;
;SUPERMON 816 JUMP TABLE
;
*=_origin_
;
JMON bra mon ;cold start entry
JMONBRK bra monbrk ;software interrupt intercept
;
vecbrkia .word 0 ;system indirect BRK vector
;
;===============================================================================
;
;mon: SUPERMON 816 COLD START
;
mon rep #m_seta ;16-bit .A
lda vecbrki ;BRK vector
cmp !#jmonbrk ;pointing at monitor?
beq monreg ;yes, ignore cold start
;
sta vecbrkia ;save vector for exit
lda !#jmonbrk ;Supermon 816 intercepts...
sta vecbrki ;BRK handler
sep #m_setr ;8 bit registers
ldx #vopsflag-reg_pbx
;
.0000010 stz reg_pbx,x ;clear DP storage
dex
bpl .0000010
;
;
; initialize register shadows...
;
lda #srinit
sta reg_srx ;status register
rep #m_seta
lda !#hwstack ;top of hardware stack
tcs ;set SP...
;
; —-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-
; The stack pointer initialization is an optional step
; that could be removed if Supermon 816 is made part
; of system firware.
; —-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-
;
tdc ;get & save DP...
sta reg_dpx ;into shadow register
lda !#0 ;flush .B
sep #m_seta
phk
pla ;capture PB &...
sta reg_pbx ;set