OpenCores
URL https://opencores.org/ocsvn/rtf65002/rtf65002/trunk

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [software/] [asm/] [supermon816.asm] - Blame information for rev 40

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 40 robfinch
;* ——————————————————————————————————————————————————————————————————————————————— *
2
;       .opt proc65c02,caseinsensitive
3
        cpu     W65C02
4
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5
;*                                                                                 *
6
;*      SUPERMON 816 MACHINE LANGUAGE MONITOR FOR THE W65C816S MICROPROCESSOR      *
7
;* ——————————————————————————————————————————————————————————————————————————————— *
8
;*      Copyright ©1991-2014 by BCS Technology Limited.  All rights reserved.      *
9
;*                                                                                 *
10
;* Permission is hereby granted to use, copy, modify and distribute this software, *
11
;* provided this copyright notice remains in the source code and  proper  attribu- *
12
;* tion is given.  Redistribution, regardless of form, must be at no charge to the *
13
;* end  user.  This code or any part thereof, including any derivation, MAY NOT be *
14
;* incorporated into any package intended for sale,  unless written permission has *
15
;* been given by the copyright holder.                                             *
16
;*                                                                                 *
17
;* THERE IS NO WARRANTY OF ANY KIND WITH THIS SOFTWARE.  The user assumes all risk *
18
;* in connection with the incorporation of this software into any system.          *
19
;* ——————————————————————————————————————————————————————————————————————————————— *
20
;* Supermon 816 is a salute to Jim Butterfield, who passed away on June 29, 2007.  *
21
;*                                                                                 *
22
;* Jim, who was the unofficial  spokesman for  Commodore  International during the *
23
;* heyday of the company's 8 bit supremacy, scratch-developed the Supermon machine *
24
;* language monitor for the PET & CBM computers.   When the best-selling Commodore *
25
;* 64 was introduced, Jim adapted his software to the new machine & gave the adap- *
26
;* tation the name Supermon 64.   Commodore  subsequently  integrated a customized *
27
;* version of Supermon 64 into the C-128 to act as the resident M/L monitor.       *
28
;*                                                                                 *
29
;* Although Supermon 816 is not an adaptation of Supermon 64,  it was  decided  to *
30
;* keep the Supermon name alive, since Supermon 816's general operation & user in- *
31
;* terface is similar to that of Supermon 64.   Supermon 816 is 100 percent native *
32
;* mode 65C816 code & was developed from a blank canvas.                           *
33
;* ——————————————————————————————————————————————————————————————————————————————— *
34
;* This version customized for the RTF65002 test system                            *
35
;* Finitron.ca                                                                     *
36
;* ——————————————————————————————————————————————————————————————————————————————— *
37
;* Supermon 816 is a full featured monitor and supports the following operations:  *
38
;*                                                                                 *
39
;*     A — Assemble code                                                           *
40
;*     C — Compare memory regions                                                  *
41
;*     D — Disassemble code                                                        *
42
;*     F — Fill memory region (cannot span banks)                                  *
43
;*     G — Execute code (stops at BRK)                                             *
44
;*     H — Search (hunt) memory region                                             *
45
;*     J — Execute code as a subroutine (stops at BRK or RTS)                      *
46
;*     M — Dump & display memory range                                             *
47
;*     R — Dump & display 65C816 registers                                         *
48
;*     T — Copy (transfer) memory region                                           *
49
;*     X — Exit Supermon 816 & return to operating environment                     *
50
;*     > — Modify up to 32 bytes of memory                                         *
51
;*     ; — Modify 65C816 registers                                                 *
52
;*                                                                                 *
53
;* Supermon 816 accepts binary (%), octal (@), decimal (+) and hexadecimal ($) as  *
54
;* input for numeric parameters.  Additionally, the H and > operations accept an   *
55
;* ASCII string in place of numeric values by preceding the string with ', e.g.:   *
56
;*                                                                                 *
57
;*     h 042000 042FFF 'BCS Technology Limited                                     *
58
;*                                                                                 *
59
;* If no radix symbol is entered hex is assumed.                                   *
60
;*                                                                                 *
61
;* Numeric conversion is also available.  For example, typing:                     *
62
;*                                                                                 *
63
;*     +1234567                                                                *
64
;*                                                                                 *
65
;* will display:                                                                   *
66
;*                                                                                 *
67
;*         $12D687                                                                 *
68
;*         +1234567                                                                *
69
;*         @04553207                                                               *
70
;*         %100101101011010000111                                                  *
71
;*                                                                                 *
72
;* In the above example,  means the console keyboard's return or enter key.    *
73
;*                                                                                 *
74
;* All numeric values are internally processed as 32 bit unsigned integers.  Addr- *
75
;* esses may be entered as 8, 16 or 24 bit values.  During instruction assembly,   *
76
;* immediate mode operands may be forced to 16 bits by preceding the operand with  *
77
;* an exclamation point if the instruction can accept a 16 bit operand, e.g.:      *
78
;*                                                                                 *
79
;*     a 1f2000 lda !#4                                                            *
80
;*                                                                                 *
81
;* The above will assemble as:                                                     *
82
;*                                                                                 *
83
;*     A 1F2000  A9 04 00     LDA #$0004                                           *
84
;*                                                                                 *
85
;* Entering:                                                                       *
86
;*                                                                                 *
87
;*     a 1f2000 ldx !#+157                                                         *
88
;*                                                                                 *
89
;* will assemble as:                                                               *
90
;*                                                                                 *
91
;*     A 1F2000  A2 9D 00     LDX #$009D                                           *
92
;*                                                                                 *
93
;* Absent the ! in the operand field, the above would have been assembled as:      *
94
;*                                                                                 *
95
;*     A 1F2000  A2 9D        LDX #$9D                                             *
96
;*                                                                                 *
97
;* If an immediate mode operand is greater than $FF assembly of a 16 bit operand   *
98
;* is implied.                                                                     *
99
;* ——————————————————————————————————————————————————————————————————————————————— *
100
;* A Note on the PEA & PEI Instructions                                            *
101
;* ————————————————————————————————————                                            *
102
;*                                                                                 *
103
;* The Eyes and Lichty programming manual uses the following syntax for the PEA    *
104
;* and PEI instructions:                                                           *
105
;*                                                                                 *
106
;*     PEA                                                                *
107
;*     PEI ()                                                             *
108
;*                                                                                 *
109
;* The WDC data sheet that was published at the time of the 65C816's release in    *
110
;* 1984 does not indicate a recommended or preferred syntax for any of the above   *
111
;* instructions.  PEA pushes its operand to the stack and hence operates like any  *
112
;* other immediate mode instruction, in that the operand is the data (however, PEA *
113
;* doesn't affect the status register).  Similarly, PEI pushes the 16 bit value    *
114
;* stored at  and +1, and hence operates like any other direct   *
115
;* (zero) page instruction, again without affecting the status register.           *
116
;*                                                                                 *
117
;* BCS Technology Limited is of the opinion that the developer of the ORCA/M as-   *
118
;* sembler, which is the assembler referred to in the Eyes and Lichty manual, mis- *
119
;* understood how PEA and PEI behave during runtime, and hence chose an incorrect  *
120
;* syntax for these two instructions.  This error was subsequently carried forward *
121
;* by Eyes and Lichty.                                                             *
122
;*                                                                                 *
123
;* Supermon 816's assembler uses the following syntax for PEA and PEI:             *
124
;*                                                                                 *
125
;*     PEA #                                                              *
126
;*     PEI                                                                *
127
;*                                                                                 *
128
;* The operand for PEA is treated as a 16 bit value, even if entered as an 8 bit   *
129
;* value.  The operand for PEI must be 8 bits.                                     *
130
;*                                                                                 *
131
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
132
;
133
;       * * * * * * * * * * * *
134
;       * VERSION INFORMATION *
135
;       * * * * * * * * * * * *
136
;
137
softvers .macro                ;software version — change with each revision...
138
         .byte "1"             ;major
139
         .byte "."
140
         .byte "0"             ;minor
141
         .byte "."
142
         .byte "1"             ;revision
143
         .endm
144
;
145
;REVISION TABLE
146
;
147
;Ver  Rev Date    Description
148
;———————————————————————————————————————————————————————————————————————————————
149
;1.0  2013/11/01  A) Original derived from the POC V1.1 single-board computer
150
;                    firmware.
151
;     2013/11/04  A) Fixed a problem where the B-accumulator wasn't always being
152
;                    be copied to shadow storage after return from execution of
153
;                    a J command.
154
;———————————————————————————————————————————————————————————————————————————————
155
;
156
;
157
;               COMMENT ABBREVIATIONS
158
;       ————————————————————————————————————————————————————
159
;         BCD   binary-coded decimal
160
;          DP   direct page or page zero
161
;         EOF   end-of-field
162
;         EOI   end-of-input
163
;         LSB   least significant byte/bit
164
;         LSD   least significant digit
165
;         LSN   least significant nybble
166
;         LSW   least significant word
167
;         MPU   microprocessor
168
;         MSB   most significant byte/bit
169
;         MSD   most significant digit
170
;         MSN   most significant nybble
171
;         MSW   most-significant word
172
;         RAM   random access memory
173
;          WS   whitespace, i.e., blanks & horizontal tabs
174
;       ————————————————————————————————————————————————————
175
;       A word is defined as 16 bits.
176
;
177
;          MPU REGISTER SYMBOLS
178
;       ——————————————————————————
179
;          .A   accumulator LSB
180
;          .B   accumulator MSB
181
;          .C   16 bit accumulator
182
;          .X   X-index
183
;          .Y   Y-index
184
;          DB   data bank
185
;          DP   direct page
186
;          PB   program bank
187
;          PC   program counter
188
;          SP   stack pointer
189
;          SR   MPU status
190
;       ————————————————————————————
191
;
192
;         MPU STATUS REGISTER SYMBOLS
193
;       ———————————————————————————————
194
;           C   carry
195
;           D   decimal mode
196
;           I   maskable interrupts
197
;           m   accumulator/memory size
198
;           N   result negative
199
;           V   sign overflow
200
;           x   index registers size
201
;           Z   result zero
202
;       ———————————————————————————————
203
;
204
;================================================================================
205
;
206
;SYSTEM INTERFACE DEFINITIONS
207
;
208
;       ——————————————————————————————————————————————————————————————————
209
;       This section defines the interface between Supermon 816 & the host
210
;       system.   Change these definitions to suit your system, but do not
211
;       change any label names.  All definitions must have valid values in
212
;       order to assemble Supermon 816.
213
;       ——————————————————————————————————————————————————————————————————
214
;
215
;       ————————————————————————————————————————————————————————
216
_origin_ =$008000              ;assembly address...
217
;
218
;       Set _ORIGIN_ to Supermon 816's desired assembly address.
219
;       ————————————————————————————————————————————————————————
220
;
221
;       ————————————————————————————————————————————————————————————————————————
222
vecexit  =$00F403              ;exit to environment address...
223
;
224
;       Set VECEXIT to where Supermon 816 should go when it exits.  Supermon 816
225
;       will do a JML (long jump) to this address, which means VECEXIT must be a
226
;       24 bit address.
227
;       ————————————————————————————————————————————————————————————————————————
228
;
229
;       ————————————————————————————————————————————————————————————————————————
230
vecbrki  =$0102                ;BRK handler indirect vector...
231
;
232
;       Supermon 816 will modify this vector so that execution of a BRK instruc-
233
;       tion is intercepted & the registers  are  captured.   Your BRK front end
234
;       should jump through this vector after pushing the registers as follows:
235
;
236
;                phb                   ;save DB
237
;                phd                   ;save DP
238
;                rep #%00110000        ;16 bit registers
239
;                pha
240
;                phx
241
;                phy
242
;                jmp (vecbrki)         ;indirect vector
243
;
244
;       When a G or J command is issued, the above sequence will be reversed be-
245
;       fore a jump is made to the code to be executed.  Upon exit from Supermon
246
;       816, the original address at VECBRKI will be restored.
247
;
248
;       If your BRK front end doesn't conform to the above you will have to mod-
249
;       ify Supermon 816 to accommodate the differences.  The most likely needed
250
;       changes will be in the order in which registers are pushed to the stack.
251
;       ————————————————————————————————————————————————————————————————————————
252
;
253
;       ————————————————————————————————————————————————————————————————————————
254
hwstack  =$3fff                ;top of hardware stack...
255
;
256
;       Supermon 816 initializes the stack pointer to this address when the cold
257
;       start at MONCOLD is called to enter the monitor.  The stack pointer will
258
;       be undisturbed when entry into Supermon 816 is through JMONBRK (see jump
259
;       table definitions).
260
;       ————————————————————————————————————————————————————————————————————————
261
;
262
;       ————————————————————————————————————————————————————————————————————————
263
zeropage =$80                  ;Supermon 816's direct page...
264
;
265
;       Supermon 816 uses direct page starting at this address.  Be sure that no
266
;       conflict occurs with other software.
267
;       ————————————————————————————————————————————————————————————————————————
268
;
269
;       ————————————————————————————————————————————————————————————————————————
270
getcha   =$F400                ;get keystroke from console...
271
;
272
;       GETCHA refers to an operating system API call that returns a keystroke
273
;       in the 8 bit accumulator.  Supermon 816  assumes that GETCHA is a non-
274
;       blocking subroutine & returns with carry clear to indicate that a key-
275
;       stroke is in .A, or with carry set to indicate that no keystroke was
276
;       available.  GETCHA will be called with a JSR instruction.
277
;
278
;       Supermon 816 expects .X & .Y to be preserved upon return from GETCHA.
279
;       You may have to modify Supermon 816 at all calls to GETCHA if your "get
280
;       keystroke" routine works differently than described.
281
;       ————————————————————————————————————————————————————————————————————————
282
;
283
;       ————————————————————————————————————————————————————————————————————————
284
putcha   =$F406                ;print character on console...
285
;
286
;       PUTCHA refers to an operating system API call that prints a character to
287
;       the console screen.  The character to be printed will be in .A, which
288
;       will be set to 8-bit width.  Supermon 816 assumes that PUTCHA will block
289
;       until the character can be processed.  PUTCHA will be called with a JSR
290
;       instructions.
291
;
292
;       Supermon 816 expects .X & .Y to be preserved upon return from PUTCHA.
293
;       You may have to modify Supermon 816 at all calls to PUTCHA if your "put
294
;       character" routine works differently than described.
295
;       ————————————————————————————————————————————————————————————————————————
296
;
297
;       ————————————————————————————————————————————————————————————————————————
298
stopkey  =$03                  ;display abort key...
299
;
300
;       Supermon 816 will poll for a "stop key" during display operations, such
301
;       as code disassembly & memory dumps, so as to abort further processing &
302
;       return to the command prompt.  STOPKEY must be defined with the ASCII
303
;       value that the "stop key" will emit when typed.  The polling is via a
304
;       call to GETCHA (described above).  The default STOPKEY definition of $03
305
;       is for ASCII  or [Ctrl-C].
306
;       ————————————————————————————————————————————————————————————————————————
307
;
308
ibuffer  =$000200               ;input buffer &...
309
auxbuf   =ibuffer+s_ibuf+s_byte ;auxiliary buffer...
310
;
311
;       ————————————————————————————————————————————————————————————————————————
312
;       Supermon 816 will use the above definitions for input buffers.  These
313
;       buffers may be located anywhere in RAM that is convenient.  The buffers
314
;       are stateless, which means that unless Supermon 816 has control of your
315
;       system, they may be overwritten without consequence.
316
;       ————————————————————————————————————————————————————————————————————————
317
;
318
;================================================================================
319
;
320
;W65C816S INSTRUCTION SYNTHESIS MACROS —— !!!!! DO NOT EDIT !!!!!
321
;
322
_asm24_  .macro .ad
323
         .byte <.ad,>.ad,.ad >> 16
324
         .endm
325
;
326
brl      .macro .ad
327
.ba      =*+3
328
         .byte $82
329
         .word .ad-.ba
330
         .endm
331
;
332
; jml is supported for the RTF65002 in 65c02 mode. And the opcode is supported
333
; by the assembler.
334
;jml      .macro .ad
335
; ;        .byte $5c
336
;         _asm24_ .ad
337
;         .endm
338
;
339
mvn      .macro .s,.d
340
         .byte $54,.d,.s
341
         .endm
342
;
343
mvp      .macro .s,.d
344
         .byte $44,.d,.s
345
         .endm
346
;
347
pea      .macro .op
348
         .byte $f4
349
         .word .op
350
         .endm
351
;
352
phb      .macro
353
         .byte $8b
354
         .endm
355
;
356
phk      .macro
357
         .byte $4b
358
         .endm
359
;
360
plb      .macro
361
         .byte $ab
362
         .endm
363
;
364
rep      .macro .op
365
         .byte $c2,.op
366
         .endm
367
;
368
sep      .macro .op
369
         .byte $e2,.op
370
         .endm
371
;
372
tcd      .macro
373
         .byte $5b
374
         .endm
375
;
376
tcs      .macro
377
         .byte $1b
378
         .endm
379
;
380
tdc      .macro
381
         .byte $7b
382
         .endm
383
;
384
tsc      .macro
385
         .byte $3b
386
         .endm
387
;
388
txy      .macro
389
         .byte $9b
390
         .endm
391
;
392
tyx      .macro
393
         .byte $bb
394
         .endm
395
;
396
wai      .macro
397
         .byte $cb
398
         .endm
399
;
400
xba      .macro
401
         .byte $eb
402
         .endm
403
;
404
adcw     .macro .op
405
         adc #<.op
406
         .byte >.op
407
         .endm
408
;
409
andw     .macro .op
410
         and #<.op
411
         .byte >.op
412
         .endm
413
;
414
bitw     .macro .op
415
         bit #<.op
416
         .byte >.op
417
         .endm
418
;
419
cmpw     .macro .op
420
         cmp #<.op
421
         .byte >.op
422
         .endm
423
;
424
cpxw     .macro .op
425
         cpx #<.op
426
         .byte >.op
427
         .endm
428
;
429
cpyw     .macro .op
430
         cpy #<.op
431
         .byte >.op
432
         .endm
433
;
434
eorw     .macro .op
435
         eor #<.op
436
         .byte >.op
437
         .endm
438
;
439
ldaw     .macro .op
440
         lda #<.op
441
         .byte >.op
442
         .endm
443
;
444
ldxw     .macro .op
445
         ldx #<.op
446
         .byte >.op
447
         .endm
448
;
449
ldyw     .macro .op
450
         ldy #<.op
451
         .byte >.op
452
         .endm
453
;
454
oraw     .macro .op
455
         ora #<.op
456
         .byte >.op
457
         .endm
458
;
459
sbcw     .macro .op
460
         sbc #<.op
461
         .byte >.op
462
         .endm
463
;
464
ldalx    .macro .ad
465
         .byte $bf
466
         _asm24_ .ad
467
         .endm
468
;
469
adcil    .macro .ad
470
         .byte $67,.ad
471
         .endm
472
;
473
adcily   .macro .ad
474
         .byte $77,.ad
475
         .endm
476
;
477
andil    .macro .ad
478
         .byte $27,.ad
479
         .endm
480
;
481
andily   .macro .ad
482
         .byte $37,.ad
483
         .endm
484
;
485
cmpil    .macro .ad
486
         .byte $c7,.ad
487
         .endm
488
;
489
cmpily   .macro .ad
490
         .byte $d7,.ad
491
         .endm
492
;
493
eoril    .macro .ad
494
         .byte $47,.ad
495
         .endm
496
;
497
eorily   .macro .ad
498
         .byte $57,.ad
499
         .endm
500
;
501
ldail    .macro .ad
502
         .byte $a7,.ad
503
         .endm
504
;
505
ldaily   .macro .ad
506
         .byte $b7,.ad
507
         .endm
508
;
509
orail    .macro .ad
510
         .byte $07,.ad
511
         .endm
512
;
513
oraily   .macro .ad
514
         .byte $17,.ad
515
         .endm
516
;
517
sbcil    .macro .ad
518
         .byte $e7,.ad
519
         .endm
520
;
521
sbcily   .macro .ad
522
         .byte $f7,.ad
523
         .endm
524
;
525
stail    .macro .ad
526
         .byte $87,.ad
527
         .endm
528
;
529
staily   .macro .ad
530
         .byte $97,.ad
531
         .endm
532
;
533
adcs     .macro .of
534
         .byte $63,.of
535
         .endm
536
;
537
adcsi    .macro .of
538
         .byte $73,.of
539
         .endm
540
;
541
ands     .macro .of
542
         .byte $23,.of
543
         .endm
544
;
545
andsi    .macro .of
546
         .byte $33,.of
547
         .endm
548
;
549
cmps     .macro .of
550
         .byte $c3,.of
551
         .endm
552
;
553
cmpsi    .macro .of
554
         .byte $d3,.of
555
         .endm
556
;
557
eors     .macro .of
558
         .byte $43,.of
559
         .endm
560
;
561
eorsi    .macro .of
562
         .byte $53,.of
563
         .endm
564
;
565
ldas     .macro .of
566
         .byte $a3,.of
567
         .endm
568
;
569
ldasi    .macro .of
570
         .byte $b3,.of
571
         .endm
572
;
573
oras     .macro .of
574
         .byte $03,.of
575
         .endm
576
;
577
orasi    .macro .of
578
         .byte $13,.of
579
         .endm
580
;
581
sbcs     .macro .of
582
         .byte $e3,.of
583
         .endm
584
;
585
sbcsi    .macro .of
586
         .byte $f3,.of
587
         .endm
588
;
589
stas     .macro .of
590
         .byte $83,.of
591
         .endm
592
;
593
stasi    .macro .of
594
         .byte $93,.of
595
         .endm
596
;
597
longa    .macro
598
         .byte $c2,$20
599
         .endm
600
;
601
longr    .macro
602
         .byte $c2,$30
603
         .endm
604
;
605
longx    .macro
606
         .byte $c2,$10
607
         .endm
608
;
609
shorta   .macro
610
         .byte $e2,$20
611
         .endm
612
;
613
shorti   .macro
614
         .byte $e2,$10
615
         .endm
616
;
617
shortr   .macro
618
         .byte $e2,$30
619
         .endm
620
;
621
shortx   .macro
622
         .byte $e2,$10
623
         .endm
624
;
625
;================================================================================
626
;
627
;CONSOLE DISPLAY CONTROL MACROS
628
;
629
;       ————————————————————————————————————————————————————————————————————————
630
;       The following macros execute terminal  control procedures  that  perform
631
;       such tasks as clearing the screen,  switching  between  normal & reverse
632
;       video, etc.  These macros are for WYSE 60 & compatible displays, such as
633
;       the WYSE 150, WYSE 160, WYSE 325 & WYSE GPT.   Only the functions needed
634
;       by Supermon 816 are included.
635
;
636
;       If your console is not WYSE 60 compatible, you will need to  edit  these
637
;       macros as required to control your particular console or terminal.  Note
638
;       that in some cases one macro may call another.  Exercise caution in your
639
;       edits to avoid introducing display bugs.
640
;
641
;       If your console display cannot execute one of these procedures,  such as
642
;       'CL' (clear to end of line), you will have to develop an alternative.
643
;       ————————————————————————————————————————————————————————————————————————
644
;
645
;
646
;       clearing data...
647
;
648
bs       .macro                ;destructive backspace
649
         .byte a_bs
650
         dcuc
651
         .endm
652
;
653
cl       .macro                ;clear to end of line
654
         .byte a_esc,"T"
655
         .endm
656
;
657
;
658
;       cursor control...
659
;
660
cn       .macro                ;cursor on
661
         .byte a_esc,"`1"
662
         .endm
663
;
664
co       .macro                ;cursor off
665
         .byte a_esc,"`0"
666
         .endm
667
;
668
cr       .macro                ;carriage return
669
         .byte a_cr
670
         .endm
671
;
672
lf       .macro                ;carriage return/line feed
673
         cr
674
         .byte a_lf
675
         .endm
676
;
677
;
678
;       display attributes...
679
;
680
bf       .macro                ;reverse foreground
681
         .byte a_esc,"("
682
         .byte a_esc,"G4"
683
         .endm
684
;
685
er       .macro                ;enable normal foreground
686
         .byte a_esc,"("
687
         .byte a_esc,"G0"
688
         .endm
689
;
690
sf       .macro                ;set foreground
691
         .byte a_esc,"("
692
         .byte a_esc,"G0"
693
         .endm
694
;
695
;
696
;       display editing...
697
;
698
dcuc     .macro                ;delete char under cursor
699
         .byte a_esc,"W"
700
         .endm
701
;
702
;
703
;       miscellaneous control...
704
;
705
rb       .macro                ;ring "bell"
706
         .byte a_bel
707
         .endm
708
;
709
;================================================================================
710
;
711
;ASCII CONTROL DEFINITIONS (menmonic order)
712
;
713
a_bel    =$07                  ; alert/ring bell
714
a_bs     =$08                  ;  backspace
715
a_cr     =$0d                  ;  carriage return
716
a_del    =$7f                  ; delete
717
a_esc    =$1b                  ; escape
718
a_ht     =$09                  ;  horizontal tabulation
719
a_lf     =$0a                  ;  linefeed
720
;
721
;
722
;       miscellaneous (description order)...
723
;
724
a_blank  =' '                  ;blank (whitespace)
725
a_asclch ='z'                  ;end of lowercase ASCII
726
a_lctouc =$5f                  ;LC to UC conversion mask
727
a_asclcl ='a'                  ;start of lowercase ASCII
728
;
729
;================================================================================
730
;
731
;GLOBAL ATOMIC CONSTANTS
732
;
733
;
734
;       data type sizes...
735
;
736
s_byte   =1                    ;byte
737
s_word   =2                    ;word (16 bits)
738
s_xword  =3                    ;extended word (24 bits)
739
s_dword  =4                    ;double word (32 bits)
740
s_rampag =$0100                ;65xx RAM page
741
;
742
;
743
;       data type sizes in bits...
744
;
745
s_bibyte =8                    ;byte
746
s_bnybbl =4                    ;nybble
747
;
748
;
749
;       miscellaneous...
750
;
751
bitabs   =$2c                  ;absolute BIT opcode
752
bitzp    =$24                  ;zero page BIT opcode
753
;
754
;================================================================================
755
;
756
;W65C816S NATIVE MODE STATUS REGISTER DEFINITIONS
757
;
758
s_mpudbx =s_byte               ;data bank size
759
s_mpudpx =s_word               ;direct page size
760
s_mpupbx =s_byte               ;program bank size
761
s_mpupcx =s_word               ;program counter size
762
s_mpuspx =s_word               ;stack pointer size
763
s_mpusrx =s_byte               ;status size
764
;
765
;
766
;       status register flags...
767
;
768
sr_car   =@00000001            ;C
769
sr_zer   =sr_car << 1          ;Z
770
sr_irq   =sr_zer << 1          ;I
771
sr_bdm   =sr_irq << 1          ;D
772
sr_ixw   =sr_bdm << 1          ;x
773
sr_amw   =sr_ixw << 1          ;m
774
sr_ovl   =sr_amw << 1          ;V
775
sr_neg   =sr_ovl << 1          ;N
776
;
777
;       NVmxDIZC
778
;       xxxxxxxx
779
;       ||||||||
780
;       |||||||+———> 1 = carry set/generated
781
;       ||||||+————> 1 = result = zero
782
;       |||||+—————> 1 = IRQs ignored
783
;       ||||+——————> 0 = binary arithmetic mode
784
;       ||||         1 = decimal arithmetic mode
785
;       |||+———————> 0 = 16 bit index
786
;       |||          1 = 8 bit index
787
;       ||+————————> 0 = 16 bit .A & memory
788
;       ||           1 = 8 bit .A & memory
789
;       |+—————————> 1 = sign overflow
790
;       +——————————> 1 = result = negative
791
;
792
;================================================================================
793
;
794
;"SIZE-OF" CONSTANTS
795
;
796
s_addr   =s_xword              ;24 bit address
797
s_auxbuf =32                   ;auxiliary buffer
798
s_ibuf   =69                   ;input buffer
799
s_mnemon =3                    ;MPU ASCII mnemonic
800
s_mnepck =2                    ;MPU encoded mnemonic
801
s_mvinst =3                    ;MVN/MVP instruction
802
s_opcode =s_byte               ;MPU opcode
803
s_oper   =s_xword              ;operand
804
s_pfac   =s_dword              ;primary math accumulator
805
s_sfac   =s_dword+s_word       ;secondary math accumulators
806
;
807
;================================================================================
808
;
809
;"NUMBER-OF" CONSTANTS
810
;
811
n_dbytes =21                   ;default disassembly bytes
812
n_dump   =8                    ;bytes per memory dump line
813
n_mbytes =s_rampag-1           ;default memory dump bytes
814
n_hccols =8                    ;compare/hunt display columns
815
n_opcols =3*s_oper             ;disassembly operand columns
816
n_opslsr =4                    ;LSRs to extract instruction size
817
n_shfenc =5                    ;shifts to encode/decode mnemonic
818
;
819
;================================================================================
820
;
821
;NUMERIC CONVERSION CONSTANTS
822
;
823
a_hexdec ='A'-'9'-2            ;hex to decimal difference
824
c_bin    ='%'                  ;binary prefix
825
c_dec    ='+'                  ;decimal prefix
826
c_hex    ='$'                  ;hexadecimal prefix
827
c_oct    ='@'                  ;octal prefix
828
k_hex    ='f'                  ;hex ASCII conversion
829
m_bits   =s_pfac*s_bibyte      ;operand bit size
830
m_cbits  =s_sfac*s_bibyte      ;workspace bit size
831
bcdumask =@00001111            ;isolate BCD units mask
832
btoamask =@00110000            ;binary to ASCII mask
833
;
834
;================================================================================
835
;
836
;ASSEMBLER/DISASSEMBLER CONSTANTS
837
;
838
a_mnecvt ='?'                  ;encoded mnemonic conversion base
839
aimmaska =@00011111            ;.A immediate opcode test #1
840
aimmaskb =@00001001            ;.A immediate opcode test #2
841
asmprfx  ='A'                  ;assemble code prefix
842
ascprmct =9                    ;assembler prompt "size-of"
843
disprfx  ='.'                  ;disassemble code prefix
844
flimmask =@11000000            ;force long immediate flag
845
opc_mvn  =$54                  ;MVN opcode
846
opc_mvp  =$44                  ;MVP opcode
847
opc_rep  =$c2                  ;REP opcode
848
opc_sep  =$e2                  ;SEP opcode
849
pfmxmask =sr_amw | sr_ixw      ;MPU m & x flag bits mask
850
;
851
;
852
;       assembler prompt buffer offsets...
853
;
854
apadrbkh =s_word               ;instruction address bank MSN
855
apadrbkl =apadrbkh+s_byte      ;instruction address bank LSN
856
apadrmbh =apadrbkl+s_byte      ;instruction address MSB MSN
857
apadrmbl =apadrmbh+s_byte      ;instruction address MSB LSN
858
apadrlbh =apadrmbl+s_byte      ;instruction address LSB MSN
859
apadrlbl =apadrlbh+s_byte      ;instruction address LSB LSN
860
;
861
;
862
;       addressing mode preamble symbols...
863
;
864
amp_flim ='!'                  ;force long immediate
865
amp_imm  ='#'                  ;immediate
866
amp_ind  ='('                  ;indirect
867
amp_indl ='['                  ;indirect long
868
;
869
;
870
;       addressing mode symbolic translation indices...
871
;
872
am_nam   =@0000                ;(0)  no symbol
873
am_imm   =@0001                ;(1)  #
874
am_adrx  =@0010                ;(2)  dp,X or addr,X
875
am_adry  =@0011                ;(3)  dp,Y or addr,Y
876
am_ind   =@0100                ;(4)  (dp) or (addr)
877
am_indl  =@0101                ;(5)  [dp] or [addr]
878
am_indly =@0110                ;(6)  [dp],Y
879
am_indx  =@0111                ;(7)  (dp,X) or (addr,X)
880
am_indy  =@1000                ;(8)  (dp),Y
881
am_stk   =@1001                ;(9)  offset,S
882
am_stky  =@1010                ;(10) (offset,S),Y
883
am_move  =@1011                ;(11) MVN/MVP sbnk,dbnk
884
;
885
;
886
;       operand size translation indices...
887
;
888
ops0     =@0000 << 4           ;no operand
889
ops1     =@0001 << 4           ;8 bit operand
890
ops2     =@0010 << 4           ;16 bit operand
891
ops3     =@0011 << 4           ;24 bit operand
892
bop1     =@0101 << 4           ;8 bit relative branch
893
bop2     =@0110 << 4           ;16 bit relative branch
894
vops     =@1001 << 4           ;8 or 16 bit operand
895
;
896
;
897
;       operand size & addressing mode extraction masks...
898
;
899
amodmask =@00001111            ;addressing mode index
900
opsmask  =@00110000            ;operand size
901
vopsmask =@11000000            ;BOPx & VOPS flag bits
902
;
903
;
904
;       instruction mnemonic encoding...
905
;
906
mne_adc  =$2144                ;ADC
907
mne_and  =$2bc4                ;AND
908
mne_asl  =$6d04                ;ASL
909
mne_bcc  =$2106                ;BCC
910
mne_bcs  =$a106                ;BCS
911
mne_beq  =$9186                ;BEQ
912
mne_bit  =$aa86                ;BIT
913
mne_bmi  =$5386                ;BMI
914
mne_bne  =$33c6                ;BNE
915
mne_bpl  =$6c46                ;BPL
916
mne_bra  =$14c6                ;BRA
917
mne_brk  =$64c6                ;BRK
918
mne_brl  =$6cc6                ;BRL
919
mne_bvc  =$25c6                ;BVC
920
mne_bvs  =$a5c6                ;BVS
921
mne_clc  =$2348                ;CLC
922
mne_cld  =$2b48                ;CLD
923
mne_cli  =$5348                ;CLI
924
mne_clv  =$bb48                ;CLV
925
mne_cmp  =$8b88                ;CMP
926
mne_cop  =$8c08                ;COP
927
mne_cpx  =$cc48                ;CPX
928
mne_cpy  =$d448                ;CPY
929
mne_dec  =$218a                ;DEC
930
mne_dex  =$c98a                ;DEX
931
mne_dey  =$d18a                ;DEY
932
mne_eor  =$9c0c                ;EOR
933
mne_inc  =$23d4                ;INC
934
mne_inx  =$cbd4                ;INX
935
mne_iny  =$d3d4                ;INY
936
mne_jml  =$6b96                ;JML
937
mne_jmp  =$8b96                ;JMP
938
mne_jsl  =$6d16                ;JSL
939
mne_jsr  =$9d16                ;JSR
940
mne_lda  =$115a                ;LDA
941
mne_ldx  =$c95a                ;LDX
942
mne_ldy  =$d15a                ;LDY
943
mne_lsr  =$9d1a                ;LSR
944
mne_mvn  =$7ddc                ;MVN
945
mne_mvp  =$8ddc                ;MVP
946
mne_nop  =$8c1e                ;NOP
947
mne_ora  =$14e0                ;ORA
948
mne_pea  =$11a2                ;PEA
949
mne_pei  =$51a2                ;PEI
950
mne_per  =$99a2                ;PER
951
mne_pha  =$1262                ;PHA
952
mne_phb  =$1a62                ;PHB
953
mne_phd  =$2a62                ;PHD
954
mne_phk  =$6262                ;PHK
955
mne_php  =$8a62                ;PHP
956
mne_phx  =$ca62                ;PHX
957
mne_phy  =$d262                ;PHY
958
mne_pla  =$1362                ;PLA
959
mne_plb  =$1b62                ;PLB
960
mne_pld  =$2b62                ;PLD
961
mne_plp  =$8b62                ;PLP
962
mne_plx  =$cb62                ;PLX
963
mne_ply  =$d362                ;PLY
964
mne_rep  =$89a6                ;REP
965
mne_rol  =$6c26                ;ROL
966
mne_ror  =$9c26                ;ROR
967
mne_rti  =$5566                ;RTI
968
mne_rtl  =$6d66                ;RTL
969
mne_rts  =$a566                ;RTS
970
mne_sbc  =$20e8                ;SBC
971
mne_sec  =$21a8                ;SEC
972
mne_sed  =$29a8                ;SED
973
mne_sei  =$51a8                ;SEI
974
mne_sep  =$89a8                ;SEP
975
mne_sta  =$1568                ;STA
976
mne_stp  =$8d68                ;STP
977
mne_stx  =$cd68                ;STX
978
mne_sty  =$d568                ;STY
979
mne_stz  =$dd68                ;STZ
980
mne_tax  =$c8aa                ;TAX
981
mne_tay  =$d0aa                ;TAY
982
mne_tcd  =$292a                ;TCD
983
mne_tcs  =$a12a                ;TCS
984
mne_tdc  =$216a                ;TDC
985
mne_trb  =$1cea                ;TRB
986
mne_tsb  =$1d2a                ;TSB
987
mne_tsc  =$252a                ;TSC
988
mne_tsx  =$cd2a                ;TSX
989
mne_txa  =$166a                ;TXA
990
mne_txs  =$a66a                ;TXS
991
mne_txy  =$d66a                ;TXY
992
mne_tya  =$16aa                ;TYA
993
mne_tyx  =$ceaa                ;TYX
994
mne_wai  =$50b0                ;WAI
995
mne_wdm  =$7170                ;WDM
996
mne_xba  =$10f2                ;XBA
997
mne_xce  =$3132                ;XCE
998
;
999
;
1000
;       encoded instruction mnemonic indices...
1001
;
1002
mne_adcx =16                   ;ADC
1003
mne_andx =29                   ;AND
1004
mne_aslx =44                   ;ASL
1005
mne_bccx =15                   ;BCC
1006
mne_bcsx =65                   ;BCS
1007
mne_beqx =59                   ;BEQ
1008
mne_bitx =70                   ;BIT
1009
mne_bmix =36                   ;BMI
1010
mne_bnex =31                   ;BNE
1011
mne_bplx =42                   ;BPL
1012
mne_brax =5                    ;BRA
1013
mne_brkx =39                   ;BRK
1014
mne_brlx =43                   ;BRL
1015
mne_bvcx =23                   ;BVC
1016
mne_bvsx =68                   ;BVS
1017
mne_clcx =20                   ;CLC
1018
mne_cldx =27                   ;CLD
1019
mne_clix =35                   ;CLI
1020
mne_clvx =71                   ;CLV
1021
mne_cmpx =53                   ;CMP
1022
mne_copx =55                   ;COP
1023
mne_cpxx =78                   ;CPX
1024
mne_cpyx =88                   ;CPY
1025
mne_decx =18                   ;DEC
1026
mne_dexx =74                   ;DEX
1027
mne_deyx =84                   ;DEY
1028
mne_eorx =61                   ;EOR
1029
mne_incx =21                   ;INC
1030
mne_inxx =77                   ;INX
1031
mne_inyx =87                   ;INY
1032
mne_jmlx =40                   ;JML
1033
mne_jmpx =54                   ;JMP
1034
mne_jslx =45                   ;JSL
1035
mne_jsrx =63                   ;JSR
1036
mne_ldax =1                    ;LDA
1037
mne_ldxx =73                   ;LDX
1038
mne_ldyx =83                   ;LDY
1039
mne_lsrx =64                   ;LSR
1040
mne_mvnx =48                   ;MVN
1041
mne_mvpx =58                   ;MVP
1042
mne_nopx =56                   ;NOP
1043
mne_orax =6                    ;ORA
1044
mne_peax =2                    ;PEA
1045
mne_peix =33                   ;PEI
1046
mne_perx =60                   ;PER
1047
mne_phax =3                    ;PHA
1048
mne_phbx =10                   ;PHB
1049
mne_phdx =26                   ;PHD
1050
mne_phkx =38                   ;PHK
1051
mne_phpx =51                   ;PHP
1052
mne_phxx =75                   ;PHX
1053
mne_phyx =85                   ;PHY
1054
mne_plax =4                    ;PLA
1055
mne_plbx =11                   ;PLB
1056
mne_pldx =28                   ;PLD
1057
mne_plpx =52                   ;PLP
1058
mne_plxx =76                   ;PLX
1059
mne_plyx =86                   ;PLY
1060
mne_repx =49                   ;REP
1061
mne_rolx =41                   ;ROL
1062
mne_rorx =62                   ;ROR
1063
mne_rtix =37                   ;RTI
1064
mne_rtlx =46                   ;RTL
1065
mne_rtsx =67                   ;RTS
1066
mne_sbcx =14                   ;SBC
1067
mne_secx =19                   ;SEC
1068
mne_sedx =25                   ;SED
1069
mne_seix =34                   ;SEI
1070
mne_sepx =50                   ;SEP
1071
mne_stax =7                    ;STA
1072
mne_stpx =57                   ;STP
1073
mne_stxx =80                   ;STX
1074
mne_styx =89                   ;STY
1075
mne_stzx =91                   ;STZ
1076
mne_taxx =72                   ;TAX
1077
mne_tayx =82                   ;TAY
1078
mne_tcdx =24                   ;TCD
1079
mne_tcsx =66                   ;TCS
1080
mne_tdcx =17                   ;TDC
1081
mne_trbx =12                   ;TRB
1082
mne_tsbx =13                   ;TSB
1083
mne_tscx =22                   ;TSC
1084
mne_tsxx =79                   ;TSX
1085
mne_txax =8                    ;TXA
1086
mne_txsx =69                   ;TXS
1087
mne_txyx =90                   ;TXY
1088
mne_tyax =9                    ;TYA
1089
mne_tyxx =81                   ;TYX
1090
mne_waix =32                   ;WAI
1091
mne_wdmx =47                   ;WDM
1092
mne_xbax =0                    ;XBA
1093
mne_xcex =30                   ;XCE
1094
;
1095
;================================================================================
1096
;
1097
;MISCELLANEOUS CONSTANTS
1098
;
1099
halftab  =4                    ;1/2 tabulation spacing
1100
memprfx  ='>'                  ;memory dump prefix
1101
memsepch =':'                  ;memory dump separator
1102
memsubch ='.'                  ;memory dump non-print char
1103
srinit   =@00110000            ;SR initialization value
1104
;
1105
;================================================================================
1106
;
1107
;DIRECT PAGE STORAGE
1108
;
1109
reg_pbx  =zeropage             ;PB
1110
reg_pcx  =reg_pbx+s_mpupbx     ;PC
1111
reg_srx  =reg_pcx+s_mpupcx     ;SR
1112
reg_ax   =reg_srx+s_mpusrx     ;.C
1113
reg_xx   =reg_ax+s_word        ;.X
1114
reg_yx   =reg_xx+s_word        ;.Y
1115
reg_spx  =reg_yx+s_word        ;SP
1116
reg_dpx  =reg_spx+s_mpuspx     ;DP
1117
reg_dbx  =reg_dpx+s_mpudpx     ;DB
1118
;
1119
;
1120
;       general workspace...
1121
;
1122
addra    =reg_dbx+s_mpudbx     ;address #1
1123
addrb    =addra+s_addr         ;address #2
1124
faca     =addrb+s_addr         ;primary accumulator
1125
facax    =faca+s_pfac          ;extended primary accumulator
1126
facb     =facax+s_pfac         ;secondary accumulator
1127
facc     =facb+s_sfac          ;tertiary accumulator
1128
operand  =facc+s_sfac          ;instruction operand
1129
auxbufix =operand+s_oper       ;auxiliary buffer index
1130
ibufidx  =auxbufix+s_byte      ;input buffer index
1131
bitsdig  =ibufidx+s_byte       ;bits per numeral
1132
numeral  =bitsdig+s_byte       ;numeral buffer
1133
radix    =numeral+s_byte       ;radix index
1134
admodidx =radix+s_byte         ;addressing mode index
1135
charcnt  =admodidx+s_byte      ;character counter
1136
instsize =charcnt+s_word       ;instruction size
1137
mnepck   =instsize+s_word      ;encoded mnemonic
1138
opcode   =mnepck+s_mnepck      ;current opcode
1139
status   =opcode+s_byte        ;I/O status flag
1140
xrtemp   =status+s_byte        ;temp .X storage
1141
eopsize  =xrtemp+s_byte        ;entered operand size
1142
flimflag =eopsize+s_byte       ;forced long immediate...
1143
;
1144
;       xx000000
1145
;       ||
1146
;       |+—————————> 0: .X/.Y = 8 bits
1147
;       |            1: .X/.Y = 18 bits
1148
;       +——————————> 0: .A = 8 bits
1149
;                    1: .A = 16 bits
1150
;
1151
;       ————————————————————————————————————————————————————————————————————————
1152
;       During assembly, FLIMFLAG indicates the operand size used with an immed-
1153
;       iate mode instruction, thus causing the following disassembly to display
1154
;       the assembled  operand size.   During disassembly,  FLIMFLAG will mirror
1155
;       the effect of the most recent REP or SEP instruction.
1156
;       ————————————————————————————————————————————————————————————————————————
1157
;
1158
iopsize  =flimflag+s_byte      ;operand size
1159
range    =iopsize+s_byte       ;allowable radix range
1160
vopsflag =range+s_byte         ;VOPS & ROPS mode bits
1161
;
1162
;
1163
;       copy/fill workspace (overlaps some of the above)...
1164
;
1165
mcftwork =vopsflag+s_byte       ;faca                 ;start of copy/fill code
1166
mcftopc  =mcftwork+s_byte      ;instruction opcode
1167
mcftbnk  =mcftopc+s_byte       ;banks
1168
;
1169
;================================================================================
1170
;
1171
;SUPERMON 816 JUMP TABLE
1172
;
1173
         org    _origin_
1174
;
1175
JMON     bra mon               ;cold start entry
1176
JMONBRK  bra monbrk            ;software interrupt intercept
1177
;
1178
;================================================================================
1179
;
1180
;mon: SUPERMON 816 COLD START
1181
;
1182
mon     longa
1183
         lda vecbrki           ;BRK vector
1184
         cmpw monbrk           ;pointing at monitor?
1185
         bne .2            ;yes, ignore cold start
1186
         jmp    monreg                  ; got a branch out of range here when debugging code
1187
                                                                ; was included
1188
.2
1189
;
1190
         sta vecbrkia          ;save vector for exit
1191
         ldaw monbrk           ;Supermon 816 intercepts...
1192
         sta vecbrki           ;BRK handler
1193
         shortr                ;8 bit registers
1194
         ldx #vopsflag-reg_pbx
1195
;
1196
.0000010 stz reg_pbx,x         ;clear DP storage
1197
         dex
1198
         bpl .0000010
1199
;
1200
         lda #srinit
1201
         sta reg_srx           ;status register
1202
         longa                 ;16 bit .A
1203
         ldaw hwstack          ;top of hardware stack
1204
         tcs                   ;set SP
1205
         tdc                   ;get & save...
1206
         sta reg_dpx           ;DP register
1207
         ldaw 0
1208
         shorta
1209
         phk
1210
         pla                   ;capture PB &...
1211
         sta reg_pbx           ;set
1212
         phb
1213
         pla                   ;capture DB &...
1214
         sta reg_dbx           ;set
1215
         pea mm_entry          ;"...ready..."
1216
         bra moncom
1217
;
1218
;================================================================================
1219
;
1220
;monbrk: SOFTWARE INTERRUPT INTERCEPT
1221
;
1222
;       ————————————————————————————————————————————————————————————————————————
1223
;       This is the entry point taken when a BRK instruction is executed.  It is
1224
;       assumed that the BRK  handler has pushed the registers to the stack that
1225
;       are not automatically pushed by the MPU in response to BRK.
1226
;       ————————————————————————————————————————————————————————————————————————
1227
;
1228
monbrk   cli                   ;reenable IRQs
1229
         ply                   ;recover registers
1230
         plx
1231
         pla
1232
         longr                 ;store 16 bit registers
1233
         sta reg_ax            ;.A
1234
         stx reg_xx            ;.X
1235
         sty reg_yx            ;.Y
1236
         shortx                ;8 bit index registers
1237
         pla                   ;get DP &...
1238
         sta reg_dpx           ;store
1239
         plx                   ;get DB &...
1240
         stx reg_dbx           ;store
1241
         plx                   ;get SR &...
1242
         stx reg_srx           ;store
1243
         pla                   ;get PC &...
1244
         sta reg_pcx           ;store
1245
         shorta
1246
         pla                   ;get PB &...
1247
         sta reg_pbx           ;store
1248
         pea mm_brk            ;"*BRK"
1249
;
1250
;================================================================================
1251
;
1252
;moncom: COMMON ENTRY POINT
1253
;
1254
;       ——————————————————————————————————————
1255
;       DO NOT directly call this entry point!
1256
;       ——————————————————————————————————————
1257
;
1258
moncom   jsr sprint            ;print heading
1259
         longa
1260
         tsc                   ;get SP &...
1261
         sta reg_spx           ;store
1262
         rep @11111111         ;clear SR &...
1263
         sep srinit            ;set default state
1264
         sec                   ;see next
1265
;
1266
;================================================================================
1267
;
1268
;monreg: DISPLAY MPU REGISTERS
1269
;
1270
;       —————————
1271
;       syntax: R
1272
;       —————————
1273
;
1274
monreg   bcs .0000010          ;okay to proceed
1275
;
1276
         jmp monerr            ;error if called with a parm
1277
;
1278
.0000010 pea mm_regs
1279
         jsr sprint            ;display heading
1280
;
1281
;
1282
;       display program bank & counter...
1283
;
1284
         lda reg_pbx           ;PB
1285
         jsr dpyhex            ;display as hex ASCII
1286
         jsr printspc          ;inter-field space
1287
         longa
1288
         lda reg_pcx
1289
         shorta
1290
         jsr dpyhexw           ;display PC
1291
         ldx #2
1292
         jsr multspc           ;inter-field spacing
1293
;
1294
;
1295
;       display SR in bitwise fashion...
1296
;
1297
         ldx reg_srx           ;SR
1298
         ldy #s_bibyte         ;bits in a byte
1299
;
1300
.0000020 txa                   ;remaining SR bits
1301
         asl                   ;grab one of them
1302
         tax                   ;save remainder
1303
         lda #'0'              ;a clear bit but...
1304
         adc #0                ;adjust if set &...
1305
         jsr putcha            ;print
1306
         dey                   ;bit processed
1307
         bne .0000020          ;do another
1308
;
1309
;
1310
;       display .C, .X, .Y, SP & DP...
1311
;
1312
.0000030 jsr printspc          ;spacing
1313
         longa
1314
         lda reg_ax,y          ;get register value
1315
         shorta
1316
         jsr dpyhexw           ;convert & display
1317
;         .rept s_word
1318
           iny
1319
           iny
1320
;         .endr
1321
         cpy #reg_dbx-reg_ax
1322
         bcc .0000030          ;next
1323
;
1324
;
1325
;       display DB...
1326
;
1327
         jsr printspc          ;more spacing
1328
         lda reg_dbx           ;get DB &...
1329
         jsr dpyhex            ;display it
1330
 
1331
;
1332
;================================================================================
1333
;
1334
;monce: COMMAND EXECUTIVE
1335
;
1336
monce    shorta
1337
         lda #0                ;default buffer index
1338
;
1339
moncea   shortr                ;alternate entry point
1340
         sta ibufidx           ;(re)set buffer index
1341
         pea mm_prmpt
1342
         jsr sprint            ;display input prompt
1343
         jsr input             ;await some input
1344
;
1345
.0000010:
1346
                jsr getcharc          ;read from buffer
1347
         beq monce             ;terminator, just loop
1348
;
1349
         cmp #a_blank
1350
         beq .0000010          ;strip leading blanks
1351
;
1352
         ldx #n_mpctab-1       ;number of primary commands
1353
;
1354
.0000020 cmp mpctab,x          ;search primary command list
1355
         bne .0000030
1356
;
1357
         txa                   ;get index
1358
         asl                   ;double for offset
1359
         tax
1360
         longa
1361
         lda mpcextab,x        ;command address -1
1362
         pha                   ;prime the stack
1363
         shorta
1364
         jmp getparm           ;evaluate parm & execute command
1365
;
1366
.0000030 dex
1367
         bpl .0000020          ;continue searching primary commands
1368
;
1369
         ldx #n_radix-1        ;number of radices
1370
;
1371
.0000040 cmp radxtab,x         ;search conversion command list
1372
         bne .0000050
1373
;
1374
         jmp monenv            ;convert & display parameter
1375
;
1376
.0000050 dex
1377
         bpl .0000040
1378
;
1379
;================================================================================
1380
;
1381
;monerr: COMMON ERROR HANDLER
1382
;
1383
monerr   shortr                ;8 bit registers
1384
;
1385
monerraa jsr dpyerr            ;indicate an error &...
1386
         bra monce             ;return to input loop
1387
;
1388
;================================================================================
1389
;
1390
;monasc: ASSEMBLE CODE
1391
;
1392
;       ———————————————————————————————————————————————————————————————————————
1393
;       syntax: A   []
1394
;
1395
;       After a line of code has been successfully assembled it will be disass-
1396
;       embled & displayed,  & the monitor will prompt with the next address to
1397
;       which code may be assembled.
1398
;       ———————————————————————————————————————————————————————————————————————
1399
;
1400
monasc   bcc .0000020          ;assembly address entered
1401
;
1402
.0000010 jmp monerr            ;terminate w/error
1403
;
1404
;
1405
;       evaluate assembly address...
1406
;
1407
.0000020 jsr facasize          ;check address...
1408
         cmp #s_dword          ;range
1409
         bcs .0000010          ;out of range — error
1410
;
1411
         jsr facaddra          ;store assembly address
1412
;
1413
;
1414
;       initialize workspace...
1415
;
1416
         ldx #s_auxbuf-s_byte
1417
;
1418
.0000030 stz auxbuf,x          ;clear addressing mode buffer
1419
         dex
1420
         bne .0000030
1421
;
1422
         lda #a_blank
1423
         sta auxbuf            ;preamble placeholder
1424
         jsr clroper           ;clear operand
1425
         stz auxbufix          ;reset addressing mode index
1426
         stz flimflag          ;clear forced long immediate
1427
         stz mnepck            ;clear encoded...
1428
         stz mnepck+s_byte     ;mnemonic workspace
1429
         stz vopsflag          ;clear 8/16 or relative flag
1430
;
1431
;
1432
;       encode mnemonic...
1433
;
1434
         ldy #s_mnemon         ;expected mnemonic size
1435
;
1436
.0000040 jsr getcharw          ;get from buffer wo/whitespace
1437
         bne .0000060          ;gotten
1438
;
1439
         cpy #s_mnemon         ;any input at all?
1440
         bcc .0000050          ;yes
1441
;
1442
         jmp monce             ;no, abort further assembly
1443
;
1444
.0000050 jmp monasc10          ;incomplete mnemonic — error
1445
;
1446
.0000060 sec
1447
         sbc #a_mnecvt         ;ASCII to binary factor
1448
         ldx #n_shfenc         ;shifts required to encode
1449
;
1450
.0000070 lsr                   ;shift out a bit...
1451
         ror mnepck+s_byte     ;into...
1452
         ror mnepck            ;encoded mnemonic
1453
         dex
1454
         bne .0000070          ;next bit
1455
;
1456
         dey
1457
         bne .0000040          ;get next char
1458
;
1459
;
1460
;       test for copy instruction...
1461
;       ————————————————————————————————————————————————————————————————————————
1462
;       The MVN & MVP instructions accept two operands & hence have an irregular
1463
;       syntax.  Therefore, special handling is necessary to assemble either of
1464
;       these instructions.
1465
;
1466
;       The official WDC syntax has the programmer entering a pair of 24 bit ad-
1467
;       dresses as operands, with the assembler isolating bits 16-23 to use as
1468
;       operands.  This formality has been dispensed with in this monitor & the
1469
;       operands are expected to be 8 bit bank values.
1470
;       ————————————————————————————————————————————————————————————————————————
1471
;
1472
         longa                 ;16 bit load
1473
         lda mnepck            ;packed menmonic
1474
         ldx #opc_mvn          ;MVN opcode
1475
         cmpw mne_mvn          ;is it MVN?
1476
         beq monasc01          ;yes
1477
;
1478
         ldx #opc_mvp          ;MVP opcode
1479
         cmpw mne_mvp          ;is it MVP?
1480
         bne monasc02          ;no
1481
;
1482
;
1483
;       assemble copy instruction...
1484
;
1485
monasc01 stx opcode            ;store relevant opcode
1486
         shorta
1487
         jsr instdata          ;get instruction data
1488
         stx eopsize           ;effective operand size
1489
         inx
1490
         stx instsize          ;instruction size
1491
         ldx #s_oper-s_word    ;operand index
1492
         stx xrtemp            ;set it
1493
;
1494
.0000010 jsr ascbin            ;evaluate bank number
1495
         bcs monasc04          ;conversion error
1496
;
1497
         beq monasc04          ;nothing returned — error
1498
;
1499
         jsr facasize          ;bank must be...
1500
         cmp #s_word           ;8 bits
1501
         bcs monasc04          ;it isn't — error
1502
;
1503
         lda faca              ;bank
1504
         ldx xrtemp            ;operand index
1505
         sta operand,x         ;store
1506
         dec xrtemp            ;index=index-1
1507
         bpl .0000010          ;get destination bank
1508
;
1509
         jsr getcharr          ;should be no more input
1510
         bne monasc04          ;there is — error
1511
;
1512
         jmp monasc08          ;finish MVN/MVP assembly
1513
;
1514
;
1515
;       continue with normal assembly...
1516
;
1517
monasc02 shorta                ;back to 8 bits
1518
;
1519
monasc03 jsr getcharw          ;get next char
1520
         beq monasc06          ;EOI, no argument
1521
;
1522
         cmp #amp_flim
1523
         bne .0000010          ;no forced long immediate
1524
;
1525
         lda flimflag          ;FLIM already set?
1526
         bne monasc04          ;yes — error
1527
;
1528
         lda #flimmask
1529
         sta flimflag          ;set flag &...
1530
         bra monasc03          ;get next char
1531
;
1532
.0000010 cmp #amp_imm          ;immediate mode?
1533
         beq .0000020          ;yes
1534
;
1535
         cmp #amp_ind          ;indirect mode?
1536
         beq .0000020          ;yes
1537
;
1538
         cmp #amp_indl         ;indirect long mode?
1539
         bne .0000030          ;no
1540
;
1541
.0000020 sta auxbuf            ;set addressing mode preamble
1542
         inc auxbufix          ;bump aux buffer index &...
1543
         bra .0000040          ;evaluate operand
1544
;
1545
.0000030 dec ibufidx           ;position back to char
1546
;
1547
.0000040 jsr ascbin            ;evaluate operand
1548
         bne monasc05          ;evaluated
1549
;
1550
         bcs monasc04          ;conversion error
1551
;
1552
         lda auxbufix          ;no operand...any preamble?
1553
         beq monasc06          ;no, syntax is okay so far
1554
;
1555
monasc04 jmp monasc10          ;abort w/error
1556
;
1557
monasc05 jsr facasize          ;size operand
1558
         cmp #s_dword          ;max is 24 bits
1559
         bcs monasc04          ;too big
1560
;
1561
         sta eopsize           ;save operand size
1562
         jsr facaoper          ;store operand
1563
;
1564
monasc06 dec ibufidx           ;back to last char
1565
         ldx auxbufix          ;mode buffer index
1566
         bne .0000010          ;preamble in buffer
1567
;
1568
         inx                   ;step past preamble position
1569
;
1570
.0000010 jsr getcharc          ;get a char w/forced UC
1571
         beq .0000030          ;EOI
1572
;
1573
         cpx #s_auxbuf         ;mode buffer full?
1574
         bcs monasc04          ;yes, too much input
1575
;
1576
.0000020 sta auxbuf,x          ;store for comparison
1577
         inx
1578
         bne .0000010
1579
;
1580
;
1581
;       evaluate mnemonic...
1582
;
1583
.0000030 ldx #n_mnemon-1       ;starting mnemonic index
1584
;
1585
monasc07 txa                   ;convert index...
1586
         asl                   ;to offset
1587
         tay                   ;now mnemonic table index
1588
         longa                 ;16 bit compare
1589
         lda mnetab,y          ;get mnemonic from table
1590
         cmp mnepck            ;compare to entered mnemonic
1591
         shorta                ;back to 8 bits
1592
         beq .0000020          ;match
1593
;
1594
.0000010 dex                   ;try next mnemonic
1595
         bmi monasc04          ;unknown mnemonic — error
1596
;
1597
         bra monasc07          ;keep going
1598
;
1599
.0000020 stx mnepck            ;save mnemonic index
1600
         txa
1601
         ldx #0                ;trial opcode
1602
;
1603
.0000030 cmp mnetabix,x        ;search index table...
1604
         beq .0000050          ;for a match
1605
;
1606
.0000040 inx                   ;keep going until we...
1607
         bne .0000030          ;search entire table
1608
;
1609
         bra monasc04          ;this shouldn't happen!
1610
;
1611
;       —————————————————————————————————————————————————————————————————————
1612
;       If the mnemonic index table search fails then there is a coding error
1613
;       somewhere, as every entry in the mnemonic table is supposed to have a
1614
;       matching cardinal index.
1615
;       —————————————————————————————————————————————————————————————————————
1616
;
1617
;
1618
;       evaluate addressing mode...
1619
;
1620
.0000050 stx opcode            ;save trial opcode
1621
         jsr instdata          ;get related instruction data
1622
         sta vopsflag          ;save 8/16 or relative flag
1623
         stx iopsize           ;operand size
1624
         inx
1625
         stx instsize          ;instruction size
1626
         ldx opcode            ;recover trial opcode
1627
         tya                   ;addressing mode
1628
         asl                   ;create table index
1629
         tay
1630
         longa
1631
         lda ms_lutab,y        ;mode lookup table
1632
         sta addrb             ;set pointer
1633
         shorta
1634
         ldy #0
1635
;
1636
.0000060 lda (addrb),y         ;table addressing mode
1637
         cmp auxbuf,y          ;entered addressing mode
1638
         beq .0000080          ;okay so far
1639
;
1640
.0000070 lda mnepck            ;reload mnemonic index
1641
         bra .0000040          ;wrong opcode for addresing mode
1642
;
1643
.0000080 ora #0                ;last char the terminator?
1644
         beq .0000090          ;yes, evaluate operand
1645
;
1646
         iny
1647
         bra .0000060          ;keep testing
1648
;
1649
;
1650
;       evaluate operand...
1651
;
1652
.0000090 lda eopsize           ;entered operand size
1653
         bne .0000100          ;non-zero
1654
;
1655
         ora iopsize           ;instruction operand size
1656
         bne .0000070          ;wrong opcode — keep trying
1657
;
1658
         bra monasc08          ;assemble instruction
1659
;
1660
.0000100 bit vopsflag          ;is this a branch?
1661
         bvs .0000160          ;yes, evaluate
1662
;
1663
         lda iopsize           ;instruction operand size
1664
         bit vopsflag          ;variable size operand allowed?
1665
         bmi .0000130          ;yes
1666
;
1667
         bit flimflag          ;was forced immediate set?
1668
         bpl .0000110          ;no
1669
;
1670
         jmp monasc10          ;yes — error
1671
;
1672
.0000110 cmp eopsize           ;entered operand size
1673
         bcc .0000070          ;operand too big
1674
;
1675
         sta eopsize           ;new operand size
1676
         bra monasc08          ;assemble, otherwise...
1677
;
1678
.0000120 cmp eopsize           ;exact size match required
1679
         bne .0000070          ;mismatch — wrong opcode
1680
;
1681
         bra monasc08          ;assemble
1682
;
1683
;
1684
;       process variable size immediate mode operand...
1685
;
1686
.0000130 ldx eopsize           ;entered operand size
1687
         cpx #s_xword          ;check size
1688
         bcs monasc10          ;too big — error
1689
;
1690
         bit flimflag          ;forced long immediate?
1691
         bpl .0000140          ;no
1692
;
1693
         ldx #s_word           ;promote operand size to...
1694
         stx eopsize           ;16 bits
1695
         bra .0000150
1696
;
1697
.0000140 cpx #s_word           ;16 bits?
1698
         bne .0000150          ;no
1699
;
1700
         ldy #flimmask         ;yes so force long...
1701
         sty flimflag          ;immediate disassembly
1702
;
1703
.0000150 ina                   ;new instruction operand size
1704
         cmp eopsize           ;compare against operand size
1705
         bcc .0000070          ;mismatch — can't assemble
1706
;
1707
         bra monasc08          ;okay, assemble
1708
;
1709
;
1710
;       process relative branch...
1711
;
1712
.0000160 jsr targoff           ;compute branch offset
1713
         bcs monasc10          ;branch out of range
1714
;
1715
         sta eopsize           ;effective operand size
1716
;
1717
;
1718
;       assemble instruction...
1719
;
1720
monasc08 lda opcode            ;opcode
1721
         stail addra           ;store at assembly address
1722
         ldx eopsize           ;any operand to process?
1723
         beq .0000020          ;no
1724
;
1725
         txy                   ;also storage offset
1726
;
1727
.0000010 dex
1728
         lda operand,x         ;get operand byte &...
1729
         staily addra          ;poke into memory
1730
         dey
1731
         bne .0000010          ;next
1732
;
1733
.0000020 lda #a_cr
1734
         jsr putcha            ;return to left margin
1735
         lda #asmprfx          ;assembly prefix
1736
         jsr dpycodaa          ;disassemble & display
1737
;
1738
;
1739
;       prompt for next instruction...
1740
;
1741
monasc09 lda #a_blank
1742
         ldx #ascprmct-1
1743
;
1744
.0000010 sta ibuffer,x         ;prepare buffer for...
1745
         dex                   ;next instruction
1746
         bpl .0000010
1747
;
1748
         lda #asmprfx          ;assemble code...
1749
         sta ibuffer           ;prompt prefix
1750
         lda addra+s_word      ;next instruction address bank
1751
         jsr binhex            ;convert to ASCII
1752
         sta ibuffer+apadrbkh  ;store MSN in buffer
1753
         stx ibuffer+apadrbkl  ;store LSN in buffer
1754
         lda addra+s_byte      ;next instruction address MSB
1755
         jsr binhex
1756
         sta ibuffer+apadrmbh
1757
         stx ibuffer+apadrmbl
1758
         lda addra             ;next instruction address LSB
1759
         jsr binhex
1760
         sta ibuffer+apadrlbh
1761
         stx ibuffer+apadrlbl
1762
         lda #ascprmct         ;effective input count
1763
         jmp moncea            ;reenter input loop
1764
;
1765
;
1766
;       process assembly error...
1767
;
1768
monasc10 jsr dpyerr            ;indicate error &...
1769
         bra monasc09          ;prompt w/same assembly address
1770
;
1771
;================================================================================
1772
;
1773
;mondsc: DISASSEMBLE CODE
1774
;
1775
;       —————————————————————————————
1776
;       syntax: D [ []]
1777
;       —————————————————————————————
1778
;
1779
mondsc   bcs .0000010          ;no parameters
1780
;
1781
         stz flimflag          ;reset to 8 bit mode
1782
         jsr facasize          ;check starting...
1783
         cmp #s_dword          ;address
1784
         bcs .0000050          ;out of range — error
1785
;
1786
         jsr facaddra          ;copy starting address
1787
         jsr getparm           ;get ending address
1788
         bcc .0000020          ;gotten
1789
;
1790
.0000010 jsr clrfaca           ;clear accumulator
1791
         longa
1792
         clc
1793
         lda addra             ;starting address
1794
         adcw n_dbytes         ;default bytes
1795
         sta faca              ;effective ending address
1796
         shorta
1797
         lda addra+s_word      ;starting bank
1798
         adc #0
1799
         sta faca+s_word       ;effective ending bank
1800
         bcs .0000050          ;end address > $FFFFFF
1801
;
1802
.0000020 jsr facasize          ;check ending...
1803
         cmp #s_dword          ;address
1804
         bcs .0000050          ;out of range — error
1805
;
1806
         jsr facaddrb          ;set ending address
1807
         jsr getparm           ;check for excess input
1808
         bcc .0000050          ;present — error
1809
;
1810
         jsr calccnt           ;calculate bytes
1811
         bcc .0000050          ;end < start
1812
;
1813
.0000030 jsr teststop          ;test for display stop
1814
         bcs .0000040          ;stopped
1815
;
1816
         jsr newline           ;next line
1817
         jsr dpycod            ;disassemble & display
1818
         jsr decdcnt           ;decrement byte count
1819
         bcc .0000030          ;not done
1820
;
1821
.0000040 jmp monce             ;back to main loop
1822
;
1823
.0000050 jmp monerr            ;address range error
1824
;
1825
;================================================================================
1826
;
1827
;monjmp: EXECUTE CODE
1828
;
1829
;       —————————————————————————————————————————————————————————————
1830
;       syntax: G []
1831
;
1832
;       If no address is specified, the current values in the PB & PC
1833
;       shadow registers are used.
1834
;       —————————————————————————————————————————————————————————————
1835
;
1836
monjmp   jsr setxaddr          ;set execution address
1837
         bcs monjmpab          ;out of range — error
1838
;
1839
         jsr getparm           ;check for excess input
1840
         bcc monjmpab          ;too much input — error
1841
;
1842
         longa                 ;16 bit .A
1843
         lda reg_spx
1844
         tcs                   ;restore SP
1845
;
1846
monjmpaa shorta
1847
         lda reg_pbx
1848
         pha                   ;restore PB
1849
         longa
1850
         lda reg_pcx
1851
         pha                   ;restore PC
1852
         shorta
1853
         lda reg_srx
1854
         pha                   ;restore SR
1855
         lda reg_dbx
1856
         pha
1857
         plb                   ;restore DB
1858
         longr
1859
         lda reg_dpx
1860
         tcd                   ;restore DP
1861
         lda reg_ax            ;restore .C
1862
         ldx reg_xx            ;restore .X
1863
         ldy reg_yx            ;restore .Y
1864
         rti                   ;execute code
1865
;
1866
monjmpab jmp monerr            ;error
1867
;
1868
;================================================================================
1869
;
1870
;monjsr: EXECUTE CODE AS SUBROUTINE
1871
;
1872
;       ————————————————————————————————————————————————————————————
1873
;       syntax: J []
1874
;
1875
;       If no address is specified the current values in the PB & PC
1876
;       shadow registers are used.   An RTS at the end of the called
1877
;       subroutine will return control to the monitor  provided  the
1878
;       stack remains in balance.
1879
;       ————————————————————————————————————————————————————————————
1880
;
1881
monjsr   jsr setxaddr          ;set execution address
1882
         bcs monjmpab          ;out of range — error
1883
;
1884
         jsr getparm           ;check for excess input
1885
         bcc monjmpab          ;too much input — error
1886
;
1887
         longa
1888
         lda reg_spx
1889
         tcs                   ;restore SP &...
1890
         jsr monjmpaa          ;call subroutine
1891
         php                   ;push SR
1892
         longr
1893
         sta reg_ax            ;save...
1894
         stx reg_xx            ;register...
1895
         sty reg_yx            ;returns
1896
         shortx                ;8 bit .X & .Y
1897
         plx                   ;get & save...
1898
         stx reg_srx           ;return SR
1899
         tsc                   ;get & save...
1900
         sta reg_spx           ;return SP
1901
         tdc                   ;get & save...
1902
         sta reg_dpx           ;DP pointer
1903
         shorta                ;8 bit .A
1904
         phk                   ;get &...
1905
         pla                   ;save...
1906
         sta reg_pbx           ;return PB
1907
         phb                   ;get &...
1908
         pla                   ;save...
1909
         sta reg_dbx           ;return DB
1910
         pea mm_rts            ;"*RET"
1911
         jmp moncom            ;return to monitor
1912
;
1913
;================================================================================
1914
;
1915
;monchm: CHANGE and/or DUMP MEMORY
1916
;
1917
;       ————————————————————————————————————————————
1918
;       syntax: > [  []...]
1919
;
1920
;       >  without operands will dump 16 bytes
1921
;       of memory, starting at .
1922
;       ————————————————————————————————————————————
1923
;
1924
monchm   bcs .0000030          ;no address given — quit
1925
;
1926
         jsr facasize          ;size address
1927
         cmp #s_dword
1928
         bcs .0000040          ;address out of range — error
1929
;
1930
         jsr facaddra          ;set starting address
1931
         jsr getpat            ;evaluate change pattern
1932
         bcc .0000010          ;entered
1933
;
1934
         bpl .0000020          ;not entered
1935
;
1936
         bra .0000040          ;evaluation error
1937
;
1938
.0000010 dey                   ;next byte
1939
         bmi .0000020          ;done
1940
;
1941
         lda auxbuf,y          ;write pattern...
1942
         staily addra          ;to memory
1943
         bra .0000010          ;next
1944
;
1945
.0000020 jsr newline           ;next line
1946
         jsr dpymem            ;regurgitate changes
1947
;
1948
.0000030 jmp monce             ;back to command loop
1949
;
1950
.0000040 jmp monerr            ;goto error handler
1951
;
1952
;================================================================================
1953
;
1954
;moncmp: COMPARE MEMORY
1955
;
1956
;       —————————————————————————————
1957
;       syntax: C   
1958
;       —————————————————————————————
1959
;
1960
moncmp   bcs .0000030          ;start not given — quit
1961
;
1962
         jsr enddest           ;get end & reference addresses
1963
         bcs .0000040          ;range or other error
1964
;
1965
         stz xrtemp            ;column counter
1966
;
1967
.0000010 jsr teststop          ;check for stop
1968
         bcs .0000030          ;abort
1969
;
1970
         ldail addra           ;get from reference location
1971
         cmpil operand         ;test against compare location
1972
         beq .0000020          ;match, don't display address
1973
;
1974
         jsr dpycaddr          ;display current location
1975
;
1976
.0000020 jsr nxtaddra          ;next reference location
1977
         bcs .0000030          ;done
1978
;
1979
         longa
1980
         inc operand           ;bump bits 0-15
1981
         shorta
1982
         bne .0000010
1983
;
1984
         inc operand+s_word    ;bump bits 16-23
1985
         bra .0000010
1986
;
1987
.0000030 jmp monce             ;return to command exec
1988
;
1989
.0000040 jmp monerr            ;goto error handler
1990
;
1991
;================================================================================
1992
;
1993
;moncpy: COPY (transfer) MEMORY
1994
;
1995
;       ————————————————————————————————
1996
;       syntax: T   
1997
;       ————————————————————————————————
1998
;
1999
moncpy   bcs .0000040          ;start not given — quit
2000
;
2001
         jsr enddest           ;get end & target addresses
2002
         bcs .0000050          ;range or other error
2003
;
2004
         longa
2005
         sec
2006
         lda addrb             ;ending address
2007
         sbc addra             ;starting address
2008
         bcc .0000050          ;start > end — error
2009
;
2010
         sta facb              ;bytes to copy
2011
         shorta
2012
         longx
2013
         lda operand+s_word    ;target bank
2014
         ldy operand           ;target address
2015
         cmp addra+s_word      ;source bank
2016
         longa
2017
         bne .0000020          ;can use forward copy
2018
;
2019
         cpy addra             ;source address
2020
         bcc .0000020          ;can use forward copy
2021
;
2022
         bne .0000010          ;must use reverse copy
2023
;
2024
         bra .0000050          ;copy in place — error
2025
;
2026
.0000010 lda facb              ;get bytes to copy
2027
         pha                   ;protect
2028
         jsr lodbnk            ;load banks
2029
         jsr cprvsup           ;do reverse copy setup
2030
         pla                   ;get bytes to copy
2031
         tax                   ;save a copy
2032
         clc
2033
         adc operand           ;change target to...
2034
         tay                   ;target end
2035
         txa                   ;recover bytes to copy
2036
         ldx addrb             ;source end
2037
         bra .0000030
2038
;
2039
.0000020 lda facb              ;get bytes to copy
2040
         pha                   ;protect
2041
         jsr lodbnk            ;load banks
2042
         jsr cpfwsup           ;do forward copy setup
2043
         pla                   ;get bytes to copy
2044
         ldx addra             ;source start
2045
;
2046
.0000030 jmp mcftwork          ;copy memory
2047
;
2048
.0000040 jmp monce             ;back to executive
2049
;
2050
.0000050 jmp monerr            ;error
2051
;
2052
;================================================================================
2053
;
2054
;mondmp: DISPLAY MEMORY RANGE
2055
;
2056
;       —————————————————————————————
2057
;       syntax: M [ []]
2058
;       —————————————————————————————
2059
;
2060
mondmp   bcs .0000010          ;no parameters
2061
;
2062
         jsr facasize          ;check address...
2063
         cmp #s_dword          ;range
2064
         bcs .0000050          ;address out of range
2065
;
2066
         jsr facaddra          ;copy starting address
2067
         jsr getparm           ;get ending address
2068
         bcc .0000020          ;gotten
2069
;
2070
.0000010 jsr clrfaca           ;clear accumulator
2071
         longa
2072
         clc
2073
         lda addra             ;starting address
2074
         adcw n_mbytes         ;default bytes
2075
         sta faca              ;effective ending address
2076
         shorta
2077
         lda addra+s_word      ;starting bank
2078
         adc #0
2079
         sta faca+s_word       ;effective ending bank
2080
         bcs .0000050          ;end address > $FFFFFF
2081
;
2082
.0000020 jsr facasize          ;check ending address...
2083
         cmp #s_dword          ;range
2084
         bcs .0000050          ;out of range — error
2085
;
2086
         jsr facaddrb          ;copy ending address
2087
         jsr getparm           ;check for excess input
2088
         bcc .0000050          ;error
2089
;
2090
         jsr calccnt           ;calculate bytes to dump
2091
         bcc .0000050          ;end < start
2092
;
2093
.0000030 jsr teststop          ;test for display stop
2094
         bcs .0000040          ;stopped
2095
;
2096
         jsr newline           ;next line
2097
         jsr dpymem            ;display
2098
         jsr decdcnt           ;decrement byte count
2099
         bcc .0000030          ;not done
2100
;
2101
.0000040 jmp monce             ;back to main loop
2102
;
2103
.0000050 jmp monerr            ;address range error
2104
;
2105
;================================================================================
2106
;
2107
;monfil: FILL MEMORY
2108
;
2109
;       —————————————————————————————————————————
2110
;       syntax: F   
2111
;
2112
;        &  must be in the same bank.
2113
;       —————————————————————————————————————————
2114
;
2115
monfil   bcs .0000010          ;start not given — quit
2116
;
2117
         jsr facasize          ;check size
2118
         cmp #s_dword
2119
         bcs .0000020          ;out of range — error...
2120
;
2121
         jsr facaddra          ;store start
2122
         jsr getparm           ;evaluate end
2123
         bcs .0000020          ;not entered — error
2124
;
2125
         jsr facasize          ;check size
2126
         cmp #s_dword
2127
         bcs .0000020          ;out of range — error
2128
;
2129
         lda faca+s_word       ;end bank
2130
         cmp addra+s_word      ;start bank
2131
         bne .0000020          ;not same — error
2132
;
2133
         jsr facaddrb          ;store 
2134
         longa
2135
         sec
2136
         lda addrb             ;ending address
2137
         sbc addra             ;starting address
2138
         bcc .0000020          ;start > end — error
2139
;
2140
         sta facb              ;bytes to copy
2141
         shorta
2142
         jsr getparm           ;evaluate 
2143
         bcs .0000020          ;not entered — error
2144
;
2145
         jsr facasize          ; should be...
2146
         cmp #s_word           ;8 bits
2147
         bcs .0000020          ;it isn't — error
2148
;
2149
         jsr facaoper          ;store 
2150
         jsr getparm           ;should be no more parameters
2151
         bcc .0000020          ;there are — error
2152
;
2153
         lda operand           ;
2154
         stail addra           ;fill 1st location
2155
         longr                 ;16 bit operations
2156
         lda facb              ;
2157
         beq .0000010          ;only 1 location — finished
2158
;
2159
         dea                   ;zero align &...
2160
         pha                   ;protect
2161
         shorta
2162
         lda addra+s_word      ;start bank
2163
         xba
2164
         lda addrb+s_word      ;end bank
2165
         jsr cpfwsup           ;do forward copy setup
2166
         pla                   ;recover fill count
2167
         ldx addra             ;fill-from starting location
2168
         txy
2169
         iny                   ;fill-to starting location
2170
         jmp mcftwork          ;fill memory
2171
;
2172
.0000010 jmp monce             ;goto command executive
2173
;
2174
.0000020 jmp monerr            ;goto error handler
2175
;
2176
;================================================================================
2177
;
2178
;monhnt: SEARCH (hunt) MEMORY
2179
;
2180
;       ———————————————————————————————————
2181
;       syntax: H   
2182
;       ———————————————————————————————————
2183
;
2184
monhnt   bcs .0000050          ;no start address
2185
;
2186
         jsr facasize          ;size starting address
2187
         cmp #s_dword
2188
         bcs .0000060          ;address out of range — error
2189
;
2190
         jsr facaddra          ;store starting address
2191
         jsr getparm           ;evaluate ending address
2192
         bcs .0000060          ;no address — error
2193
;
2194
         jsr facasize          ;size ending address
2195
         cmp #s_dword
2196
         bcs .0000060          ;address out of range — error
2197
;
2198
         jsr facaddrb          ;store ending address
2199
         jsr calccnt           ;calculate byte range
2200
         bcc .0000060          ;end < start
2201
;
2202
         jsr getpat            ;evaluate search pattern
2203
         bcs .0000060          ;error
2204
;
2205
         stz xrtemp            ;clear column counter
2206
;
2207
.0000010 jsr teststop          ;check for stop
2208
         bcs .0000050          ;abort
2209
;
2210
         ldy auxbufix          ;pattern index
2211
;
2212
.0000020 dey
2213
         bmi .0000030          ;pattern match
2214
;
2215
         ldaily addra          ;get from memory
2216
         cmp auxbuf,y          ;test against pattern
2217
         bne .0000040          ;mismatch, next location
2218
;
2219
         beq .0000020          ;match, keep testing
2220
;
2221
.0000030 jsr dpycaddr          ;display current location
2222
;
2223
.0000040 jsr nxtaddra          ;next location
2224
         bcc .0000010          ;not done
2225
;
2226
.0000050 jmp monce             ;back to executive
2227
;
2228
.0000060 jmp monerr            ;goto error handler
2229
;
2230
;================================================================================
2231
;
2232
;monenv: CONVERT NUMERIC VALUE
2233
;
2234
;       ——————————————————————
2235
;       syntax: 
2236
;       ——————————————————————
2237
;
2238
monenv   jsr getparmr          ;reread & evaluate parameter
2239
         bcs .0000020          ;none entered
2240
;
2241
         ldx #0                ;radix index
2242
         ldy #n_radix          ;number of radices
2243
;
2244
.0000010 phy                   ;save counter
2245
         phx                   ;save radix index
2246
         jsr newline           ;next line &...
2247
         jsr clearlin          ;clear it
2248
         lda #a_blank
2249
         ldx #halftab
2250
         jsr multspc           ;indent 1/2 tab
2251
         plx                   ;get radix index but...
2252
         phx                   ;put it back
2253
         lda radxtab,x         ;get radix
2254
         jsr binasc            ;convert to ASCII
2255
         phy                   ;string address MSB
2256
         phx                   ;string address LSB
2257
         jsr sprint            ;print
2258
         plx                   ;get index again
2259
         ply                   ;get counter
2260
         inx
2261
         dey
2262
         bne .0000010          ;no
2263
 
2264
.0000020 jmp monce             ;back to command exec
2265
;
2266
;================================================================================
2267
;
2268
;monchr: CHANGE REGISTERS
2269
;
2270
;       ——————————————————————————————————————————————————————
2271
;       syntax: ; [PB [PC [.S [.C [.X [.Y [SP [DP [DB]]]]]]]]]
2272
;
2273
;       ; with no parameters is the same as the R command.
2274
;       ——————————————————————————————————————————————————————
2275
;
2276
monchr   bcs .0000040          ;dump registers & quit
2277
;
2278
         ldy #0                ;register counter
2279
         sty facc              ;initialize register index
2280
;
2281
.0000010 jsr facasize          ;get parameter size
2282
         cmp rcvltab,y         ;check against size table
2283
         bcs .0000050          ;out of range
2284
;
2285
         lda rcvltab,y         ;determine number of bytes...
2286
         cmp #s_word+1         ;to store
2287
         ror facc+s_byte       ;condition flag
2288
         bpl .0000020          ;8 bit register size
2289
;
2290
         longa                 ;16 bit register size
2291
;
2292
.0000020 ldx facc              ;get register index
2293
         lda faca              ;get parm
2294
         sta reg_pbx,x         ;put in shadow storage
2295
         shorta
2296
         asl facc+s_byte       ;mode flag to carry
2297
         txa                   ;register index
2298
         adc #s_byte           ;at least 1 byte stored
2299
         sta facc              ;save new index
2300
         jsr getparm           ;get a parameter
2301
         bcs .0000040          ;EOI
2302
;
2303
         iny                   ;bump register count
2304
         cpy #n_regchv         ;all registers processed?
2305
         bne .0000010          ;no, keep going
2306
;
2307
.0000030 jsr alert             ;excessive input
2308
;
2309
.0000040 jmp monreg            ;display changes
2310
;
2311
.0000050 jmp monerr            ;goto error handler
2312
;
2313
;================================================================================
2314
;
2315
;monxit: EXIT TO OPERATING ENVIRONMENT
2316
;
2317
;       —————————
2318
;       syntax: X
2319
;       —————————
2320
;
2321
monxit   bcc .0000020          ;no parameters allowed
2322
;
2323
         longa
2324
         lda vecbrki           ;BRK indirect vector
2325
         cmpw monbrk           ;we intercept it?
2326
         bne .0000010          ;no, don't change it
2327
;
2328
         lda vecbrkia          ;old vector
2329
         sta vecbrki           ;restore it
2330
         stz vecbrkia          ;invalidate old vector
2331
;
2332
.0000010 shortr
2333
         jml vecexit           ;long jump to exit
2334
;
2335
.0000020 jmp monerr            ;goto error handler
2336
;
2337
; * * * * * * * * * * * * * * * * * * * * * * * *
2338
; * * * * * * * * * * * * * * * * * * * * * * * *
2339
; * *                                         * *
2340
; * * S T A R T   o f   S U B R O U T I N E S * *
2341
; * *                                         * *
2342
; * * * * * * * * * * * * * * * * * * * * * * * *
2343
; * * * * * * * * * * * * * * * * * * * * * * * *
2344
;
2345
;dpycaddr: DISPLAY CURRENT ADDRESS IN COLUMNS
2346
;
2347
dpycaddr ldx xrtemp            ;column count
2348
         bne .0000010          ;not at right side
2349
;
2350
         jsr newline           ;next row
2351
         ldx #n_hccols         ;max columns
2352
;
2353
.0000010 cpx #n_hccols         ;max columns
2354
         beq .0000020          ;at left margin
2355
;
2356
         lda #a_ht
2357
         jsr putcha            ;tab a column
2358
;
2359
.0000020 dex                   ;one less column
2360
         stx xrtemp            ;save column counter
2361
         jmp prntladr          ;print reference address
2362
;
2363
;================================================================================
2364
;
2365
;dpycod: DISASSEMBLE & DISPLAY CODE
2366
;
2367
;       ————————————————————————————————————————————————————————————————————————
2368
;       This function disassembles & displays the machine code at  the  location
2369
;       pointed to by ADDRA.  Upon return, ADDRA will point to the opcode of the
2370
;       next instruction.   The entry point at DPYCODAA  should be called with a
2371
;       disassembly prefix character loaded in .A.   If entered  at  DPYCOD, the
2372
;       default character will be display at the beginning of each  disassembled
2373
;       instruction.
2374
;
2375
;       The disassembly of immediate mode instructions that can take an 8 or  16
2376
;       bit operand is affected by the bit pattern that is  stored  in  FLIMFLAG
2377
;       upon entry to this function:
2378
;
2379
;           FLIMFLAG: xx000000
2380
;                     ||
2381
;                     |+—————————> 0:  8 bit .X or .Y operand
2382
;                     |            1: 16 bit .X or .Y operand
2383
;                     +——————————> 0:  8 bit .A or BIT # operand
2384
;                                  1: 16 bit .A or BIT # operand
2385
;
2386
;       FLIMFLAG is conditioned according to the operand of  the  most  recently
2387
;       disassembled REP or SEP instruction.   Hence repetitive  calls  to  this
2388
;       subroutine will usually result in the correct disassembly of 16 bit imm-
2389
;       ediate mode instructions.
2390
;       ————————————————————————————————————————————————————————————————————————
2391
;
2392
dpycod   lda #disprfx          ;default prefix
2393
;
2394
;
2395
;       alternate prefix display entry point...
2396
;
2397
dpycodaa jsr putcha            ;print prefix
2398
         jsr printspc          ;space
2399
         jsr prntladr          ;print long address
2400
         jsr printspc          ;space to opcode field
2401
         jsr getbyte           ;get opcode
2402
         sta opcode            ;save &...
2403
         jsr printbyt          ;display as hex
2404
;
2405
;
2406
;       decode menmonic & addressing info...
2407
;
2408
         ldx opcode            ;current mnemonic
2409
         lda mnetabix,x        ;get mnemonic index
2410
         asl                   ;double for...
2411
         tay                   ;mnemonic table offset
2412
         longa                 ;16 bit load
2413
         lda mnetab,y          ;copy encoded mnemonic to...
2414
         sta mnepck            ;working storage
2415
         shorta                ;back to 8 bits
2416
         jsr instdata          ;extract mode & size data
2417
         sta vopsflag          ;save mode flags
2418
         sty admodidx          ;save mode index
2419
         asl                   ;variable immediate instruction?
2420
         bcc dpycod01          ;no, effective operand size in .X
2421
;
2422
;
2423
;       determine immediate mode operand size...
2424
;
2425
         lda opcode            ;current opcode
2426
         bit flimflag          ;operand display mode
2427
         bpl .0000010          ;8 bit .A & BIT immediate mode
2428
;
2429
         and #aimmaska         ;determine if...
2430
         cmp #aimmaskb         ;.A or BIT immediate
2431
         beq .0000030          ;display 16 bit operand
2432
;
2433
         lda opcode            ;not .A or BIT immediate
2434
;
2435
.0000010 bvc dpycod01          ;8 bit .X/.Y immediate mode
2436
;
2437
         ldy #n_vopidx-1       ;opcodes to test
2438
;
2439
.0000020 cmp vopidx,y          ;looking for LDX #, CPY #, etc.
2440
         beq .0000040          ;disassemble a 16 bit operand
2441
;
2442
         dey
2443
         bpl .0000020          ;keep trying
2444
;
2445
         bra dpycod01          ;not .X or .Y immediate
2446
;
2447
.0000030 lda opcode            ;reload
2448
;
2449
.0000040 inx                   ;16 bit operand
2450
;
2451
;
2452
;       get & display operand bytes...
2453
;
2454
dpycod01 stx iopsize           ;operand size...
2455
         inx                   ;plus opcode becomes...
2456
         stx instsize          ;instruction size
2457
         stx charcnt           ;total bytes to process
2458
         lda #n_opcols+2       ;total operand columns plus WS
2459
         sta xrtemp            ;initialize counter
2460
         jsr clroper           ;clear operand
2461
         ldy iopsize           ;operand size
2462
         beq .0000020          ;no operand
2463
;
2464
         ldx #0                ;operand index
2465
;
2466
.0000010 jsr getbyte           ;get operand byte
2467
         sta operand,x         ;save
2468
         phx                   ;protect operand index
2469
         jsr printbyt          ;print operand byte
2470
         dec xrtemp            ;3 columns used, 2 for...
2471
         dec xrtemp            ;operand nybbles &...
2472
         dec xrtemp            ;1 for whitespace
2473
         plx                   ;get operand index
2474
         inx                   ;bump it
2475
         dey
2476
         bne .0000010          ;next
2477
;
2478
.0000020 ldx xrtemp            ;operand columns remaining
2479
         jsr multspc           ;space to mnemonic field
2480
;
2481
;
2482
;       display mnemonic...
2483
;
2484
         ldy #s_mnemon         ;size of ASCII mnemonic
2485
;
2486
.0000030 lda #0                ;initialize char
2487
         ldx #n_shfenc         ;shifts to execute
2488
;
2489
.0000040 asl mnepck            ;shift encoded mnemonic
2490
         rol mnepck+s_byte
2491
         rol
2492
         dex
2493
         bne .0000040
2494
;
2495
         adc #a_mnecvt         ;convert to ASCII &...
2496
         pha                   ;stash
2497
         dey
2498
         bne .0000030          ;continue with mnemonic
2499
;
2500
         ldy #s_mnemon
2501
;
2502
.0000050 pla                   ;get mnenmonic byte
2503
         jsr putcha            ;print it
2504
         dey
2505
         bne .0000050
2506
;
2507
;
2508
;       display operand...
2509
;
2510
         lda iopsize           ;operand size
2511
         beq clearlin          ;zero, disassembly finished
2512
;
2513
         jsr printspc          ;space to operand field
2514
         bit vopsflag          ;check mode flags
2515
         bvc dpycod02          ;not a branch
2516
;
2517
         jsr offtarg           ;compute branch target
2518
         ldx instsize          ;effective instruction size
2519
         dex
2520
         stx iopsize           ;effective operand size
2521
;
2522
dpycod02 stz vopsflag          ;clear
2523
         lda admodidx          ;instruction addressing mode
2524
         cmp #am_move          ;block move instruction?
2525
         bne .0000010          ;no
2526
;
2527
         ror vopsflag          ;yes
2528
;
2529
.0000010 asl                   ;convert addressing mode to...
2530
         tax                   ;symbology table index
2531
         longa                 ;do a 16 bit load
2532
         lda ms_lutab,x        ;addressing symbol pointer
2533
         pha
2534
         shorta                ;back to 8 bit loads
2535
         ldy #0
2536
         ldasi 1               ;get 1st char
2537
         cmp #a_blank
2538
         beq .0000020          ;no addresing mode preamble
2539
;
2540
         jsr putcha            ;print preamble
2541
;
2542
.0000020 lda #c_hex
2543
         jsr putcha            ;operand displayed as hex
2544
         ldy iopsize           ;operand size = index
2545
;
2546
.0000030 dey
2547
         bmi .0000040          ;done with operand
2548
;
2549
         lda operand,y         ;get operand byte
2550
         jsr dpyhex            ;print operand byte
2551
         bit vopsflag          ;block move?
2552
         bpl .0000030          ;no
2553
;
2554
         stz vopsflag          ;reset
2555
         phy                   ;protect operand index
2556
         pea ms_move
2557
         jsr sprint            ;display MVN/MVP operand separator
2558
         ply                   ;recover operand index again
2559
         bra .0000030          ;continue
2560
;
2561
.0000040 plx                   ;symbology LSB
2562
         ply                   ;symbology MSB
2563
         inx                   ;move past preamble
2564
         bne .0000050
2565
;
2566
         iny
2567
;
2568
.0000050 phy
2569
         phx
2570
         jsr sprint            ;print postamble, if any
2571
;
2572
;
2573
;       condition immediate mode display format...
2574
;
2575
dpycod03 lda operand           ;operand LSB
2576
         and #pfmxmask         ;isolate M & X bits
2577
         asl                   ;shift to match...
2578
         asl                   ;FLIMFLAG alignment
2579
         ldx opcode            ;current instruction
2580
         cpx #opc_rep          ;was it REP?
2581
         bne .0000010          ;no
2582
;
2583
         tsb flimflag          ;set flag bits as required
2584
         bra clearlin
2585
;
2586
.0000010 cpx #opc_sep          ;was it SEP?
2587
         bne clearlin          ;no, just exit
2588
;
2589
         trb flimflag          ;clear flag bits as required
2590
;
2591
;================================================================================
2592
;
2593
;clearlin: CLEAR DISPLAY LINE
2594
;
2595
clearlin pea dc_cl
2596
         bra dpyerraa
2597
;
2598
;================================================================================
2599
;
2600
;dpyibuf: DISPLAY MONITOR INPUT BUFFER CONTENTS
2601
;
2602
dpyibuf  pea ibuffer
2603
         bra dpyerraa
2604
;
2605
;================================================================================
2606
;
2607
;dpymem: DISPLAY MEMORY
2608
;
2609
;       ————————————————————————————————————————————————————————————
2610
;       This function displays 16 bytes of memory as hex values & as
2611
;       ASCII equivalents.  The starting address for the display is
2612
;       in ADDRA & is expected to be a 24 bit address.  Upon return,
2613
;       ADDRA will point to the start of the next 16 bytes.
2614
;       ————————————————————————————————————————————————————————————
2615
;
2616
dpymem   shortr
2617
         stz charcnt           ;reset
2618
         lda #memprfx
2619
         jsr putcha            ;display prefix
2620
         jsr prntladr          ;print 24 bit address
2621
         ldx #0                ;string buffer index
2622
         ldy #n_dump           ;bytes per line
2623
;
2624
.0000010 jsr getbyte           ;get from RAM, also...
2625
         pha                   ;save for decoding
2626
         phx                   ;save string index
2627
         jsr printbyt          ;display as hex ASCII
2628
         inc charcnt           ;bytes displayed +1
2629
         plx                   ;recover string index &...
2630
         pla                   ;byte
2631
         cmp #a_blank          ;printable?
2632
         bcc .0000020          ;no
2633
;
2634
         cmp #a_del
2635
         bcc .0000030          ;is printable
2636
;
2637
.0000020 lda #memsubch         ;substitute character
2638
;
2639
.0000030 sta ibuffer,x         ;save char
2640
         inx                   ;bump index
2641
         dey                   ;byte count -= 1
2642
         bne .0000010          ;not done
2643
;
2644
         stz ibuffer,x         ;terminate ASCII string
2645
         lda #memsepch
2646
         jsr putcha            ;separate ASCII from bytes
2647
         pea dc_bf
2648
         jsr sprint            ;select reverse video
2649
         jsr dpyibuf           ;display ASCII equivalents
2650
         pea dc_er             ;normal video
2651
         bra dpyerraa
2652
;
2653
;================================================================================
2654
;
2655
;dpyerr: DISPLAY ERROR SIGNAL
2656
;
2657
dpyerr   pea mm_err            ;"*ERR"
2658
;
2659
dpyerraa jsr sprint
2660
         rts
2661
;
2662
;================================================================================
2663
;
2664
;gendbs: GENERATE DESTRUCTIVE BACKSPACE
2665
;
2666
gendbs   pea dc_bs             ;destructive backspace
2667
         bra dpyerraa
2668
;
2669
;================================================================================
2670
;
2671
;prntladr: PRINT 24 BIT CURRENT ADDRESS
2672
;
2673
prntladr php                   ;protect register sizes
2674
         shorta
2675
         lda addra+s_word      ;get bank byte &...
2676
         jsr dpyhex            ;display it
2677
         longa
2678
         lda addra             ;get 16 bit address
2679
         plp                   ;restore register sizes
2680
;
2681
;================================================================================
2682
;
2683
;dpyhexw: DISPLAY BINARY WORD AS HEX ASCII
2684
;
2685
;       ————————————————————————————————————
2686
;       Preparatory Ops: .C: word to display
2687
;
2688
;       Returned Values: .C: used
2689
;                        .X: used
2690
;                        .Y: entry value
2691
;       ————————————————————————————————————
2692
;
2693
dpyhexw  php                   ;save register sizes
2694
         longa
2695
         pha                   ;protect value
2696
         shorta
2697
         xba                   ;get MSB &...
2698
         jsr dpyhex            ;display
2699
         longa
2700
         pla                   ;recover value
2701
         shorta                ;only LSB visible
2702
         plp                   ;reset register sizes
2703
;
2704
;================================================================================
2705
;
2706
;dpyhex: DISPLAY BINARY BYTE AS HEX ASCII
2707
;
2708
;       ————————————————————————————————————
2709
;       Preparatory Ops: .A: byte to display
2710
;
2711
;       Returned Values: .A: used
2712
;                        .X: used
2713
;                        .Y: entry value
2714
;       ————————————————————————————————————
2715
;
2716
dpyhex   jsr binhex            ;convert to hex ASCII
2717
         jsr putcha            ;print MSN
2718
         txa
2719
         jmp putcha            ;print LSN
2720
;
2721
;================================================================================
2722
;
2723
;multspc: PRINT MULTIPLE BLANKS
2724
;
2725
;       ————————————————————————————————————————————————
2726
;       Preparatory Ops : .X: number of blanks to print
2727
;
2728
;       Register Returns: none
2729
;
2730
;       Calling Example : ldx #3
2731
;                         jsr multspc    ;print 3 spaces
2732
;
2733
;       Notes: This sub will print 1 blank if .X=0.
2734
;       ————————————————————————————————————————————————
2735
;
2736
multspc  txa
2737
         bne .0000010          ;blank count specified
2738
;
2739
         inx                   ;default to 1 blank
2740
;
2741
.0000010 lda #a_blank
2742
;
2743
.0000020 jsr putcha
2744
         dex
2745
         bne .0000020
2746
;
2747
         rts
2748
;
2749
;================================================================================
2750
;
2751
;newline: PRINT NEWLINE (CRLF)
2752
;
2753
newline  pea dc_lf
2754
         bra dpyerraa
2755
;
2756
;================================================================================
2757
;
2758
;printbyt: PRINT A BYTE WITH LEADING SPACE
2759
;
2760
printbyt pha                   ;protect byte
2761
         jsr printspc          ;print leading space
2762
         pla                   ;restore &...
2763
         bra dpyhex            ;print byte
2764
;
2765
;================================================================================
2766
;
2767
;alert: ALERT USER w/TERMINAL BELL
2768
;
2769
alert    lda #a_bel
2770
         bra printcmn
2771
;
2772
;================================================================================
2773
;
2774
;printspc: PRINT A SPACE
2775
;
2776
printspc lda #a_blank
2777
;
2778
printcmn jmp putcha
2779
;
2780
;================================================================================
2781
;
2782
;sprint: PRINT NULL-TERMINATED CHARACTER STRING
2783
;
2784
;       —————————————————————————————————————————————————————————
2785
;       Preparatory Ops : SP+1: string address LSB
2786
;                         SP+2: string address MSB
2787
;
2788
;       Register Returns: .A: used
2789
;                         .B: entry value
2790
;                         .X: used
2791
;                         .Y: used
2792
;
2793
;       MPU Flags: NVmxDIZC
2794
;                  ||||||||
2795
;                  |||||||+———> 0: okay
2796
;                  |||||||      1: string too long (1)
2797
;                  ||||+++————> not defined
2798
;                  |||+———————> 1
2799
;                  ||+————————> 1
2800
;                  ++—————————> not defined
2801
;
2802
;       Example: PER STRING
2803
;                JSR SPRINT
2804
;                BCS TOOLONG
2805
;
2806
;       Notes: 1) Maximum permissible string length including the
2807
;                 terminator is 32,767 bytes.
2808
;              2) All registers are forced to 8 bits.
2809
;              3) DO NOT JUMP OR BRANCH INTO THIS FUNCTION!
2810
;       —————————————————————————————————————————————————————————
2811
;
2812
sprint   shorta                ;8 bit accumulator
2813
         longx                 ;16 bit index
2814
;
2815
;—————————————————————————————————————————————————————————
2816
.reetaddr =1                    ;return address
2817
 
2818
.src     =.reetaddr+s_word      ;string address stack offset
2819
 
2820
;—————————————————————————————————————————————————————————
2821
;
2822
         ldyw 0
2823
         clc                   ;no initial error
2824
;
2825
.0000010 ldasi .src            ;get a byte
2826
         beq .0000020          ;done
2827
;
2828
         jsr putcha            ;write to console port
2829
         iny
2830
         bpl .0000010          ;next
2831
;
2832
         sec                   ;string too long
2833
;
2834
.0000020 plx                   ;pull RTS address
2835
         ply                   ;clear string pointer
2836
         phx                   ;replace RTS
2837
         shortx
2838
         rts
2839
;
2840
;================================================================================
2841
;
2842
;ascbin: CONVERT NULL-TERMINATED ASCII NUMBER STRING TO BINARY
2843
;
2844
;       ———————————————————————————————————————————————————
2845
;       Preparatory Ops: ASCII number string in IBUFFER
2846
;
2847
;       Returned Values: FACA: converted parameter
2848
;                          .A: used
2849
;                          .X: used
2850
;                          .Y: used
2851
;                          .C: 1 = conversion error
2852
;                          .Z: 1 = nothing to convert
2853
;
2854
;       Notes: 1) Conversion stops when a non-numeric char-
2855
;                 acter is encountered.
2856
;              2) Radix symbols are as follows:
2857
;
2858
;                 % binary
2859
;                 @ octal
2860
;                 + decimal
2861
;                 $ hexadecimal
2862
;
2863
;                 Hex is the default if no radix is speci-
2864
;                 fied in the 1st character of the string.
2865
;       ———————————————————————————————————————————————————
2866
;
2867
ascbin   shortr
2868
         jsr clrfaca           ;clear accumulator
2869
         stz charcnt           ;zero char count
2870
         stz radix             ;initialize
2871
;
2872
;
2873
;       process radix if present...
2874
;
2875
         jsr getcharw          ;get next non-WS char
2876
         bne .0000010          ;got something
2877
;
2878
         clc                   ;no more input
2879
         rts
2880
;
2881
.0000010 ldx #n_radix-1        ;number of radices
2882
;
2883
.0000020 cmp radxtab,x         ;recognized radix?
2884
         beq .0000030          ;yes
2885
;
2886
         dex
2887
         bpl .0000020          ;try next
2888
;
2889
         dec ibufidx           ;reposition to previous char
2890
         inx                   ;not recognized, assume hex
2891
;
2892
.0000030 cmp #c_dec            ;decimal radix?
2893
         bne .0000040          ;not decimal
2894
;
2895
         ror radix             ;flag decimal conversion
2896
;
2897
.0000040 lda basetab,x         ;number bases table
2898
         sta range             ;set valid numeral range
2899
         lda bitsdtab,x        ;get bits per digit
2900
         sta bitsdig           ;store
2901
;
2902
;
2903
;       process numerals...
2904
;
2905
ascbin01 jsr getchar           ;get next char
2906
         beq ascbin03          ;EOI
2907
;
2908
         cmp #' '
2909
         beq ascbin03          ;blank — EOF
2910
;
2911
         cmp #','
2912
         beq ascbin03          ;comma — EOF
2913
;
2914
         cmp #a_ht
2915
         beq ascbin03          ;tab — EOF
2916
;
2917
         jsr nybtobin          ;change to binary
2918
         bcs ascbin04          ;not a recognized numeral
2919
;
2920
         cmp range             ;check range
2921
         bcs ascbin04          ;not valid for base
2922
;
2923
         sta numeral           ;save processed numeral
2924
         inc charcnt           ;bump numeral count
2925
         bit radix             ;working in base 10?
2926
         bpl .0000030          ;no
2927
;
2928
;
2929
;       compute N*2 for decimal conversion...
2930
;
2931
         ldx #0                ;accumulator index
2932
         ldy #s_pfac/2         ;iterations
2933
         longa
2934
         clc
2935
;
2936
.0000020 lda faca,x            ;N
2937
         rol                   ;N=N*2
2938
         sta facb,x
2939
         inx
2940
         inx
2941
         dey
2942
         bne .0000020
2943
;
2944
         bcs ascbin04          ;overflow — error
2945
;
2946
         shorta
2947
;
2948
;
2949
;       compute N*base for binary, octal or hex...
2950
;       or N*8 for decimal...
2951
;
2952
.0000030 ldx bitsdig           ;bits per digit
2953
         longa                 ;16 bit shifts
2954
;
2955
.0000040 asl faca
2956
         rol faca+s_word
2957
         bcs ascbin04          ;overflow — error
2958
;
2959
         dex
2960
         bne .0000040          ;next shift
2961
;
2962
         shorta                ;back to 8 bits
2963
         bit radix             ;check base
2964
         bpl ascbin02          ;not decimal
2965
;
2966
;
2967
;       compute N*10 for decimal (N*8 + N*2)...
2968
;
2969
         ldy #s_pfac
2970
         longa
2971
;
2972
.0000050 lda faca,x            ;N*8
2973
         adc facb,x            ;N*2
2974
         sta faca,x            ;now N*10
2975
         inx
2976
         inx
2977
         dey
2978
         bne .0000050
2979
;
2980
         bcs ascbin04          ;overflow — error
2981
;
2982
         shorta
2983
;
2984
;
2985
;       add current numeral to partial result...
2986
;
2987
ascbin02 lda faca              ;N
2988
         adc numeral           ;N=N+D
2989
         sta faca
2990
         ldx #1
2991
         ldy #s_pfac-1
2992
;
2993
.0000010 lda faca,x
2994
         adc #0                ;account for carry
2995
         sta faca,x
2996
         inx
2997
         dey
2998
         bne .0000010
2999
;
3000
         bcc ascbin01          ;next if no overflow
3001
;
3002
         bcs ascbin04          ;overflow — error
3003
;
3004
;
3005
;       finish up...
3006
;
3007
ascbin03 clc                   ;no error
3008
;
3009
ascbin04 shorta                ;reset if necessary
3010
         lda charcnt           ;load char count
3011
         rts                   ;done
3012
;
3013
;================================================================================
3014
;
3015
;bcdasc: CONVERT BCD DIGIT TO ASCII
3016
;
3017
;       ———————————————————————————————————————
3018
;       Preparatory Ops: .A: BCD digit, $00-$99
3019
;
3020
;       Returned Values: .A: ASCII MSD
3021
;                        .X: ASCII LSD
3022
;                        .Y: entry value
3023
;       ———————————————————————————————————————
3024
;
3025
bcdasc   jsr bintonyb          ;extract nybbles
3026
         pha                   ;save tens
3027
         txa
3028
         ora #btoamask         ;change units to ASCII
3029
         tax                   ;store
3030
         pla                   ;get tens
3031
         ora #btoamask         ;change to ASCII
3032
         rts
3033
;
3034
;================================================================================
3035
;
3036
;bintonyb: EXTRACT BINARY NYBBLES
3037
;
3038
;       —————————————————————————————————
3039
;       Preparatory Ops: .A: binary value
3040
;
3041
;       Returned Values: .A: MSN
3042
;                        .X: LSN
3043
;                        .Y: entry value
3044
;       —————————————————————————————————
3045
;
3046
bintonyb pha                   ;save
3047
         and #bcdumask         ;extract LSN
3048
         tax                   ;save it
3049
         pla
3050
;         .rept s_bnybbl        ;extract MSN
3051
           lsr
3052
           lsr
3053
           lsr
3054
           lsr
3055
;         .endr
3056
         rts
3057
;
3058
;================================================================================
3059
;
3060
;binasc: CONVERT 32-BIT BINARY TO NULL-TERMINATED ASCII NUMBER STRING
3061
;
3062
;       ——————————————————————————————————————————————————————
3063
;       Preparatory Ops: FACA: 32-bit operand
3064
;                          .A: radix character, w/bit 7 set to
3065
;                              suppress radix symbol in the
3066
;                              conversion string
3067
;
3068
;       Returned Values: ibuffer: conversion string
3069
;                             .A: string length
3070
;                             .X: string address LSB
3071
;                             .Y: string address MSB
3072
;
3073
;       Execution Notes: ibufidx & instsize are overwritten.
3074
;       ——————————————————————————————————————————————————————
3075
;
3076
binasc   stz ibufidx           ;initialize string index
3077
         stz instsize          ;clear format flag
3078
;
3079
;
3080
;       evaluate radix...
3081
;
3082
         asl                   ;extract format flag &...
3083
         ror instsize          ;save it
3084
         lsr                   ;extract radix character
3085
         ldx #n_radix-1        ;total radices
3086
;
3087
.0000010 cmp radxtab,x         ;recognized radix?
3088
         beq .0000020          ;yes
3089
;
3090
         dex
3091
         bpl .0000010          ;try next
3092
;
3093
         inx                   ;assume hex
3094
;
3095
.0000020 stx radix             ;save radix index for later
3096
         bit instsize
3097
         bmi .0000030          ;no radix symbol wanted
3098
;
3099
         lda radxtab,x         ;radix table
3100
         sta ibuffer           ;prepend to string
3101
         inc ibufidx           ;bump string index
3102
;
3103
.0000030 cmp #c_dec            ;converting to decimal?
3104
         bne .0000040          ;no
3105
;
3106
         jsr facabcd           ;convert operand to BCD
3107
         lda #0
3108
         bra .0000070          ;skip binary stuff
3109
;
3110
;
3111
;       prepare for binary, octal or hex conversion...
3112
;
3113
.0000040 ldx #0                ;operand index
3114
         ldy #s_sfac-1         ;workspace index
3115
;
3116
.0000050 lda faca,x            ;copy operand to...
3117
         sta facb,y            ;workspace in...
3118
         dey                   ;big-endian order
3119
         inx
3120
         cpx #s_pfac
3121
         bne .0000050
3122
;
3123
         lda #0
3124
         tyx
3125
;
3126
.0000060 sta facb,x            ;pad workspace
3127
         dex
3128
         bpl .0000060
3129
;
3130
;
3131
;       set up conversion parameters...
3132
;
3133
.0000070 sta facc              ;initialize byte counter
3134
         ldy radix             ;radix index
3135
         lda numstab,y         ;numerals in string
3136
         sta facc+s_byte       ;set remaining numeral count
3137
         lda bitsntab,y        ;bits per numeral
3138
         sta facc+s_word       ;set
3139
         lda lzsttab,y         ;leading zero threshold
3140
         sta facc+s_xword      ;set
3141
;
3142
;
3143
;       generate conversion string...
3144
;
3145
.0000080 lda #0
3146
         ldy facc+s_word       ;bits per numeral
3147
;
3148
.0000090 ldx #s_sfac-1         ;workspace size
3149
         clc                   ;avoid starting carry
3150
;
3151
.0000100 rol facb,x            ;shift out a bit...
3152
         dex                   ;from the operand or...
3153
         bpl .0000100          ;BCD conversion result
3154
;
3155
         rol                   ;bit to .A
3156
         dey
3157
         bne .0000090          ;more bits to grab
3158
;
3159
         tay                   ;if numeral isn't zero...
3160
         bne .0000110          ;skip leading zero tests
3161
;
3162
         ldx facc+s_byte       ;remaining numerals
3163
         cpx facc+s_xword      ;leading zero threshold
3164
         bcc .0000110          ;below it, must convert
3165
;
3166
         ldx facc              ;processed byte count
3167
         beq .0000130          ;discard leading zero
3168
;
3169
.0000110 cmp #10               ;check range
3170
         bcc .0000120          ;is 0-9
3171
;
3172
         adc #a_hexdec         ;apply hex adjust
3173
;
3174
.0000120 adc #'0'              ;change to ASCII
3175
         ldy ibufidx           ;string index
3176
         sta ibuffer,y         ;save numeral in buffer
3177
         inc ibufidx           ;next buffer position
3178
         inc facc              ;bytes=bytes+1
3179
;
3180
.0000130 dec facc+s_byte       ;numerals=numerals-1
3181
         bne .0000080          ;not done
3182
;
3183
;
3184
;       terminate string & exit...
3185
;
3186
         ldx ibufidx           ;printable string length
3187
         stz ibuffer,x         ;terminate string
3188
         txa
3189
         ldx #
3190
         ldy #>ibuffer
3191
         clc                   ;all okay
3192
         rts
3193
;
3194
;================================================================================
3195
;
3196
;binhex: CONVERT BINARY BYTE TO HEX ASCII CHARS
3197
;
3198
;       ————————————————————————————————————————————
3199
;       Preparatory Ops: .A: byte to convert
3200
;
3201
;       Returned Values: .A: MSN ASCII char
3202
;                        .X: LSN ASCII char
3203
;                        .Y: entry value
3204
;       ————————————————————————————————————————————
3205
;
3206
binhex   jsr bintonyb          ;generate binary values
3207
         pha                   ;save MSN
3208
         txa
3209
         jsr .0000010          ;generate ASCII LSN
3210
         tax                   ;save
3211
         pla                   ;get input
3212
;
3213
;
3214
;       convert nybble to hex ASCII equivalent...
3215
;
3216
.0000010 cmp #10
3217
         bcc .0000020          ;in decimal range
3218
;
3219
         adc #k_hex            ;hex compensate
3220
;
3221
.0000020 eor #'0'              ;finalize nybble
3222
         rts                   ;done
3223
;
3224
;================================================================================
3225
;
3226
;clrfaca: CLEAR FLOATING ACCUMULATOR A
3227
;
3228
clrfaca  php
3229
         longa
3230
         stz faca
3231
         stz faca+s_word
3232
         plp
3233
         rts
3234
;
3235
;================================================================================
3236
;
3237
;clrfacb: CLEAR FLOATING ACCUMULATOR B
3238
;
3239
clrfacb  php
3240
         longa
3241
         stz facb
3242
         stz facb+s_word
3243
         plp
3244
         rts
3245
;
3246
;================================================================================
3247
;
3248
;facabcd: CONVERT FACA INTO BCD
3249
;
3250
facabcd  ldx #s_pfac-1         ;primary accumulator size -1
3251
;
3252
.0000010 lda faca,x            ;value to be converted
3253
         pha                   ;preserve
3254
         dex
3255
         bpl .0000010          ;next
3256
;
3257
         ldx #s_sfac-1         ;workspace size
3258
;
3259
.0000020 stz facb,x            ;clear final result
3260
         stz facc,x            ;clear scratchpad
3261
         dex
3262
         bpl .0000020
3263
;
3264
         inc facc+s_sfac-s_byte
3265
         sed                   ;select decimal mode
3266
         ldy #m_bits-1         ;bits to convert -1
3267
;
3268
.0000030 ldx #s_pfac-1         ;operand size
3269
         clc                   ;no carry at start
3270
;
3271
.0000040 ror faca,x            ;grab LS bit in operand
3272
         dex
3273
         bpl .0000040
3274
;
3275
         bcc .0000060          ;LS bit clear
3276
;
3277
         clc
3278
         ldx #s_sfac-1
3279
;
3280
.0000050 lda facb,x            ;partial result
3281
         adc facc,x            ;scratchpad
3282
         sta facb,x            ;new partial result
3283
         dex
3284
         bpl .0000050
3285
;
3286
         clc
3287
;
3288
.0000060 ldx #s_sfac-1
3289
;
3290
.0000070 lda facc,x            ;scratchpad
3291
         adc facc,x            ;double &...
3292
         sta facc,x            ;save
3293
         dex
3294
         bpl .0000070
3295
;
3296
         dey
3297
         bpl .0000030          ;next operand bit
3298
;
3299
         cld
3300
         ldx #0
3301
         ldy #s_pfac
3302
;
3303
.0000080 pla                   ;operand
3304
         sta faca,x            ;restore
3305
         inx
3306
         dey
3307
         bne .0000080          ;next
3308
;
3309
         rts
3310
;
3311
;================================================================================
3312
;
3313
;nybtobin: CONVERT ASCII NYBBLE TO BINARY
3314
;
3315
nybtobin jsr toupper           ;convert case if necessary
3316
         sec
3317
         sbc #'0'              ;change to binary
3318
         bcc .0000020          ;not a numeral — error
3319
;
3320
         cmp #10
3321
         bcc .0000010          ;numeral is 0-9
3322
;
3323
         sbc #a_hexdec+1       ;10-15 ——> A-F
3324
         clc                   ;no conversion error
3325
;
3326
.0000010 rts
3327
;
3328
.0000020 sec                   ;conversion error
3329
         rts
3330
;
3331
;================================================================================
3332
;
3333
;calccnt: COMPUTE BYTE COUNT FROM ADDRESS RANGE
3334
;
3335
calccnt  jsr clrfacb           ;clear accumulator
3336
         longa
3337
         sec
3338
         lda addrb             ;ending address
3339
         sbc addra             ;starting address
3340
         sta facb              ;byte count
3341
         shorta
3342
         lda addrb+s_word      ;handle banks
3343
         sbc addra+s_word
3344
         sta facb+s_word
3345
         rts
3346
;
3347
;================================================================================
3348
;
3349
;clroper: CLEAR OPERAND
3350
;
3351
clroper  phx
3352
         ldx #s_oper-1
3353
;
3354
.0000010 stz operand,x
3355
         dex
3356
         bpl .0000010
3357
;
3358
         stz eopsize
3359
         plx
3360
         rts
3361
;
3362
;================================================================================
3363
;
3364
;cpfwsup: FOWARD COPY MEMORY SETUP
3365
;
3366
cpfwsup  longr
3367
         ldxw opc_mvn          ;"move next" opcode
3368
         bra cpsup
3369
;
3370
;================================================================================
3371
;
3372
;cprvsup: REVERSE COPY MEMORY SETUP
3373
;
3374
cprvsup  longr
3375
         ldxw opc_mvp          ;"move previous" opcode
3376
;
3377
;================================================================================
3378
;
3379
;cpsup: COPY MEMORY SETUP
3380
;
3381
cpsup    pha                   ;save banks
3382
         txa                   ;protect...
3383
         xba                   ;opcode
3384
         shorta
3385
         ldxw (cpcodeee-cpcode-1)
3386
;
3387
.0000010 ldalx cpcode          ;transfer copy code to...
3388
         sta mcftwork,x        ;to workspace
3389
         dex
3390
         bpl .0000010
3391
;
3392
         xba                   ;recover opcode &...
3393
         sta mcftopc           ;set it
3394
         longa
3395
         pla                   ;get banks &...
3396
         sta mcftbnk           ;set them
3397
 
3398
;-------------------------------------------------------------------------------
3399
; We just dynamically created a routine, so the cache (if one is present) has
3400
; to be invalidated. Otherwise the processor could execute dead code from the
3401
; cache. Two lines are invalidated in case the code crosses a line boundary.
3402
;
3403
; Parameters to ICacheIL816:
3404
;       acc = 16 bit address to invalidate
3405
;
3406
; The ICacheIL816 routine should invalidate the cache line and return. If there
3407
; is no cache in the processor then these lines can be deleted.
3408
;-------------------------------------------------------------------------------
3409
         pha
3410
         lda    #mcftwork
3411
         jsr    ICacheIL816
3412
         lda    #mcftwork+8
3413
         jsr    ICacheIL816
3414
         pla
3415
;---------------------------------------------
3416
         rts
3417
;
3418
;================================================================================
3419
;
3420
;cpcode: COPY MEMORY CODE
3421
;
3422
;       ———————————————————————————————————————————
3423
;       This code is transfered to workspace when a
3424
;       copy or fill operation is to be performed.
3425
;       ———————————————————————————————————————————
3426
;
3427
cpcode   phb                   ;must preserve data bank
3428
;         .rept s_mvinst
3429
           nop                 ;placeholder
3430
           nop
3431
           nop
3432
;         .endr
3433
         plb                   ;restore data bank
3434
         jml monce             ;return to command executive
3435
cpcodeee =*                    ;placeholder — do not delete
3436
;
3437
;================================================================================
3438
;
3439
;decdcnt: DECREMENT DUMP COUNT
3440
;
3441
;       ———————————————————————————————————————————
3442
;       Preparatory Ops: bytes to process in FACB
3443
;                        bytes processed in CHARCNT
3444
;
3445
;       Returned Values: .A: used
3446
;                        .X: entry value
3447
;                        .Y: entry value
3448
;                        .C: 1 = count = zero
3449
;       ———————————————————————————————————————————
3450
;
3451
decdcnt  shorta
3452
         lda #0
3453
         xba                   ;clear .B
3454
         lda facb+s_word       ;count MSW
3455
         longa
3456
         sec
3457
         ora facb              ;count LSW
3458
         beq .0000020          ;zero, just exit
3459
;
3460
         lda facb
3461
         sbc charcnt           ;bytes processed
3462
         sta facb
3463
         shorta
3464
         lda facb+s_word
3465
         sbc #0                ;handle borrow
3466
         bcc .0000010          ;underflow
3467
;
3468
         sta facb+s_word
3469
         clc                   ;count > 0
3470
         rts
3471
;
3472
.0000010 sec
3473
;
3474
.0000020 shorta
3475
         rts
3476
;
3477
;================================================================================
3478
;
3479
;enddest: GET 2ND & 3RD ADDRESSES FOR COMPARE & TRANSFER
3480
;
3481
enddest  jsr facasize          ;check start...
3482
         cmp #s_dword          ;for range
3483
         bcs .0000010          ;out of range — error
3484
;
3485
         jsr facaddra          ;store start
3486
         jsr getparm           ;get end
3487
         bcs .0000010          ;not entered — error
3488
;
3489
         jsr facasize          ;check end...
3490
         cmp #s_dword          ;for range
3491
         bcs .0000010          ;out of range — error
3492
;
3493
         jsr facaddrb          ;store end
3494
         jsr getparm           ;get destination
3495
         bcs .0000010          ;not entered — error
3496
;
3497
         jsr facasize          ;check destination...
3498
         cmp #s_dword          ;for range
3499
         bcc facaoper          ;store dest address
3500
;
3501
.0000010 rts                   ;exit w/error
3502
;
3503
;================================================================================
3504
;
3505
;facaddra: COPY FACA TO ADDRA
3506
;
3507
facaddra ldx #s_xword-1
3508
;
3509
.0000010 lda faca,x
3510
         sta addra,x
3511
         dex
3512
         bpl .0000010
3513
;
3514
         rts
3515
;
3516
;================================================================================
3517
;
3518
;facaddrb: COPY FACA TO ADDRB
3519
;
3520
facaddrb ldx #s_xword-1
3521
;
3522
.0000010 lda faca,x
3523
         sta addrb,x
3524
         dex
3525
         bpl .0000010
3526
;
3527
         rts
3528
;
3529
;================================================================================
3530
;
3531
;facaoper: COPY FACA TO OPERAND
3532
;
3533
facaoper ldx #s_oper-1
3534
;
3535
.0000010 lda faca,x
3536
         sta operand,x
3537
         dex
3538
         bpl .0000010
3539
;
3540
         rts
3541
;
3542
;================================================================================
3543
;
3544
;facasize: REPORT OPERAND SIZE IN FACA
3545
;
3546
;       ——————————————————————————————————————————
3547
;       Preparatory Ops: operand in FACA
3548
;
3549
;       Returned Values: .A: s_byte  (1)
3550
;                            s_word  (2)
3551
;                            s_xword (3)
3552
;                            s_dword (4)
3553
;
3554
;       Notes: 1) This function will always report
3555
;                 a non-zero result.
3556
;       ——————————————————————————————————————————
3557
;
3558
facasize shortr
3559
         ldx #s_dword-1
3560
;
3561
.0000010 lda faca,x            ;get byte
3562
         bne .0000020          ;done
3563
;
3564
         dex
3565
         bne .0000010          ;next byte
3566
;
3567
.0000020 inx                   ;count=index+1
3568
         txa
3569
         rts
3570
;
3571
;================================================================================
3572
;
3573
;getbyte: GET A BYTE FROM MEMORY
3574
;
3575
getbyte  ldail addra           ;get a byte
3576
         bra incaddra          ;bump address
3577
;
3578
;================================================================================
3579
;
3580
;getparm: GET A PARAMETER
3581
;
3582
;       —————————————————————————————————————————————————
3583
;       Preparatory Ops: null-terminated input in IBUFFER
3584
;
3585
;       Returned Values: .A: chars in converted parameter
3586
;                        .X: used
3587
;                        .Y: entry value
3588
;                        .C: 1 = no parameter entered
3589
;       —————————————————————————————————————————————————
3590
;
3591
getparmr dec ibufidx           ;reread previous char
3592
;
3593
getparm  phy                   ;preserve
3594
         jsr ascbin            ;convert parameter to binary
3595
         bcs .0000040          ;conversion error
3596
;
3597
         jsr getcharr          ;reread last char
3598
         bne .0000010          ;not end-of-input
3599
;
3600
         dec ibufidx           ;reindex to terminator
3601
         lda charcnt           ;get chars processed so far
3602
         beq .0000030          ;none
3603
;
3604
         bne .0000020          ;some
3605
;
3606
.0000010 cmp #a_blank          ;recognized delimiter
3607
         beq .0000020          ;end of parameter
3608
;
3609
         cmp #','              ;recognized delimiter
3610
         bne .0000040          ;unknown delimter
3611
;
3612
.0000020 clc
3613
         .byte bitzp           ;skip SEC below
3614
;
3615
.0000030 sec
3616
         ply                   ;restore
3617
         lda charcnt           ;get count
3618
         rts                   ;done
3619
;
3620
.0000040
3621
;.rept 3               ;clean up stack
3622
                        pla
3623
                        pla
3624
           pla
3625
;        .endr
3626
         jmp monerr            ;abort w/error
3627
;
3628
;================================================================================
3629
;
3630
;nxtaddra: TEST & INCREMENT WORKING ADDRESS 'A'
3631
;
3632
;       ——————————————————————————————————————————————————
3633
;       Calling syntax: JSR NXTADDRA
3634
;
3635
;       Exit registers: .A: used
3636
;                       .B: used
3637
;                       .X: entry value
3638
;                       .Y: entry value
3639
;                       DB: entry value
3640
;                       DP: entry value
3641
;                       PB: entry value
3642
;                       SR: NVmxDIZC
3643
;                           ||||||||
3644
;                           |||||||+———> 0: ADDRA < ADDRB
3645
;                           |||||||      1: ADDRA >= ADDRB
3646
;                           ||||||+————> undefined
3647
;                           |||+++—————> entry value
3648
;                           ||+————————> 1
3649
;                           ++—————————> undefined
3650
;       ——————————————————————————————————————————————————
3651
;
3652
nxtaddra shorta
3653
         lda addra+s_word      ;bits 16-23
3654
         cmp addrb+s_word
3655
         bcc incaddra          ;increment
3656
;
3657
         bne .0000010          ;don't increment
3658
;
3659
         longa
3660
         lda addra             ;bits 0-15
3661
         cmp addrb             ;condition flags
3662
         shorta
3663
         bcc incaddra          ;increment
3664
;
3665
.0000010 rts
3666
;
3667
;================================================================================
3668
;
3669
;incaddra: INCREMENT WORKING ADDRESS 'A'
3670
;
3671
;       ——————————————————————————————————————————————————
3672
;       Calling syntax: JSR INCADDRA
3673
;
3674
;       Exit registers: .A: entry value
3675
;                       .B: entry value
3676
;                       .X: entry value
3677
;                       .Y: entry value
3678
;                       DB: entry value
3679
;                       DP: entry value
3680
;                       PB: entry value
3681
;                       SR: NVmxDIZC
3682
;                           ||||||||
3683
;                           ++++++++———> entry value
3684
;       ——————————————————————————————————————————————————
3685
;
3686
incaddra php
3687
         longa
3688
         inc addra             ;bump bits 0-15
3689
         bne .0000010
3690
;
3691
         shorta
3692
         inc addra+s_word      ;bump bits 16-23
3693
;
3694
.0000010 plp
3695
         rts
3696
;
3697
;================================================================================
3698
;
3699
;incoper: INCREMENT OPERAND ADDRESS
3700
;
3701
incoper  clc
3702
         php
3703
         longr
3704
         pha
3705
         inc operand           ;handle base address
3706
         bne .0000010
3707
;
3708
         shorta
3709
         inc operand+s_word    ;handle bank
3710
         longa
3711
;
3712
.0000010 pla
3713
         plp
3714
         rts
3715
;
3716
;================================================================================
3717
;
3718
;instdata: GET INSTRUCTION SIZE & ADDRESSING MODE DATA
3719
;
3720
;       ——————————————————————————————————
3721
;       Preparatory Ops: .X: 65C816 opcode
3722
;
3723
;       Returned Values: .A: mode flags
3724
;                        .X: operand size
3725
;                        .Y: mode index
3726
;       ——————————————————————————————————
3727
;
3728
instdata shortr
3729
         lda mnetabam,x        ;addressing mode data
3730
         pha                   ;save mode flag bits
3731
         pha                   ;save size data
3732
         and #amodmask         ;extract mode index &...
3733
         tay                   ;save
3734
         pla                   ;recover data
3735
         and #opsmask          ;mask mode fields &...
3736
;         .rept n_opslsr        ;extract operand size
3737
           lsr
3738
           lsr
3739
           lsr
3740
           lsr
3741
;         .endr
3742
         tax                   ;operand size
3743
         pla                   ;recover mode flags
3744
         and #vopsmask         ;discard mode & size fields
3745
         rts
3746
;
3747
;================================================================================
3748
;
3749
;offtarg: CONVERT BRANCH OFFSET TO TARGET ADDRESS
3750
;
3751
;       ———————————————————————————————————————————————
3752
;       Preparatory Ops:    ADDRA: base address
3753
;                        INSTSIZE: instruction size
3754
;                         OPERAND: offset
3755
;
3756
;       Returned Values:  OPERAND: target address (L/H)
3757
;                              .A: used
3758
;                              .X: entry value
3759
;                              .Y: entry value
3760
;       ———————————————————————————————————————————————
3761
;
3762
offtarg  longa
3763
         lda addra             ;base address
3764
         shorta
3765
         lsr instsize          ;bit 0 will be set if...
3766
         bcs .0000010          ;a long branch
3767
;
3768
         bit operand           ;short forward or backward?
3769
         bpl .0000010          ;forward
3770
;
3771
         xba                   ;expose address MSB
3772
         dea                   ;back a page
3773
         xba                   ;expose address LSB
3774
;
3775
.0000010 longa
3776
         clc
3777
         adc operand           ;calculate target address
3778
         sta operand           ;new operand
3779
         shorta
3780
         lda #s_xword
3781
         sta instsize          ;effective instruction size
3782
         rts
3783
;
3784
;================================================================================
3785
;
3786
;setxaddr: SET EXECUTION ADDRESS
3787
;
3788
setxaddr bcs .0000010          ;no address given
3789
;
3790
         jsr facasize          ;check address...
3791
         cmp #s_dword          ;range
3792
         bcs .0000020          ;out of range
3793
;
3794
         longa
3795
         lda faca              ;execution address
3796
         sta reg_pcx           ;set new PC value
3797
         shorta
3798
         lda faca+s_word
3799
         sta reg_pbx           ;set new PB value
3800
;
3801
.0000010 clc                   ;no error
3802
;
3803
.0000020 rts
3804
;
3805
;================================================================================
3806
;
3807
;targoff: CONVERT BRANCH TARGET ADDRESS TO BRANCH OFFSET
3808
;
3809
;       —————————————————————————————————————————————————
3810
;       Preparatory Ops:   ADDRA: instruction address
3811
;                        OPERAND: target address
3812
;
3813
;       Returned Values: OPERAND: computed offset
3814
;                             .A: effective operand size
3815
;                             .X: entry value
3816
;                             .Y: entry value
3817
;                             .C: 1 = branch out of range
3818
;
3819
;       Execution notes: ADDRB is set to the branch base
3820
;                        address.
3821
;       —————————————————————————————————————————————————
3822
;
3823
targoff  stz instsize+s_byte   ;always zero
3824
         lda instsize          ;instruction size will tell...
3825
         lsr                   ;if long or short branch
3826
;
3827
;—————————————————————————————————————————————————
3828
.btype   =facc+5               ;branch type flag
3829
;—————————————————————————————————————————————————
3830
;
3831
         ror .btype            ;set branch type...
3832
;
3833
;       x0000000
3834
;       |
3835
;       +——————————> 0: short
3836
;                    1: long
3837
;
3838
         longa
3839
         clc
3840
         lda addra             ;instruction address
3841
         adc instsize          ;instruction size
3842
         sta addrb             ;base address
3843
         sec
3844
         lda operand           ;target address
3845
         sbc addrb             ;base address
3846
         sta operand           ;offset
3847
         shorta
3848
         bcc .0000040          ;backward branch
3849
;
3850
         bit .btype            ;check branch range
3851
         bmi .0000020          ;long
3852
;
3853
;
3854
;       process short forward branch...
3855
;
3856
         xba                   ;offset MSB should be zero
3857
         bne .0000060          ;it isn't — out of range
3858
;
3859
         xba                   ;offset LSB should be $00-$7F
3860
         bmi .0000060          ;it isn't — out of range
3861
;
3862
.0000010 lda #s_byte           ;final instruction size
3863
         clc                   ;branch in range
3864
         rts
3865
;
3866
;
3867
;       process long forward branch...
3868
;
3869
.0000020 xba                   ;offset MSB should be positive
3870
         bmi .0000060          ;it isn't — branch out of range
3871
;
3872
.0000030 lda #s_word
3873
         clc
3874
         rts
3875
;
3876
;
3877
;       process backward branch...
3878
;
3879
.0000040 bit .btype            ;long or short?
3880
         bmi .0000050          ;long
3881
;
3882
;
3883
;       process short backward branch...
3884
;
3885
         xba                   ;offset MSB should be negative
3886
         bpl .0000060          ;it isn't — out of range
3887
;
3888
         eor #@11111111        ;complement offset MSB 2s
3889
         bne .0000060          ;out of range
3890
;
3891
         xba                   ;offset LSB should be $80-$FF
3892
         bmi .0000010          ;it is — branch in range
3893
;
3894
         bra .0000060          ;branch out of range
3895
;
3896
;
3897
;       process long backward branch...
3898
;
3899
.0000050 xba                   ;offset MSB should be negative
3900
         bmi .0000030          ;it is — branch in range
3901
;
3902
.0000060 sec                   ;range error
3903
         rts
3904
;
3905
;================================================================================
3906
;
3907
;getcharr: GET PREVIOUS INPUT BUFFER CHARACTER
3908
;
3909
getcharr dec ibufidx           ;move back a char
3910
;
3911
;================================================================================
3912
;
3913
;getchar: GET A CHARACTER FROM INPUT BUFFER
3914
;
3915
;       ——————————————————————————————————————————————
3916
;       Preparatory Ops : none
3917
;
3918
;       Register Returns: .A: character or 
3919
;                         .B: entry value
3920
;                         .X: entry value
3921
;                         .Y: entry value
3922
;
3923
;       MPU Flags: NVmxDIZC
3924
;                  ||||||||
3925
;                  |||||||+———> entry value
3926
;                  ||||||+————> 1:  gotten
3927
;                  |||||+—————> entry value
3928
;                  ||||+——————> entry value
3929
;                  |||+———————> entry value
3930
;                  ||+————————> entry value
3931
;                  |+—————————> not defined
3932
;                  +——————————> not defined
3933
;       ——————————————————————————————————————————————
3934
;
3935
getchar  phx
3936
         phy
3937
         php                   ;save register sizes
3938
         shortr                ;force 8 bits
3939
         ldx ibufidx           ;buffer index
3940
         lda ibuffer,x         ;get char
3941
         inc ibufidx           ;bump index
3942
         plp                   ;restore register widths
3943
         ply
3944
         plx
3945
; Changed the following to XBA instruction which seems to work as well.
3946
; XBA doesn't access the stack memory saving a data memory access,
3947
; and hence is faster.
3948
         xba            ;       pha                   ;condition...
3949
         xba            ;   pla                   ;.Z
3950
         rts
3951
;
3952
;================================================================================
3953
;
3954
;getpat: GET PATTERN FOR MEMORY CHANGE or SEARCH
3955
;
3956
;       —————————————————————————————————————————————————————
3957
;       Preparatory Ops: Null-terminated pattern in IBUFFER.
3958
;
3959
;       Returned Values: .A: used
3960
;                        .X: used
3961
;                        .Y: pattern length if entered
3962
;                        .C: 0 = pattern valid
3963
;                            1 = exception:
3964
;                        .N  0 = no pattern entered
3965
;                            1 = evaluation error
3966
;
3967
;       Notes: 1) If pattern is preceded by "'" the following
3968
;                 characters are interpreted as ASCII.
3969
;              2) A maximum of 32 bytes or characters is
3970
;                 accepted.  Excess input will be discarded.
3971
;       —————————————————————————————————————————————————————
3972
;
3973
getpat   stz status            ;clear pattern type indicator
3974
         ldy #0                ;pattern index
3975
         jsr getcharr          ;get last char
3976
         beq .0000070          ;EOS
3977
;
3978
         ldx ibufidx           ;current buffer index
3979
         jsr getcharw          ;get next
3980
         beq .0000070          ;EOS
3981
;
3982
         cmp #'''
3983
         bne .0000010          ;not ASCII input
3984
;
3985
         ror status            ;condition flag
3986
         bra .0000030          ;balance of input is ASCII
3987
;
3988
.0000010 stx ibufidx           ;restore buffer index
3989
;
3990
.0000020 jsr getparm           ;evaluate numeric pattern
3991
         bcs .0000060          ;done w/pattern
3992
;
3993
         jsr facasize          ;size
3994
         cmp #s_word
3995
         bcs .0000070          ;not a byte — error
3996
;
3997
         lda faca              ;get byte &...
3998
         bra .0000040          ;store
3999
;
4000
.0000030 jsr getchar           ;get ASCII char
4001
         beq .0000060          ;done w/pattern
4002
;
4003
.0000040 cpy #s_auxbuf         ;pattern buffer full?
4004
         beq .0000050          ;yes
4005
;
4006
         sta auxbuf,y          ;store pattern
4007
         iny
4008
         bit status
4009
         bpl .0000020          ;get next numeric value
4010
;
4011
         bra .0000030          ;get next ASCII char
4012
;
4013
.0000050 jsr alert             ;excess input
4014
;
4015
.0000060 sty auxbufix          ;save pattern size
4016
         tya                   ;condition .Z
4017
         clc                   ;pattern valid
4018
         rts
4019
;
4020
;
4021
;       no pattern entered...
4022
;
4023
.0000070 rep @10000000
4024
         sec
4025
         rts
4026
;
4027
;
4028
;       evaluation error...
4029
;
4030
.0000080 sep @10000001
4031
         rts
4032
;
4033
;================================================================================
4034
;
4035
;getcharw: GET FROM INPUT BUFFER, DISCARDING WHITESPACE
4036
;
4037
;       ——————————————————————————————————————————————————
4038
;       Preparatory Ops: Null-terminated input in IBUFFER.
4039
;
4040
;       Returned Values: .A: char or null
4041
;                        .X: entry value
4042
;                        .Y: entry value
4043
;                        .Z: 1 = null terminator detected
4044
;
4045
;       Notes: Whitespace is defined as a blank ($20) or a
4046
;              horizontal tab ($09).
4047
;       ——————————————————————————————————————————————————
4048
;
4049
getcharw jsr getchar           ;get from buffer
4050
         beq .0000010          ;EOI
4051
;
4052
         cmp #' '
4053
         beq getcharw          ;discard whitespace
4054
;
4055
         cmp #a_ht             ;also whitespace
4056
         beq getcharw
4057
;
4058
.0000010 clc
4059
         rts
4060
;
4061
;================================================================================
4062
;
4063
;input: INTERACTIVE INPUT FROM CONSOLE CHANNEL
4064
;
4065
;       ———————————————————————————————————————————————————————————
4066
;       Preparatory Ops: Zero IBUFIDX or load IBUFFER with default
4067
;                        input & set IBUFIDX to the number of chars
4068
;                        loaded into the buffer.
4069
;
4070
;       Returned Values: .A: used
4071
;                        .X: characters entered
4072
;                        .Y: used
4073
;
4074
;       Example: STZ IBUFIDX
4075
;                JSR INPUT
4076
;
4077
;       Notes: Input is collected in IBUFFER & is null-terminated.
4078
;              IBUFIDX is reset to zero upon exit.
4079
;       ———————————————————————————————————————————————————————————
4080
;
4081
input:
4082
            ldx ibufidx
4083
         stz ibuffer,x         ;be sure buffer is terminated
4084
         jsr dpyibuf           ;print default input if any
4085
         pea dc_cn
4086
         jsr sprint            ;enable cursor
4087
         ldx ibufidx           ;starting buffer index
4088
;
4089
;
4090
;       main input loop...
4091
;
4092
.0000010 jsr getcha            ;poll for input
4093
         bcc .0000020          ;got something
4094
;
4095
         jsr    $F409          ;wait 'til any IRQ &... (Reschedule tasks)
4096
         bra .0000010          ;try again
4097
;
4098
.0000020 cmp #a_del            ;above ASCII range?
4099
         bcs .0000010          ;yes, ignore
4100
;
4101
         cmp #a_ht             ;horizontal tab?
4102
         bne .0000030          ;no
4103
;
4104
         lda #a_blank          ;replace  w/blank
4105
;
4106
.0000030 cmp #a_blank          ;control char?
4107
         bcc .0000050          ;yes
4108
;
4109
;
4110
;       process QWERTY character...
4111
;
4112
         cpx #s_ibuf           ;room in buffer?
4113
         bcs .0000040          ;no
4114
;
4115
         sta ibuffer,x         ;store char
4116
         inx                   ;bump index
4117
         .byte bitabs          ;echo char
4118
;
4119
.0000040 lda #a_bel            ;alert user
4120
         jsr putcha
4121
         bra .0000010          ;get some more
4122
;
4123
;
4124
;       process carriage return...
4125
;
4126
.0000050 cmp #a_cr             ;carriage return?
4127
         bne .0000060          ;no
4128
;
4129
         phx                   ;protect input count
4130
         pea dc_co
4131
         jsr sprint            ;cursor off
4132
         plx                   ;recover input count
4133
         stz ibuffer,x         ;terminate input &...
4134
         stz ibufidx           ;reset buffer index
4135
         rts                   ;done
4136
;
4137
;
4138
;       process backspace...
4139
;
4140
.0000060 cmp #a_bs             ;backspace?
4141
         bne .0000010          ;no
4142
;
4143
         txa
4144
         beq .0000010          ;no input, ignore 
4145
;
4146
         dex                   ;1 less char
4147
         phx                   ;preserve count
4148
         jsr gendbs            ;destructive backspace
4149
         plx                   ;restore count
4150
         bra .0000010          ;get more input
4151
;
4152
;================================================================================
4153
;
4154
;lodbnk: LOAD SOURCE & DESTINATION BANKS
4155
;
4156
lodbnk   shorta
4157
         lda operand+s_word    ;destination bank
4158
         xba                   ;make it MSB
4159
         lda addra+s_word      ;source bank is LSB
4160
         rts
4161
;
4162
;================================================================================
4163
;
4164
;getcharc: GET A CHARACTER FROM INPUT BUFFER & CONVERT CASE
4165
;
4166
;       ——————————————————————————————————————————————————
4167
;       Preparatory Ops: Null-terminated input in IBUFFER.
4168
;
4169
;       Returned Values: .A: char or null
4170
;                        .X: entry value
4171
;                        .Y: entry value
4172
;                        .Z: 1 = null terminator detected
4173
;       ——————————————————————————————————————————————————
4174
;
4175
getcharc jsr getchar           ;get from buffer
4176
         beq touppera          ;just return
4177
;
4178
;================================================================================
4179
;
4180
;toupper: FORCE CHARACTER TO UPPER CASE
4181
;
4182
;       ————————————————————————————————————————————————
4183
;       Preparatory Ops : .A: character to convert
4184
;
4185
;       Register Returns: .A: converted character
4186
;                         .B: entry value
4187
;                         .X: entry value
4188
;                         .Y: entry value
4189
;
4190
;       MPU Flags: no change
4191
;
4192
;       Notes: 1) This subroutine has no effect on char-
4193
;                 acters that are not alpha.
4194
;       ————————————————————————————————————————————————
4195
;
4196
toupper  php                   ;protect flags
4197
         cmp #a_asclcl         ;check char range
4198
         bcc .0000010          ;not LC alpha
4199
;
4200
         cmp #a_asclch+s_byte
4201
         bcs .0000010          ;not LC alpha
4202
;
4203
         and #a_lctouc         ;force to UC
4204
;
4205
.0000010 plp                   ;restore flags
4206
;
4207
touppera rts
4208
;
4209
;================================================================================
4210
;
4211
;teststop: TEST FOR STOP KEY
4212
;
4213
;       ——————————————————————————————————————————————
4214
;       Preparatory Ops: none
4215
;
4216
;       Returned Values: .A: detected keypress, if any
4217
;                        .X: entry value
4218
;                        .Y: entry value
4219
;
4220
;       MPU Flags: NVmxDIZC
4221
;                  ||||||||
4222
;                  |||||||+———> 0: normal key detected
4223
;                  |||||||      1:  detected
4224
;                  +++++++————> not defined
4225
;
4226
;       Example: jsr teststop
4227
;                bcs stopped
4228
;
4229
;       Notes: The symbol STOPKEY defines the ASCII
4230
;              value of the "stop key."
4231
;       ——————————————————————————————————————————————
4232
;
4233
teststop jsr getcha            ;poll console
4234
         bcs .0000010          ;no input
4235
;
4236
         cmp #stopkey          ;stop key pressed?
4237
         beq .0000020          ;yes
4238
;
4239
.0000010 clc
4240
;
4241
.0000020 rts
4242
;
4243
;================================================================================
4244
;
4245
;COMMAND PROCESSING DATA TABLES
4246
;
4247
;
4248
;       monitor commands...
4249
;
4250
mpctab   .byte "A"             ;assemble code
4251
         .byte "C"             ;compare memory ranges
4252
         .byte "D"             ;disassemble code
4253
         .byte "F"             ;fill memory
4254
         .byte "G"             ;execute code
4255
         .byte "H"             ;search memory
4256
         .byte "J"             ;execute code as subroutine
4257
         .byte "M"             ;dump memory range
4258
         .byte "R"             ;dump registers
4259
         .byte "T"             ;copy memory range
4260
         .byte "X"             ;exit from monitor
4261
         .byte ">"             ;change memory
4262
         .byte ";"             ;change registers
4263
n_mpctab =*-mpctab             ;entries in above table
4264
;
4265
;
4266
;       monitor command jump table...
4267
;
4268
mpcextab .word monasc-s_byte   ; A  assemble code
4269
         .word moncmp-s_byte   ; C  compare memory ranges
4270
         .word mondsc-s_byte   ; D  disassemble code
4271
         .word monfil-s_byte   ; F  fill memory
4272
         .word monjmp-s_byte   ; G  execute code
4273
         .word monhnt-s_byte   ; H  search memory
4274
         .word monjsr-s_byte   ; J  execute code as subroutine
4275
         .word mondmp-s_byte   ; M  dump memory range
4276
         .word monreg-s_byte   ; R  dump registers
4277
         .word moncpy-s_byte   ; T  copy memory range
4278
         .word monxit-s_byte   ; X  exit from monitor
4279
         .word monchm-s_byte   ; >  change memory
4280
         .word monchr-s_byte   ; ;  change registers
4281
;
4282
;
4283
;       number conversion...
4284
;
4285
basetab  .byte 16,10,8,2       ;supported number bases
4286
bitsdtab .byte 4,3,3,1         ;bits per binary digit
4287
bitsntab .byte 4,4,3,1         ;bits per ASCII character
4288
lzsttab  .byte 3,2,9,2         ;leading zero suppression thresholds
4289
numstab  .byte 12,12,16,48     ;bin to ASCII conversion numerals
4290
radxtab  .byte c_hex           ;hexadecimal radix
4291
         .byte c_dec           ;decimal radix
4292
         .byte c_oct           ;octal radix
4293
         .byte c_bin           ;binary radix
4294
n_radix  =*-radxtab            ;number of recognized radices
4295
;
4296
;
4297
;       shadow MPU register sizes...
4298
;
4299
rcvltab  .byte s_mpupbx+s_byte ; PB
4300
         .byte s_mpupcx+s_byte ; PC
4301
         .byte s_mpusrx+s_byte ; SR
4302
         .byte s_word+s_byte   ; .C
4303
         .byte s_word+s_byte   ; .X
4304
         .byte s_word+s_byte   ; .Y
4305
         .byte s_mpuspx+s_byte ; SP
4306
         .byte s_mpudpx+s_byte ; DP
4307
         .byte s_mpudbx+s_byte ; DB
4308
n_regchv =*-rcvltab            ;total shadow registers
4309
;
4310
;================================================================================
4311
;
4312
;ASSEMBLER/DISASSEMBLER DATA TABLES
4313
;
4314
;
4315
;       numerically sorted & encoded W65C816S mnemonics...
4316
;
4317
mnetab   .word mne_xba         ;  0 — XBA
4318
         .word mne_lda         ;  1 — LDA
4319
         .word mne_pea         ;  2 — PEA
4320
         .word mne_pha         ;  3 — PHA
4321
         .word mne_pla         ;  4 — PLA
4322
         .word mne_bra         ;  5 — BRA
4323
         .word mne_ora         ;  6 — ORA
4324
         .word mne_sta         ;  7 — STA
4325
         .word mne_txa         ;  8 — TXA
4326
         .word mne_tya         ;  9 — TYA
4327
         .word mne_phb         ; 10 — PHB
4328
         .word mne_plb         ; 11 — PLB
4329
         .word mne_trb         ; 12 — TRB
4330
         .word mne_tsb         ; 13 — TSB
4331
         .word mne_sbc         ; 14 — SBC
4332
         .word mne_bcc         ; 15 — BCC
4333
         .word mne_adc         ; 16 — ADC
4334
         .word mne_tdc         ; 17 — TDC
4335
         .word mne_dec         ; 18 — DEC
4336
         .word mne_sec         ; 19 — SEC
4337
         .word mne_clc         ; 20 — CLC
4338
         .word mne_inc         ; 21 — INC
4339
         .word mne_tsc         ; 22 — TSC
4340
         .word mne_bvc         ; 23 — BVC
4341
         .word mne_tcd         ; 24 — TCD
4342
         .word mne_sed         ; 25 — SED
4343
         .word mne_phd         ; 26 — PHD
4344
         .word mne_cld         ; 27 — CLD
4345
         .word mne_pld         ; 28 — PLD
4346
         .word mne_and         ; 29 — AND
4347
         .word mne_xce         ; 30 — XCE
4348
         .word mne_bne         ; 31 — BNE
4349
         .word mne_wai         ; 32 — WAI
4350
         .word mne_pei         ; 33 — PEI
4351
         .word mne_sei         ; 34 — SEI
4352
         .word mne_cli         ; 35 — CLI
4353
         .word mne_bmi         ; 36 — BMI
4354
         .word mne_rti         ; 37 — RTI
4355
         .word mne_phk         ; 38 — PHK
4356
         .word mne_brk         ; 39 — BRK
4357
         .word mne_jml         ; 40 — JML
4358
         .word mne_rol         ; 41 — ROL
4359
         .word mne_bpl         ; 42 — BPL
4360
         .word mne_brl         ; 43 — BRL
4361
         .word mne_asl         ; 44 — ASL
4362
         .word mne_jsl         ; 45 — JSL
4363
         .word mne_rtl         ; 46 — RTL
4364
         .word mne_wdm         ; 47 — WDM
4365
         .word mne_mvn         ; 48 — MVN
4366
         .word mne_rep         ; 49 — REP
4367
         .word mne_sep         ; 50 — SEP
4368
         .word mne_php         ; 51 — PHP
4369
         .word mne_plp         ; 52 — PLP
4370
         .word mne_cmp         ; 53 — CMP
4371
         .word mne_jmp         ; 54 — JMP
4372
         .word mne_cop         ; 55 — COP
4373
         .word mne_nop         ; 56 — NOP
4374
         .word mne_stp         ; 57 — STP
4375
         .word mne_mvp         ; 58 — MVP
4376
         .word mne_beq         ; 59 — BEQ
4377
         .word mne_per         ; 60 — PER
4378
         .word mne_eor         ; 61 — EOR
4379
         .word mne_ror         ; 62 — ROR
4380
         .word mne_jsr         ; 63 — JSR
4381
         .word mne_lsr         ; 64 — LSR
4382
         .word mne_bcs         ; 65 — BCS
4383
         .word mne_tcs         ; 66 — TCS
4384
         .word mne_rts         ; 67 — RTS
4385
         .word mne_bvs         ; 68 — BVS
4386
         .word mne_txs         ; 69 — TXS
4387
         .word mne_bit         ; 70 — BIT
4388
         .word mne_clv         ; 71 — CLV
4389
         .word mne_tax         ; 72 — TAX
4390
         .word mne_ldx         ; 73 — LDX
4391
         .word mne_dex         ; 74 — DEX
4392
         .word mne_phx         ; 75 — PHX
4393
         .word mne_plx         ; 76 — PLX
4394
         .word mne_inx         ; 77 — INX
4395
         .word mne_cpx         ; 78 — CPX
4396
         .word mne_tsx         ; 79 — TSX
4397
         .word mne_stx         ; 80 — STX
4398
         .word mne_tyx         ; 81 — TYX
4399
         .word mne_tay         ; 82 — TAY
4400
         .word mne_ldy         ; 83 — LDY
4401
         .word mne_dey         ; 84 — DEY
4402
         .word mne_phy         ; 85 — PHY
4403
         .word mne_ply         ; 86 — PLY
4404
         .word mne_iny         ; 87 — INY
4405
         .word mne_cpy         ; 88 — CPY
4406
         .word mne_sty         ; 89 — STY
4407
         .word mne_txy         ; 90 — TXY
4408
         .word mne_stz         ; 91 — STZ
4409
;
4410
s_mnetab =*-mnetab             ;mnemonic table size
4411
n_mnemon =s_mnetab/s_word      ;total mnemonics
4412
;
4413
;
4414
;       mnemonic lookup indices in opcode order...
4415
;
4416
mnetabix .byte mne_brkx        ; $00  BRK
4417
         .byte mne_orax        ; $01  ORA (dp,X)
4418
         .byte mne_copx        ; $02  COP
4419
         .byte mne_orax        ; $03  ORA offset,S
4420
         .byte mne_tsbx        ; $04  TSB dp
4421
         .byte mne_orax        ; $05  ORA dp
4422
         .byte mne_aslx        ; $06  ASL dp
4423
         .byte mne_orax        ; $07  ORA [dp]
4424
         .byte mne_phpx        ; $08  PHP
4425
         .byte mne_orax        ; $09  ORA #
4426
         .byte mne_aslx        ; $0A  ASL A
4427
         .byte mne_phdx        ; $0B  PHD
4428
         .byte mne_tsbx        ; $0C  TSB abs
4429
         .byte mne_orax        ; $0D  ORA abs
4430
         .byte mne_aslx        ; $0E  ASL abs
4431
         .byte mne_orax        ; $0F  ORA absl
4432
;
4433
         .byte mne_bplx        ; $10  BPL abs
4434
         .byte mne_orax        ; $11  ORA (dp),Y
4435
         .byte mne_orax        ; $12  ORA (dp)
4436
         .byte mne_orax        ; $13  ORA (offset,S),Y
4437
         .byte mne_trbx        ; $14  TRB dp
4438
         .byte mne_orax        ; $15  ORA dp,X
4439
         .byte mne_aslx        ; $16  ASL dp,X
4440
         .byte mne_orax        ; $17  ORA [dp],Y
4441
         .byte mne_clcx        ; $18  CLC
4442
         .byte mne_orax        ; $19  ORA abs
4443
         .byte mne_incx        ; $1A  INC A
4444
         .byte mne_tcsx        ; $1B  TCS
4445
         .byte mne_trbx        ; $1C  TRB abs
4446
         .byte mne_orax        ; $1D  ORA abs,X
4447
         .byte mne_aslx        ; $1E  ASL abs,X
4448
         .byte mne_orax        ; $1F  ORA absl,X
4449
;
4450
         .byte mne_jsrx        ; $20  JSR abs
4451
         .byte mne_andx        ; $21  AND (dp,X)
4452
         .byte mne_jslx        ; $22  JSL absl
4453
         .byte mne_andx        ; $23  AND offset,S
4454
         .byte mne_bitx        ; $24  BIT dp
4455
         .byte mne_andx        ; $25  AND dp
4456
         .byte mne_rolx        ; $26  ROL dp
4457
         .byte mne_andx        ; $27  AND [dp]
4458
         .byte mne_plpx        ; $28  PLP
4459
         .byte mne_andx        ; $29  AND #
4460
         .byte mne_rolx        ; $2A  ROL A
4461
         .byte mne_pldx        ; $2B  PLD
4462
         .byte mne_bitx        ; $2C  BIT abs
4463
         .byte mne_andx        ; $2D  AND abs
4464
         .byte mne_rolx        ; $2E  ROL abs
4465
         .byte mne_andx        ; $2F  AND absl
4466
;
4467
         .byte mne_bmix        ; $30  BMI abs
4468
         .byte mne_andx        ; $31  AND (dp),Y
4469
         .byte mne_andx        ; $32  AND (dp)
4470
         .byte mne_andx        ; $33  AND (offset,S),Y
4471
         .byte mne_bitx        ; $34  BIT dp,X
4472
         .byte mne_andx        ; $35  AND dp,X
4473
         .byte mne_rolx        ; $36  ROL dp,X
4474
         .byte mne_andx        ; $37  AND [dp],Y
4475
         .byte mne_secx        ; $38  SEC
4476
         .byte mne_andx        ; $39  AND abs,Y
4477
         .byte mne_decx        ; $3A  DEC A
4478
         .byte mne_tscx        ; $3B  TSC
4479
         .byte mne_bitx        ; $3C  BIT abs,X
4480
         .byte mne_andx        ; $3D  AND abs,X
4481
         .byte mne_rolx        ; $3E  ROL abs,X
4482
         .byte mne_andx        ; $3F  AND absl,X
4483
;
4484
         .byte mne_rtix        ; $40  RTI
4485
         .byte mne_eorx        ; $41  EOR (dp,X)
4486
         .byte mne_wdmx        ; $42  WDM
4487
         .byte mne_eorx        ; $43  EOR offset,S
4488
         .byte mne_mvpx        ; $44  MVP sb,db
4489
         .byte mne_eorx        ; $45  EOR dp
4490
         .byte mne_lsrx        ; $46  LSR dp
4491
         .byte mne_eorx        ; $47  EOR [dp]
4492
         .byte mne_phax        ; $48  PHA
4493
         .byte mne_eorx        ; $49  EOR #
4494
         .byte mne_lsrx        ; $4A  LSR A
4495
         .byte mne_phkx        ; $4B  PHK
4496
         .byte mne_jmpx        ; $4C  JMP abs
4497
         .byte mne_eorx        ; $4D  EOR abs
4498
         .byte mne_lsrx        ; $4E  LSR abs
4499
         .byte mne_eorx        ; $4F  EOR absl
4500
;
4501
         .byte mne_bvcx        ; $50  BVC abs
4502
         .byte mne_eorx        ; $51  EOR (dp),Y
4503
         .byte mne_eorx        ; $52  EOR (dp)
4504
         .byte mne_eorx        ; $53  EOR (offset,S),Y
4505
         .byte mne_mvnx        ; $54  MVN sb,db
4506
         .byte mne_eorx        ; $55  EOR dp,X
4507
         .byte mne_lsrx        ; $56  LSR dp,X
4508
         .byte mne_eorx        ; $57  EOR [dp],Y
4509
         .byte mne_clix        ; $58  CLI
4510
         .byte mne_eorx        ; $59  EOR abs,Y
4511
         .byte mne_phyx        ; $5A  PHY
4512
         .byte mne_tcdx        ; $5B  TCD
4513
         .byte mne_jmlx        ; $5C  JML absl
4514
         .byte mne_eorx        ; $5D  EOR abs,X
4515
         .byte mne_lsrx        ; $5E  LSR abs,X
4516
         .byte mne_eorx        ; $5F  EOR absl,X
4517
;
4518
         .byte mne_rtsx        ; $60  RTS
4519
         .byte mne_adcx        ; $61  ADC (dp,X)
4520
         .byte mne_perx        ; $62  PER
4521
         .byte mne_adcx        ; $63  ADC offset,S
4522
         .byte mne_stzx        ; $64  STZ dp
4523
         .byte mne_adcx        ; $65  ADC dp
4524
         .byte mne_rorx        ; $66  ROR dp
4525
         .byte mne_adcx        ; $67  ADC [dp]
4526
         .byte mne_plax        ; $68  PLA
4527
         .byte mne_adcx        ; $69  ADC #
4528
         .byte mne_rorx        ; $6A  ROR A
4529
         .byte mne_rtlx        ; $6B  RTL
4530
         .byte mne_jmpx        ; $6C  JMP (abs)
4531
         .byte mne_adcx        ; $6D  ADC abs
4532
         .byte mne_rorx        ; $6E  ROR abs
4533
         .byte mne_adcx        ; $6F  ADC absl
4534
;
4535
         .byte mne_bvsx        ; $70  BVS abs
4536
         .byte mne_adcx        ; $71  ADC (dp),Y
4537
         .byte mne_adcx        ; $72  ADC (dp)
4538
         .byte mne_adcx        ; $73  ADC (offset,S),Y
4539
         .byte mne_stzx        ; $74  STZ dp,X
4540
         .byte mne_adcx        ; $75  ADC dp,X
4541
         .byte mne_rorx        ; $76  ROR dp,X
4542
         .byte mne_adcx        ; $77  ADC [dp],Y
4543
         .byte mne_seix        ; $78  SEI
4544
         .byte mne_adcx        ; $79  ADC abs,Y
4545
         .byte mne_plyx        ; $7A  PLY
4546
         .byte mne_tdcx        ; $7B  TDC
4547
         .byte mne_jmpx        ; $7C  JMP (abs,X)
4548
         .byte mne_adcx        ; $7D  ADC abs,X
4549
         .byte mne_rorx        ; $7E  ROR abs,X
4550
         .byte mne_adcx        ; $7F  ADC absl,X
4551
;
4552
         .byte mne_brax        ; $80  BRA abs
4553
         .byte mne_stax        ; $81  STA (dp,X)
4554
         .byte mne_brlx        ; $82  BRL abs
4555
         .byte mne_stax        ; $83  STA offset,S
4556
         .byte mne_styx        ; $84  STY dp
4557
         .byte mne_stax        ; $85  STA dp
4558
         .byte mne_stxx        ; $86  STX dp
4559
         .byte mne_stax        ; $87  STA [dp]
4560
         .byte mne_deyx        ; $88  DEY
4561
         .byte mne_bitx        ; $89  BIT #
4562
         .byte mne_txax        ; $8A  TXA
4563
         .byte mne_phbx        ; $8B  PHB
4564
         .byte mne_styx        ; $8C  STY abs
4565
         .byte mne_stax        ; $8D  STA abs
4566
         .byte mne_stxx        ; $8E  STX abs
4567
         .byte mne_stax        ; $8F  STA absl
4568
;
4569
         .byte mne_bccx        ; $90  BCC abs
4570
         .byte mne_stax        ; $91  STA (dp),Y
4571
         .byte mne_stax        ; $92  STA (dp)
4572
         .byte mne_stax        ; $93  STA (offset,S),Y
4573
         .byte mne_styx        ; $94  STY dp,X
4574
         .byte mne_stax        ; $95  STA dp,X
4575
         .byte mne_stxx        ; $96  STX dp,Y
4576
         .byte mne_stax        ; $97  STA [dp],Y
4577
         .byte mne_tyax        ; $98  TYA
4578
         .byte mne_stax        ; $99  STA abs,Y
4579
         .byte mne_txsx        ; $9A  TXS
4580
         .byte mne_txyx        ; $9B  TXY
4581
         .byte mne_stzx        ; $9C  STZ abs
4582
         .byte mne_stax        ; $9D  STA abs,X
4583
         .byte mne_stzx        ; $9E  STZ abs,X
4584
         .byte mne_stax        ; $9F  STA absl,X
4585
;
4586
         .byte mne_ldyx        ; $A0  LDY #
4587
         .byte mne_ldax        ; $A1  LDA (dp,X)
4588
         .byte mne_ldxx        ; $A2  LDX #
4589
         .byte mne_ldax        ; $A3  LDA offset,S
4590
         .byte mne_ldyx        ; $A4  LDY dp
4591
         .byte mne_ldax        ; $A5  LDA dp
4592
         .byte mne_ldxx        ; $A6  LDX dp
4593
         .byte mne_ldax        ; $A7  LDA [dp]
4594
         .byte mne_tayx        ; $A8  TAY
4595
         .byte mne_ldax        ; $A9  LDA #
4596
         .byte mne_taxx        ; $AA  TAX
4597
         .byte mne_plbx        ; $AB  PLB
4598
         .byte mne_ldyx        ; $AC  LDY abs
4599
         .byte mne_ldax        ; $AD  LDA abs
4600
         .byte mne_ldxx        ; $AE  LDX abs
4601
         .byte mne_ldax        ; $AF  LDA absl
4602
;
4603
         .byte mne_bcsx        ; $B0  BCS abs
4604
         .byte mne_ldax        ; $B1  LDA (dp),Y
4605
         .byte mne_ldax        ; $B2  LDA (dp)
4606
         .byte mne_ldax        ; $B3  LDA (offset,S),Y
4607
         .byte mne_ldyx        ; $B4  LDY dp,X
4608
         .byte mne_ldax        ; $B5  LDA dp,X
4609
         .byte mne_ldxx        ; $B6  LDX dp,Y
4610
         .byte mne_ldax        ; $B7  LDA [dp],Y
4611
         .byte mne_clvx        ; $B8  CLV
4612
         .byte mne_ldax        ; $B9  LDA abs,Y
4613
         .byte mne_tsxx        ; $BA  TSX
4614
         .byte mne_tyxx        ; $BB  TYX
4615
         .byte mne_ldyx        ; $BC  LDY abs,X
4616
         .byte mne_ldax        ; $BD  LDA abs,X
4617
         .byte mne_ldxx        ; $BE  LDX abs,Y
4618
         .byte mne_ldax        ; $BF  LDA absl,X
4619
;
4620
         .byte mne_cpyx        ; $C0  CPY #
4621
         .byte mne_cmpx        ; $C1  CMP (dp,X)
4622
         .byte mne_repx        ; $C2  REP #
4623
         .byte mne_cmpx        ; $C3  CMP offset,S
4624
         .byte mne_cpyx        ; $C4  CPY dp
4625
         .byte mne_cmpx        ; $C5  CMP dp
4626
         .byte mne_decx        ; $C6  DEC dp
4627
         .byte mne_cmpx        ; $C7  CMP [dp]
4628
         .byte mne_inyx        ; $C8  INY
4629
         .byte mne_cmpx        ; $C9  CMP #
4630
         .byte mne_dexx        ; $CA  DEX
4631
         .byte mne_waix        ; $CB  WAI
4632
         .byte mne_cpyx        ; $CC  CPY abs
4633
         .byte mne_cmpx        ; $CD  CMP abs
4634
         .byte mne_decx        ; $CE  DEC abs
4635
         .byte mne_cmpx        ; $CF  CMP absl
4636
;
4637
         .byte mne_bnex        ; $D0  BNE abs
4638
         .byte mne_cmpx        ; $D1  CMP (dp),Y
4639
         .byte mne_cmpx        ; $D2  CMP (dp)
4640
         .byte mne_cmpx        ; $D3  CMP (offset,S),Y
4641
         .byte mne_peix        ; $D4  PEI dp
4642
         .byte mne_cmpx        ; $D5  CMP dp,X
4643
         .byte mne_decx        ; $D6  DEC dp,X
4644
         .byte mne_cmpx        ; $D7  CMP [dp],Y
4645
         .byte mne_cldx        ; $D8  CLD
4646
         .byte mne_cmpx        ; $D9  CMP abs,Y
4647
         .byte mne_phxx        ; $DA  PHX
4648
         .byte mne_stpx        ; $DB  STP
4649
         .byte mne_jmpx        ; $DC  JMP [abs]
4650
         .byte mne_cmpx        ; $DD  CMP abs,X
4651
         .byte mne_decx        ; $DE  DEC abs,X
4652
         .byte mne_cmpx        ; $DF  CMP absl,X
4653
;
4654
         .byte mne_cpxx        ; $E0  CPX #
4655
         .byte mne_sbcx        ; $E1  SBC (dp,X)
4656
         .byte mne_sepx        ; $E2  SEP #
4657
         .byte mne_sbcx        ; $E3  SBC offset,S
4658
         .byte mne_cpxx        ; $E4  CPX dp
4659
         .byte mne_sbcx        ; $E5  SBC dp
4660
         .byte mne_incx        ; $E6  INC dp
4661
         .byte mne_sbcx        ; $E7  SBC [dp]
4662
         .byte mne_inxx        ; $E8  INX
4663
         .byte mne_sbcx        ; $E9  SBC #
4664
         .byte mne_nopx        ; $EA  NOP
4665
         .byte mne_xbax        ; $EB  XBA
4666
         .byte mne_cpxx        ; $EC  CPX abs
4667
         .byte mne_sbcx        ; $ED  SBC abs
4668
         .byte mne_incx        ; $EE  INC abs
4669
         .byte mne_sbcx        ; $EF  SBC absl
4670
;
4671
         .byte mne_beqx        ; $F0  BEQ abs
4672
         .byte mne_sbcx        ; $F1  SBC (dp),Y
4673
         .byte mne_sbcx        ; $F2  SBC (dp)
4674
         .byte mne_sbcx        ; $F3  SBC (offset,S),Y
4675
         .byte mne_peax        ; $F4  PEA #
4676
         .byte mne_sbcx        ; $F5  SBC dp,X
4677
         .byte mne_incx        ; $F6  INC dp,X
4678
         .byte mne_sbcx        ; $F7  SBC [dp],Y
4679
         .byte mne_sedx        ; $F8  SED
4680
         .byte mne_sbcx        ; $F9  SBC abs,Y
4681
         .byte mne_plxx        ; $FA  PLX
4682
         .byte mne_xcex        ; $FB  XCE
4683
         .byte mne_jsrx        ; $FC  JSR (abs,X)
4684
         .byte mne_sbcx        ; $FD  SBC abs,X
4685
         .byte mne_incx        ; $FE  INC abs,X
4686
         .byte mne_sbcx        ; $FF  SBC absl,X
4687
;
4688
;
4689
;       instruction addressing modes & sizes in opcode order...
4690
;
4691
;           xxxxxxxx
4692
;           ||||||||
4693
;           ||||++++———> Addressing Mode
4694
;           ||||         ——————————————————————————————————
4695
;           ||||          0000  dp, abs, absl, implied or A
4696
;           ||||          0001  #
4697
;           ||||          0010  dp,X, abs,X or absl,X
4698
;           ||||          0011  dp,Y or abs,Y
4699
;           ||||          0100  (dp) or (abs)
4700
;           ||||          0101  [dp] or [abs]
4701
;           ||||          0110  [dp],Y
4702
;           ||||          0111  (dp,X) or (abs,X)
4703
;           ||||          1000  (dp),Y
4704
;           ||||          1001  offset,S
4705
;           ||||          1010  (offset,S),Y
4706
;           ||||          1011  sbnk,dbnk (MVN or MVP)
4707
;           ||||          —-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—-—
4708
;           ||||           #    = immediate
4709
;           ||||           A    = accumulator
4710
;           ||||           abs  = absolute
4711
;           ||||           absl = absolute long
4712
;           ||||           dbnk = destination bank
4713
;           ||||           dp   = direct (zero) page
4714
;           ||||           S    = stack relative
4715
;           ||||           sbnk = source bank
4716
;           ||||         ——————————————————————————————————
4717
;           ||||
4718
;           ||++———————> binary-encoded operand size
4719
;           |+—————————> 1: relative branch instruction
4720
;           +——————————> 1: variable operand size...
4721
;
4722
;           —————————————————————————————————————————————————————————————
4723
;           Variable operand size refers to an immediate mode instruction
4724
;           that can accept either an 8 or 16 bit operand.  During instr-
4725
;           uction assembly, an 8 bit operand can be forced to 16 bits by
4726
;           preceding the operand field with !,  e.g.,  LDA !#$01,  which
4727
;           will assemble as $A9 $01 $00.
4728
;           —————————————————————————————————————————————————————————————
4729
;
4730
mnetabam .byte ops0 | am_nam   ; $00  BRK
4731
         .byte ops1 | am_indx  ; $01  ORA (dp,X)
4732
         .byte ops1 | am_nam   ; $02  COP
4733
         .byte ops1 | am_stk   ; $03  ORA offset,S
4734
         .byte ops1 | am_nam   ; $04  TSB dp
4735
         .byte ops1 | am_nam   ; $05  ORA dp
4736
         .byte ops1 | am_nam   ; $06  ASL dp
4737
         .byte ops1 | am_indl  ; $07  ORA [dp]
4738
         .byte ops0 | am_nam   ; $08  PHP
4739
         .byte vops | am_imm   ; $09  ORA #
4740
         .byte ops0 | am_nam   ; $0A  ASL A
4741
         .byte ops0 | am_nam   ; $0B  PHD
4742
         .byte ops2 | am_nam   ; $0C  TSB abs
4743
         .byte ops2 | am_nam   ; $0D  ORA abs
4744
         .byte ops2 | am_nam   ; $0E  ASL abs
4745
         .byte ops3 | am_nam   ; $0F  ORA absl
4746
;
4747
         .byte bop1 | am_nam   ; $10  BPL abs
4748
         .byte ops1 | am_indy  ; $11  ORA (dp),Y
4749
         .byte ops1 | am_ind   ; $12  ORA (dp)
4750
         .byte ops1 | am_stky  ; $13  ORA (offset,S),Y
4751
         .byte ops1 | am_nam   ; $14  TRB dp
4752
         .byte ops1 | am_adrx  ; $15  ORA dp,X
4753
         .byte ops1 | am_adrx  ; $16  ASL dp,X
4754
         .byte ops1 | am_indly ; $17  ORA [dp],Y
4755
         .byte ops0 | am_nam   ; $18  CLC
4756
         .byte ops2 | am_nam   ; $19  ORA abs
4757
         .byte ops0 | am_nam   ; $1A  INC A
4758
         .byte ops0 | am_nam   ; $1B  TCS
4759
         .byte ops2 | am_nam   ; $1C  TRB abs
4760
         .byte ops2 | am_adrx  ; $1D  ORA abs,X
4761
         .byte ops2 | am_adrx  ; $1E  ASL abs,X
4762
         .byte ops3 | am_adrx  ; $1F  ORA absl,X
4763
;
4764
         .byte ops2 | am_nam   ; $20  JSR abs
4765
         .byte ops1 | am_indx  ; $21  AND (dp,X)
4766
         .byte ops3 | am_nam   ; $22  JSL absl
4767
         .byte ops1 | am_stk   ; $23  AND offset,S
4768
         .byte ops1 | am_nam   ; $24  BIT dp
4769
         .byte ops1 | am_nam   ; $25  AND dp
4770
         .byte ops1 | am_nam   ; $26  ROL dp
4771
         .byte ops1 | am_indl  ; $27  AND [dp]
4772
         .byte ops0 | am_nam   ; $28  PLP
4773
         .byte vops | am_imm   ; $29  AND #
4774
         .byte ops0 | am_nam   ; $2A  ROL A
4775
         .byte ops0 | am_nam   ; $2B  PLD
4776
         .byte ops2 | am_nam   ; $2C  BIT abs
4777
         .byte ops2 | am_nam   ; $2D  AND abs
4778
         .byte ops2 | am_nam   ; $2E  ROL abs
4779
         .byte ops3 | am_nam   ; $2F  AND absl
4780
;
4781
         .byte bop1 | am_nam   ; $30  BMI abs
4782
         .byte ops1 | am_indy  ; $31  AND (dp),Y
4783
         .byte ops1 | am_ind   ; $32  AND (dp)
4784
         .byte ops1 | am_stky  ; $33  AND (offset,S),Y
4785
         .byte ops1 | am_adrx  ; $34  BIT dp,X
4786
         .byte ops1 | am_adrx  ; $35  AND dp,X
4787
         .byte ops1 | am_adrx  ; $36  ROL dp,X
4788
         .byte ops1 | am_indly ; $37  AND [dp],Y
4789
         .byte ops0 | am_nam   ; $38  SEC
4790
         .byte ops2 | am_adry  ; $39  AND abs,Y
4791
         .byte ops0 | am_nam   ; $3A  DEC A
4792
         .byte ops0 | am_nam   ; $3B  TSC
4793
         .byte ops2 | am_adrx  ; $3C  BIT abs,X
4794
         .byte ops2 | am_adrx  ; $3D  AND abs,X
4795
         .byte ops2 | am_adrx  ; $3E  ROL abs,X
4796
         .byte ops3 | am_adrx  ; $3F  AND absl,X
4797
;
4798
         .byte ops0 | am_nam   ; $40  RTI
4799
         .byte ops1 | am_indx  ; $41  EOR (dp,X)
4800
         .byte ops0 | am_nam   ; $42  WDM
4801
         .byte ops1 | am_stk   ; $43  EOR offset,S
4802
         .byte ops2 | am_move  ; $44  MVP sb,db
4803
         .byte ops1 | am_nam   ; $45  EOR dp
4804
         .byte ops1 | am_nam   ; $46  LSR dp
4805
         .byte ops1 | am_indl  ; $47  EOR [dp]
4806
         .byte ops0 | am_nam   ; $48  PHA
4807
         .byte vops | am_imm   ; $49  EOR #
4808
         .byte ops0 | am_nam   ; $4A  LSR A
4809
         .byte ops0 | am_nam   ; $4B  PHK
4810
         .byte ops2 | am_nam   ; $4C  JMP abs
4811
         .byte ops2 | am_nam   ; $4D  EOR abs
4812
         .byte ops2 | am_nam   ; $4E  LSR abs
4813
         .byte ops3 | am_nam   ; $4F  EOR absl
4814
;
4815
         .byte bop1 | am_nam   ; $50  BVC abs
4816
         .byte ops1 | am_indy  ; $51  EOR (dp),Y
4817
         .byte ops1 | am_ind   ; $52  EOR (dp)
4818
         .byte ops1 | am_stky  ; $53  EOR (offset,S),Y
4819
         .byte ops2 | am_move  ; $54  MVN sb,db
4820
         .byte ops1 | am_adrx  ; $55  EOR dp,X
4821
         .byte ops1 | am_adrx  ; $56  LSR dp,X
4822
         .byte ops1 | am_indly ; $57  EOR [dp],Y
4823
         .byte ops0 | am_nam   ; $58  CLI
4824
         .byte ops2 | am_adry  ; $59  EOR abs,Y
4825
         .byte ops0 | am_nam   ; $5A  PHY
4826
         .byte ops0 | am_nam   ; $5B  TCD
4827
         .byte ops3 | am_nam   ; $5C  JML absl
4828
         .byte ops2 | am_adrx  ; $5D  EOR abs,X
4829
         .byte ops2 | am_adrx  ; $5E  LSR abs,X
4830
         .byte ops3 | am_adrx  ; $5F  EOR absl,X
4831
;
4832
         .byte ops0 | am_nam   ; $60  RTS
4833
         .byte ops1 | am_indx  ; $61  ADC (dp,X)
4834
         .byte bop2 | am_nam   ; $62  PER
4835
         .byte ops1 | am_stk   ; $63  ADC offset,S
4836
         .byte ops1 | am_nam   ; $64  STZ dp
4837
         .byte ops1 | am_nam   ; $65  ADC dp
4838
         .byte ops1 | am_nam   ; $66  ROR dp
4839
         .byte ops1 | am_indl  ; $67  ADC [dp]
4840
         .byte ops0 | am_nam   ; $68  PLA
4841
         .byte vops | am_imm   ; $69  ADC #
4842
         .byte ops0 | am_nam   ; $6A  ROR A
4843
         .byte ops0 | am_nam   ; $6B  RTL
4844
         .byte ops2 | am_ind   ; $6C  JMP (abs)
4845
         .byte ops2 | am_nam   ; $6D  ADC abs
4846
         .byte ops2 | am_nam   ; $6E  ROR abs
4847
         .byte ops3 | am_nam   ; $6F  ADC absl
4848
;
4849
         .byte bop1 | am_nam   ; $70  BVS abs
4850
         .byte ops1 | am_indy  ; $71  ADC (dp),Y
4851
         .byte ops1 | am_ind   ; $72  ADC (dp)
4852
         .byte ops1 | am_stky  ; $73  ADC (offset,S),Y
4853
         .byte ops1 | am_adrx  ; $74  STZ dp,X
4854
         .byte ops1 | am_adrx  ; $75  ADC dp,X
4855
         .byte ops1 | am_adrx  ; $76  ROR dp,X
4856
         .byte ops1 | am_indly ; $77  ADC [dp],Y
4857
         .byte ops0 | am_nam   ; $78  SEI
4858
         .byte ops2 | am_adry  ; $79  ADC abs,Y
4859
         .byte ops0 | am_nam   ; $7A  PLY
4860
         .byte ops0 | am_nam   ; $7B  TDC
4861
         .byte ops2 | am_indx  ; $7C  JMP (abs,X)
4862
         .byte ops2 | am_adrx  ; $7D  ADC abs,X
4863
         .byte ops2 | am_adrx  ; $7E  ROR abs,X
4864
         .byte ops3 | am_adrx  ; $7F  ADC absl,X
4865
;
4866
         .byte bop1 | am_nam   ; $80  BRA abs
4867
         .byte ops1 | am_indx  ; $81  STA (dp,X)
4868
         .byte bop2 | am_nam   ; $82  BRL abs
4869
         .byte ops1 | am_stk   ; $83  STA offset,S
4870
         .byte ops1 | am_nam   ; $84  STY dp
4871
         .byte ops1 | am_nam   ; $85  STA dp
4872
         .byte ops1 | am_nam   ; $86  STX dp
4873
         .byte ops1 | am_indl  ; $87  STA [dp]
4874
         .byte ops0 | am_nam   ; $88  DEY
4875
         .byte vops | am_imm   ; $89  BIT #
4876
         .byte ops0 | am_nam   ; $8A  TXA
4877
         .byte ops0 | am_nam   ; $8B  PHB
4878
         .byte ops2 | am_nam   ; $8C  STY abs
4879
         .byte ops2 | am_nam   ; $8D  STA abs
4880
         .byte ops2 | am_nam   ; $8E  STX abs
4881
         .byte ops3 | am_nam   ; $8F  STA absl
4882
;
4883
         .byte bop1 | am_nam   ; $90  BCC abs
4884
         .byte ops1 | am_indy  ; $91  STA (dp),Y
4885
         .byte ops1 | am_ind   ; $92  STA (dp)
4886
         .byte ops1 | am_stky  ; $93  STA (offset,S),Y
4887
         .byte ops1 | am_adrx  ; $94  STY dp,X
4888
         .byte ops1 | am_adrx  ; $95  STA dp,X
4889
         .byte ops1 | am_adry  ; $96  STX dp,Y
4890
         .byte ops1 | am_indly ; $97  STA [dp],Y
4891
         .byte ops0 | am_nam   ; $98  TYA
4892
         .byte ops2 | am_adry  ; $99  STA abs,Y
4893
         .byte ops0 | am_nam   ; $9A  TXS
4894
         .byte ops0 | am_nam   ; $9B  TXY
4895
         .byte ops2 | am_nam   ; $9C  STZ abs
4896
         .byte ops2 | am_adrx  ; $9D  STA abs,X
4897
         .byte ops2 | am_adrx  ; $9E  STZ abs,X
4898
         .byte ops3 | am_adrx  ; $9F  STA absl,X
4899
;
4900
         .byte vops | am_imm   ; $A0  LDY #
4901
         .byte ops1 | am_indx  ; $A1  LDA (dp,X)
4902
         .byte vops | am_imm   ; $A2  LDX #
4903
         .byte ops1 | am_stk   ; $A3  LDA offset,S
4904
         .byte ops1 | am_nam   ; $A4  LDY dp
4905
         .byte ops1 | am_nam   ; $A5  LDA dp
4906
         .byte ops1 | am_nam   ; $A6  LDX dp
4907
         .byte ops1 | am_indl  ; $A7  LDA [dp]
4908
         .byte ops0 | am_nam   ; $A8  TAY
4909
         .byte vops | am_imm   ; $A9  LDA #
4910
         .byte ops0 | am_nam   ; $AA  TAX
4911
         .byte ops0 | am_nam   ; $AB  PLB
4912
         .byte ops2 | am_nam   ; $AC  LDY abs
4913
         .byte ops2 | am_nam   ; $AD  LDA abs
4914
         .byte ops2 | am_nam   ; $AE  LDX abs
4915
         .byte ops3 | am_nam   ; $AF  LDA absl
4916
;
4917
         .byte bop1 | am_nam   ; $B0  BCS abs
4918
         .byte ops1 | am_indy  ; $B1  LDA (dp),Y
4919
         .byte ops1 | am_ind   ; $B2  LDA (dp)
4920
         .byte ops1 | am_stky  ; $B3  LDA (offset,S),Y
4921
         .byte ops1 | am_adrx  ; $B4  LDY dp,X
4922
         .byte ops1 | am_adrx  ; $B5  LDA dp,X
4923
         .byte ops1 | am_adry  ; $B6  LDX dp,Y
4924
         .byte ops1 | am_indly ; $B7  LDA [dp],Y
4925
         .byte ops0 | am_nam   ; $B8  CLV
4926
         .byte ops2 | am_adry  ; $B9  LDA abs,Y
4927
         .byte ops0 | am_nam   ; $BA  TSX
4928
         .byte ops0 | am_nam   ; $BB  TYX
4929
         .byte ops2 | am_adrx  ; $BC  LDY abs,X
4930
         .byte ops2 | am_adrx  ; $BD  LDA abs,X
4931
         .byte ops2 | am_adry  ; $BE  LDX abs,Y
4932
         .byte ops3 | am_adrx  ; $BF  LDA absl,X
4933
;
4934
         .byte vops | am_imm   ; $C0  CPY #
4935
         .byte ops1 | am_indx  ; $C1  CMP (dp,X)
4936
         .byte ops1 | am_imm   ; $C2  REP #
4937
         .byte ops1 | am_stk   ; $C3  CMP offset,S
4938
         .byte ops1 | am_nam   ; $C4  CPY dp
4939
         .byte ops1 | am_nam   ; $C5  CMP dp
4940
         .byte ops1 | am_nam   ; $C6  DEC dp
4941
         .byte ops1 | am_indl  ; $C7  CMP [dp]
4942
         .byte ops0 | am_nam   ; $C8  INY
4943
         .byte vops | am_imm   ; $C9  CMP #
4944
         .byte ops0 | am_nam   ; $CA  DEX
4945
         .byte ops0 | am_nam   ; $CB  WAI
4946
         .byte ops2 | am_nam   ; $CC  CPY abs
4947
         .byte ops2 | am_nam   ; $CD  CMP abs
4948
         .byte ops2 | am_nam   ; $CE  DEC abs
4949
         .byte ops3 | am_nam   ; $CF  CMP absl
4950
;
4951
         .byte bop1 | am_nam   ; $D0  BNE abs
4952
         .byte ops1 | am_indy  ; $D1  CMP (dp),Y
4953
         .byte ops1 | am_ind   ; $D2  CMP (dp)
4954
         .byte ops1 | am_stky  ; $D3  CMP (offset,S),Y
4955
         .byte ops1 | am_nam   ; $D4  PEI dp
4956
         .byte ops1 | am_adrx  ; $D5  CMP dp,X
4957
         .byte ops1 | am_adrx  ; $D6  DEC dp,X
4958
         .byte ops1 | am_indly ; $D7  CMP [dp],Y
4959
         .byte ops0 | am_nam   ; $D8  CLD
4960
         .byte ops2 | am_adry  ; $D9  CMP abs,Y
4961
         .byte ops0 | am_nam   ; $DA  PHX
4962
         .byte ops0 | am_nam   ; $DB  STP
4963
         .byte ops2 | am_indl  ; $DC  JMP [abs]
4964
         .byte ops2 | am_adrx  ; $DD  CMP abs,X
4965
         .byte ops2 | am_adrx  ; $DE  DEC abs,X
4966
         .byte ops3 | am_adrx  ; $DF  CMP absl,X
4967
;
4968
         .byte vops | am_imm   ; $E0  CPX #
4969
         .byte ops1 | am_indx  ; $E1  SBC (dp,X)
4970
         .byte ops1 | am_imm   ; $E2  SEP #
4971
         .byte ops1 | am_stk   ; $E3  SBC offset,S
4972
         .byte ops1 | am_nam   ; $E4  CPX dp
4973
         .byte ops1 | am_nam   ; $E5  SBC dp
4974
         .byte ops1 | am_nam   ; $E6  INC dp
4975
         .byte ops1 | am_indl  ; $E7  SBC [dp]
4976
         .byte ops0 | am_nam   ; $E8  INX
4977
         .byte vops | am_imm   ; $E9  SBC #
4978
         .byte ops0 | am_nam   ; $EA  NOP
4979
         .byte ops0 | am_nam   ; $EB  XBA
4980
         .byte ops2 | am_nam   ; $EC  CPX abs
4981
         .byte ops2 | am_nam   ; $ED  SBC abs
4982
         .byte ops2 | am_nam   ; $EE  INC abs
4983
         .byte ops3 | am_nam   ; $EF  SBC absl
4984
;
4985
         .byte bop1 | am_nam   ; $F0  BEQ abs
4986
         .byte ops1 | am_indy  ; $F1  SBC (dp),Y
4987
         .byte ops1 | am_ind   ; $F2  SBC (dp)
4988
         .byte ops1 | am_stky  ; $F3  SBC (offset,S),Y
4989
         .byte ops2 | am_imm   ; $F4  PEA #
4990
         .byte ops1 | am_adrx  ; $F5  SBC dp,X
4991
         .byte ops1 | am_adrx  ; $F6  INC dp,X
4992
         .byte ops1 | am_indly ; $F7  SBC [dp],Y
4993
         .byte ops0 | am_nam   ; $F8  SED
4994
         .byte ops2 | am_adry  ; $F9  SBC abs,Y
4995
         .byte ops0 | am_nam   ; $FA  PLX
4996
         .byte ops0 | am_nam   ; $FB  XCE
4997
         .byte ops2 | am_indx  ; $FC  JSR (abs,X)
4998
         .byte ops2 | am_adrx  ; $FD  SBC abs,X
4999
         .byte ops2 | am_adrx  ; $FE  INC abs,X
5000
         .byte ops3 | am_adrx  ; $FF  SBC absl,X
5001
;
5002
;
5003
;       .X & .Y immediate mode opcodes...
5004
;
5005
vopidx   .byte $a0             ;LDY #
5006
         .byte $a2             ;LDX #
5007
         .byte $c0             ;CPY #
5008
         .byte $e0             ;CPX #
5009
n_vopidx =*-vopidx             ;number of opcodes
5010
;
5011
;
5012
;       addressing mode symbology lookup...
5013
;
5014
ms_lutab .word ms_nam          ;(0000)  no symbol
5015
         .word ms_imm          ;(0001)  #
5016
         .word ms_addrx        ;(0010)  dp,X or abs,X
5017
         .word ms_addry        ;(0011)  dp,Y or abs,Y
5018
         .word ms_ind          ;(0100)  (dp) or (abs)
5019
         .word ms_indl         ;(0101)  [dp] or [abs]
5020
         .word ms_indly        ;(0110)  [dp],Y
5021
         .word ms_indx         ;(0111)  (dp,X) or (abs,X)
5022
         .word ms_indy         ;(1000)  (dp),Y
5023
         .word ms_stk          ;(1001)  offset,S
5024
         .word ms_stky         ;(1010) (offset,S),Y
5025
         .word ms_nam          ;(1011) sbnk,dbnk
5026
;
5027
;
5028
;       addressing mode symbology strings...
5029
;
5030
ms_nam   .byte " ",0           ;no symbol
5031
ms_addrx .byte " ,X",0         ;dp,X or addr,X
5032
ms_addry .byte " ,Y",0         ;dp,Y or addr,Y
5033
ms_imm   .byte "#",0           ;immediate
5034
ms_ind   .byte "()",0          ;(dp) or (abs)
5035
ms_indl  .byte "[]",0          ;[dp] or [abs]
5036
ms_indly .byte "[],Y",0        ;[dp],Y
5037
ms_indx  .byte "(,X)",0        ;(dp,X) or (abs,X)
5038
ms_indy  .byte "(),Y",0        ;(dp),Y
5039
ms_move  .byte ",$",0          ;MVN/MVP sbnk,dbnk
5040
ms_stk   .byte " ,S",0         ;offset,S
5041
ms_stky  .byte "(,S),Y",0      ;(offset,S),Y
5042
;
5043
;================================================================================
5044
;
5045
;CONSOLE DISPLAY CONTROL STRINGS
5046
;
5047
dc_bf    bf                    ;enable reverse foreground
5048
         .byte 0
5049
;
5050
dc_bs    bs                    ;destructive backspace
5051
         .byte 0
5052
;
5053
dc_cl    cl                    ;clear to end of line
5054
         .byte 0
5055
;
5056
dc_cn    cn                    ;cursor on
5057
         .byte 0
5058
;
5059
dc_co    co                    ;cursor off
5060
         .byte 0
5061
;
5062
dc_er    er                    ;enable normal foreground
5063
         .byte 0
5064
;
5065
dc_lf    lf                    ;newline
5066
         .byte 0
5067
;
5068
;================================================================================
5069
;
5070
;TEXT STRINGS
5071
;
5072
mm_brk   rb
5073
         lf
5074
         .byte "**BRK"
5075
         lf
5076
         .byte 0
5077
;
5078
mm_entry lf
5079
         .byte a_lf,"Supermon 816 "
5080
         softvers
5081
         .byte " "
5082
         lf
5083
         .byte 0
5084
;
5085
mm_err   .byte " **ERR  ",0
5086
;
5087
mm_prmpt lf
5088
         sf
5089
         .byte ".",0
5090
;
5091
mm_regs  lf
5092
         .byte "  PB  PC   NVmxDIZC  .C   .X   .Y   SP   DP  DB"
5093
         lf
5094
         .byte "; ",0
5095
;
5096
mm_rts   rb
5097
         lf
5098
         .byte "**RTS"
5099
         lf
5100
         .byte 0
5101
;
5102
;================================================================================
5103
;
5104
;VECTOR STORAGE
5105
;
5106
vecbrkia .word 0                ;system indirect BRK vector
5107
;
5108
_txtend_ =*                     ;end of program text
5109
;
5110
;================================================================================
5111
        .end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.