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

Subversion Repositories System09

[/] [System09/] [trunk/] [src/] [sys09bug/] [sys09bug.asm] - Blame information for rev 114

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 99 davidgb
* NAM SYS09BUG12 SYSTEM09 MONITOR
2
 OPT l
3
 PAGE
4
*
5
* MONITOR PROGRAM FOR THE SOUTHWEST TECHNICAL
6
* PRODUCTS MP-09 CPU BOARD AS COMMENTED BY....
7
*
8
* ALLEN CLARK            WALLACE WATSON
9
* 2502 REGAL OAKS LANE   4815 EAST 97th AVE.
10
* LUTZ, FLA. 33549       TEMPLE TERRACE, FLA. 33617
11
* PH. 813-977-0347       PH. 813-985-1359
12
*
13
* MODIFIED TO SBUG09 VER 1.8 BY:  RANDY JARRETT
14
*                                 2561 NANTUCKET DR APT. E
15
*                                 ATLANTA, GA  30345
16
*                                 PH. 404-320-1043
17
*
18
* MODIFIED TO SYS09BUG VER 1.0
19 59 davidgb
* FOR:     SYSTEM09 FPGA SYSTEM
20
* BY:      JOHN KENT
21
* DATE:    21ST NOVEMBER 2006
22
* REMOVED: DISK BOOTS
23
*          MEMORY TEST
24
* ADDED:   ADM3A VDU DRIVER
25 99 davidgb
*
26
* MODIFIED TO SYS09BUG VER 1.1
27 59 davidgb
* FOR:     SYSTEM09 FPGA SYSTEM
28
* BY:      JOHN KENT
29
* DATE:    7TH JANUARY 2007
30
* ADDED:   'U' USER EXTENTION COMMANDS AT $F000
31
*          CONDITIONAL ASSEMBLY OF FLOPPY BOOTS
32
*          AND REALTIME CLOCK
33
*
34 99 davidgb
* MODIFIED TO SYS09BUG VER 1.2
35 59 davidgb
* FOR:     SYSTEM09 FPGA SYSTEM
36
* BY:      JOHN KENT
37
* DATE:    21ST MAY 2007
38
* ADDED:   COMPACT FLASH BOOT TO FPGA VERSION
39
*          REMOVED PORT REDIRECTION ON PUNCH & LOAD
40 99 davidgb
*
41 59 davidgb
* Modified to SYS09BUG VER 1.3
42
* FOR:     SYSTEM09 FPGA SYSTEM
43
* BY:      JOHN KENT
44
* DATE:    8TH JAN 2008
45
* ADDED:   CONDITIONALS FOR SPARTAN3E STARTER BOARD
46
*          WITH ONLY 32K OF RAM
47
*
48
* Modified to SYS09BUG VER 1.4
49
* FOR:     SYSTEM09 FPGA SYSTEM
50
* BY:      JOHN KENT
51
* DATE:    3RD FEB 2008
52
* ADDED:   CONDITIONALS FOR XESS BOARD WITH IDE
53
*          SEPERATE CONDITIONAL FOR S3 STARTER AND B5-X300
54
*          16 BIT IDE DISK BOOT STRAP ROUTINE
55 99 davidgb
*
56
* Modified to SYS09BUG VER 1.5
57
* FOR:     SYSTEM09 FPGA SYSTEM
58
* BY:      JOHN KENT
59
* DATE:    7TH SEP 2008
60
* ADDED:   ADDED "B3-S2+" STRING
61
*
62
* Modified to SYS09BUG VER 1.6
63
* FOR:     SYSTEM09 FPGA SYSTEM
64
* BY:      JOHN KENT
65
* DATE:    2ND DEC 2008
66
* ADDED:   ADDED HARDWARE FLOW CONTROL
67
*
68 59 davidgb
* CHANGED: SEPARARTED OPTIONS EQUATES AND BODY INTO SEPARATE FILES
69
*
70 99 davidgb
*       *** COMMANDS ***
71
*
72
* CONTROL A   = ALTER THE "A" ACCUMULATOR
73
* CONTROL B   = ALTER THE "B" ACCUMULATOR
74
* CONTROL C   = ALTER THE CONDITION CODE REGISTER
75
* CONTROL D   = ALTER THE DIRECT PAGE REGISTER
76
* CONTROL P   = ALTER THE PROGRAM COUNTER
77
* CONTROL U   = ALTER USER STACK POINTER
78
* CONTROL X   = ALTER "X" INDEX REGISTER
79
* CONTROL Y   = ALTER "Y" INDEX REGISTER
80
* B hhhh      = SET BREAKPOINT AT LOCATION $hhhh
81 59 davidgb
* D           = 5.25" MINIFLOPPY BOOT
82
* E ssss-eeee = EXAMINE MEMORY
83 99 davidgb
*               FROM STARTING ADDRESS ssss
84
*               TO ENDING ADDRESS eeee.
85
* G           = CONTINUE EXECUTION FROM BREAKPOINT OR SWI
86
* L           = LOAD TAPE
87
* M hhhh      = EXAMINE AND CHANGE MEMORY LOCATION hhhh
88
* P ssss-eeee = PUNCH TAPE, START ssss TO END eeee ADDR.
89
* R           = DISPLAY REGISTER CONTENTS
90
* S           = DISPLAY STACK FROM ssss TO $DFC0
91 59 davidgb
* U           = 8" DMAF2 FLOPPY BOOT
92
* U           = USER EXTENSION COMMANDS AT $F000
93 99 davidgb
* X           = REMOVE ALL BREAKPOINTS
94 59 davidgb
*
95 99 davidgb
*
96 59 davidgb
***************************************************
97
*   SYS09BUG VARIABLE SPACE
98
***************************************************
99 99 davidgb
*
100 59 davidgb
        ORG   MONRAM
101 99 davidgb
STACK   EQU   *         ; TOP OF INTERNAL STACK
102
NMI     RMB   2         ; USER NMI VECTOR
103
SWI3    RMB   2         ; SOFTWARE INTERRUPT VECTOR #3
104
SWI2    RMB   2         ; SOFTWARE INTERRUPT VECTOR #2
105
FIRQ    RMB   2         ; FAST INTERRUPT VECTOR
106
IRQ     RMB   2         ; INTERRUPT VECTOR
107
SWI     RMB   2         ; SOFTWARE INTERRUPT VECTOR
108
SVCVO   RMB   2         ; SUPERVISOR CALL VECTOR ORGIN
109
SVCVL   RMB   2         ; SUPERVISOR CALL VECTOR LIMIT
110 59 davidgb
        IFD DATOPT
111 99 davidgb
LRARAM  RMB  16         ; LRA ADDRESSES
112 59 davidgb
        ENDIF DATOPT
113 99 davidgb
CPORT   RMB   2         ; RE-VECTORABLE CONTROL PORT
114
ECHO    RMB   1         ; ECHO FLAG
115
BPTBL   RMB  24         ; BREAKPOINT TABLE BASE ADDR
116 59 davidgb
        IFD  TRAOPT
117 99 davidgb
NMISAV  RMB   2         ; NMI Jump Vector Backup
118
TRACNT  RMB   2         ; Trace Count
119 59 davidgb
        ENDIF TRAOPT
120
        IFD VDUOPT
121
*
122
**************************************************
123
*   VDU8 DISPLAY DRIVER VARIABLES                                    *
124
**************************************************
125
*
126
**** ALWAYS KEEP COLADX AND ROWADX TOGETHER ******
127 99 davidgb
COLADX  RMB   1         ; CURSOR COLUMN
128
ROWADX  RMB   1         ; CURSOR ROW
129 59 davidgb
**************************************************
130
*
131 99 davidgb
NEWROW  RMB   1         ; NEW ROW TEMP FOR ESCAPE
132
ESCFLG  RMB   1         ; ESCAPE SEQUENCE ACTIVE
133 59 davidgb
        ENDIF VDUOPT
134 99 davidgb
        IFD DG640OPT
135 59 davidgb
*
136
***************************************************
137
*   DG640 MEMORY MAPPED DISPLAY DRIVER VARIABLES  *
138
***************************************************
139
*
140
***** ALWAYS KEEP THESE TWO BYTES TOGETHER *****
141 99 davidgb
COLADX  RMB   1        ; CURSOR COLUMN
142
ROWADX  RMB   1        ; CURSOR ROW
143 59 davidgb
*************************************************
144 99 davidgb
CURSOR  RMB   2        ; ABSOLUTE SCREEN ADDRESS
145
NEWROW  RMB   1        ; NEW ROW TEMP FOR ESCAPE
146
ESCFLG  RMB   1        ; ESCAPE SEQUENCE ACTIVE
147 59 davidgb
        ENDIF DG640OPT
148
*
149
*
150
***************************************************
151
*   START OF ROM                                  *
152
***************************************************
153
*
154
        ORG   MONROM
155 99 davidgb
        FDB   MONITOR
156
        FDB   NEXTCMD
157
        FDB   INCH
158
        FDB   INCHE
159
        FDB   INCHEK
160
        FDB   OUTCH
161
        FDB   PDATA
162
        FDB   PCRLF
163
        FDB   PSTRNG
164
        FDB   LRA
165
*
166
        IFD   ADSOPT
167
        FDB   PCHK     ; CHECK FOR PRINTER INPUT
168
        FDB   PINIZ    ; INITIATE PRINTER
169
        FDB   POUTCH   ; OUTPUT CH. TO PRINTER
170
        FDB   VINIZ
171
        FDB   VOUTCH
172
        FDB   ACINIZ
173
        FDB   AOUTCH
174 59 davidgb
        ENDIF ADSOPT
175
*
176 99 davidgb
* MONITOR
177 59 davidgb
*
178 99 davidgb
* VECTOR ADDRESS STRING IS.....
179
* $F8A1-$F8A1-$F8A1-$F8A1-$F8A1-$FAB0-$FFFF-$FFFF
180
*
181
MONITOR LDX   #RAMVEC  ; POINT TO VECTOR ADDR. STRING
182
        LDY   #STACK   ; POINT TO RAM VECTOR LOCATION
183
        LDB   #$10     ; BYTES TO MOVE = 16
184
LOOPA   LDA   ,X+      ; GET VECTOR BYTE
185
        STA   ,Y+      ; PUT VECTORS IN RAM / $DFC0-$DFCF
186
        DECB           ; SUBTRACT 1 FROM NUMBER OF BYTES TO MOVE
187
        BNE   LOOPA    ; CONTINUE UNTIL ALL VECTORS MOVED
188
*
189
* CONTENTS     FROM         TO      FUNCTION
190
*  $F8A1       $FE40      $DFC0     USER-V
191
*  $F8A1       $FE42      $DFC2     SWI3-V
192
*  $F8A1       $FE44      $DFC4     SWI2-V
193
*  $F8A1       $FE46      $DFC6     FIRQ-V
194
*  $F8A1       $FE48      $DFC8     IRQ-V
195
*  $FAB0       $FE4A      $DFCA     SWI-V
196
*  $FFFF       $FE4C      $DFCC     SVC-VO
197
*  $FFFF       $FE4E      $DFCE     SVC-VL
198
*
199
        LDX   #ACIAS
200
        STX   CPORT    ; STORE ADDR. IN RAM
201
        LBSR  XBKPNT   ; CLEAR OUTSTANDING BREAKPOINTS
202
        LDB   #12      ; CLEAR 12 BYTES ON STACK
203
CLRSTK  CLR   ,-S
204
        DECB
205
        BNE   CLRSTK
206
        LEAX  MONITOR,PCR  ; SET PC TO SBUG-E ENTRY
207
        STX   10,S    ; ON STACK
208
        LDA   #$D0    ; PRESET CONDITION CODES ON STACK
209
        STA   ,S
210
        TFR   S,U
211
        LBSR  IOINIZ  ; INITIALIZE CONTROL PORT
212
        LDX   #MSG1   ; POINT TO MONITOR MESSAGE
213
        LBSR  PDATA   ; PRINT MSG
214
*
215
        IFD   DATOPT
216
        LDX   #LRARAM ; POINT TO LRA RAM STORAGE AREA
217
        CLRA  START   ; TOTAL AT ZERO
218
        LDB   #13     ; TOTAL UP ALL ACTIVE RAM MEMORY
219
FNDREL  TST   B,X     ; TEST FOR RAM AT NEXT LOC.
220
        BEQ   RELPAS  ; IF NO RAM GO TO NEXT LOC.
221
        ADDA  #4      ; ELSE ADD 4K TO TOTAL
222
        DAA           ; ADJ. TOTAL FOR DECIMAL
223
RELPAS  DECB          ; SUB. 1 FROM LOCS. TO TEST
224
        BPL   FNDREL  ; PRINT TOTAL OF RAM
225
        LBSR  OUT2H   ; OUTPUT HEX BYTE AS ASCII
226
        LDX   #MSG2   ; POINT TO MSG 'K' CR/LF + 3 NULS
227
        LBSR  PDATA   ; PRINT MSG
228 59 davidgb
        ENDIF DATOPT
229
*
230 99 davidgb
        IFD   TRAOPT
231
        LBSR  TRAINZ
232 59 davidgb
        ENDIF TRAOPT
233 99 davidgb
*
234
***** NEXTCMD *****
235
*
236
NEXTCMD LDX  #MSG3   ; POINT TO MSG ">"
237
        LBSR PSTRNG  ; PRINT MSG
238
        LBSR INCH    ; GET ONE CHAR. FROM TERMINAL
239
        ANDA #$7F    ; STRIP PARITY FROM CHAR.
240
        CMPA #$0D    ; IS IT CARRIAGE RETURN ?
241
        BEQ  NEXTCMD ; IF CR THEN GET ANOTHER CHAR.
242
        TFR  A,B     ; PUT CHAR. IN "B" ACCUM.
243
        CMPA #$20    ; IS IT CONTROL OR DATA CHAR ?
244
        BGE  PRTCMD  ; IF CMD CHAR IS DATA, PRNT IT
245
        LDA  #'^     ; ELSE CNTRL CHAR CMD SO...
246
        LBSR OUTCH   ; PRINT "^"
247
        TFR  B,A     ; RECALL CNTRL CMD CHAR
248
        ADDA #$40    ; CONVERT IT TO ASCII LETTER
249
PRTCMD  LBSR OUTCH   ; PRNT CMD CHAR
250
        LBSR OUT1S   ; PRNT SPACE
251
        CMPB #$60
252
        BLE  NXTCH0
253
        SUBB #$20
254
*
255
***** DO TABLE LOOKUP *****
256
*   FOR COMMAND FUNCTIONS
257
*
258
NXTCH0  LDX  #JMPTAB ; POINT TO JUMP TABLE
259
NXTCHR  CMPB ,X+     ; DOES COMMAND MATCH TABLE ENTRY ?
260
        BEQ  JMPCMD  ; BRANCH IF MATCH FOUND
261
        LEAX 2,X     ; POINT TO NEXT ENTRY IN TABLE
262
        CMPX #TABEND ; REACHED END OF TABLE YET ?
263
        BNE  NXTCHR  ; IF NOT END, CHECK NEXT ENTRY
264
        LDX  #MSG4   ; POINT TO MSG "WHAT?"
265
        LBSR PDATA   ; PRINT MSG
266
        BRA  NEXTCMD ; IF NO MATCH, PRMPT FOR NEW CMD
267
JMPCMD  JSR  [,X]    ; JUMP TO COMMAND ROUTINE
268
        BRA  NEXTCMD ; PROMPT FOR NEW COMMAND
269
*
270
* "G" GO OR CONTINUE
271
*
272
GO      TFR  U,S
273
RTI     RTI
274
*
275
***** "M" MEMORY EXAMINE AND CHANGE *****
276
*
277
MEMCHG  LBSR IN1ADR  ; INPUT ADDRESS
278
        BVS  CHRTN   ; IF NOT HEX, RETURN
279
        TFR  X,Y     ; SAVE ADDR IN "Y"
280
MEMC2   LDX  #MSG5   ; POINT TO MSG " - "
281
        LBSR PSTRNG  ; PRINT MSG
282
        TFR  Y,X     ; FETCH ADDRESS
283
        LBSR OUT4H   ; PRINT ADDR IN HEX
284
        LBSR OUT1S   ; OUTPUT SPACE
285
        LDA  ,Y      ; GET CONTENTS OF CURRENT ADDR.
286
        LBSR OUT2H   ; OUTPUT CONTENTS IN ASCII
287
        LBSR OUT1S   ; OUTPUT SPACE
288
        LBSR BYTE    ; LOOP WAITING FOR OPERATOR INPUT
289
        BVC  CHANGE  ; IF VALID HEX GO CHANGE MEM. LOC.
290
        CMPA #8      ; IS IT A BACKSPACE (CNTRL H)?
291
        BEQ  MEMC2   ; PROMPT OPERATOR AGAIN
292
        CMPA #$18    ; IS IT A CANCEL (CNTRL X)?
293
        BEQ  MEMC2   ; PROMPT OPERATOR AGAIN
294
        CMPA #'^     ; IS IT AN UP ARROW?
295
        BEQ  BACK    ; DISPLAY PREVIOUS BYTE
296
        CMPA #$D     ; IS IT A CR?
297
        BNE  FORWRD  ; DISPLAY NEXT BYTE
298
CHRTN   RTS          ; EXIT ROUTINE
299
*
300
*
301
CHANGE  STA  ,Y      ; CHANGE BYTE IN MEMORY
302
        CMPA ,Y      ; DID MEMORY BYTE CHANGE?
303
        BEQ  FORWRD  ; $F972
304
        LBSR OUT1S   ; OUTPUT SPACE
305
        LDA  #'?     ; LOAD QUESTION MARK
306
        LBSR OUTCH   ; PRINT IT
307
FORWRD  LEAY 1,Y     ; POINT TO NEXT HIGHER MEM LOCATION
308
        BRA  MEMC2   ; PRINT LOCATION & CONTENTS
309
BACK    LEAY -1,Y    ; POINT TO LAST MEM LOCATION
310
        BRA  MEMC2   ; PRINT LOCATION & CONTENTS
311
*
312
* "S" DISPLAY STACK
313
* HEX-ASCII DISPLAY OF CURRENT STACK CONTENTS FROM
314
** CURRENT STACK POINTER TO INTERNAL STACK LIMIT.
315
*
316
DISSTK  LBSR PRTSP   ; PRINT CURRENT STACK POINTER
317
        TFR  U,Y
318
        LDX  #STACK  ; LOAD INTERNAL STACK AS UPPER LIMIT
319
        LEAX -1,X    ; POINT TO CURRENT STACK
320
        BRA  MDUMP1  ; ENTER MEMORY DUMP OF STACK CONTENTS
321
*
322
* "E" DUMP MEMORY FOR EXAMINE IN HEX AND ASCII
323
* AFTER CALLING 'IN2ADR' LOWER ADDRESS IN Y-REG.
324
*                        UPPER ADDRESS IN X-REG.
325
* IF HEX ADDRESSES ARE INVALID (V)=1.
326
*
327
MEMDUMP LBSR IN2ADR  ; INPUT ADDRESS BOUNDRIES
328
        BVS  EDPRTN  ; NEW COMMAND IF ILLEGAL HEX
329
MDUMP1  PSHS Y       ; COMPARE LOWER TO UPPER BOUNDS
330
        CMPX ,S++    ; LOWER BOUNDS > UPPER BOUNDS?
331
        BCC  AJDUMP  ; IF NOT, DUMP HEX AND ASCII
332
EDPRTN  RTS          ;
333
*
334
* ADJUST LOWER AND UPPER ADDRESS LIMITS
335
* TO EVEN 16 BYTE BOUNDRIES.
336
*
337
* IF LOWER ADDR = $4532
338
* LOWER BOUNDS WILL BE ADJUSTED TO = $4530.
339
*
340
* IF UPPER ADDR = $4567
341
* UPPER BOUNDS WILL BE ADJUSTED TO = $4570.
342
*
343
* ENTER WITH LOWER ADDRESS IN X-REG.
344
*           -UPPER ADDRESS ON TOP OF STACK.
345
*
346
AJDUMP  TFR  X,D     ; GET UPPER ADDR IN D-REG
347
        ADDD #$10    ; ADD 16 TO UPPER ADDRESS
348
        ANDB #$F0    ; MASK TO EVEN 16 BYTE BOUNDRY
349
        PSHS A,B     ; SAVE ON STACK AS UPPER DUMP LIMIT
350
        TFR  Y,D     ; $F9A5 GET LOWER ADDRESS IN D-REG
351
        ANDB #$F0    ; MASK TO EVEN 16 BYTE BOUNDRY
352
        TFR  D,X     ; PUT IN X-REG AS LOWER DUMP LIMIT
353
NXTLIN  CMPX ,S      ; COMPARE LOWER TO UPPER LIMIT
354
        BEQ  SKPDMP  ; IF EQUAL SKIP HEX-ASCII DUMP
355
        LBSR INCHEK  ; CHECK FOR INPUT FROM KEYBOARD
356 59 davidgb
        BEQ  EDUMP
357 99 davidgb
SKPDMP  LEAS 2,S     ; READJUST STACK IF NOT DUMPING
358 59 davidgb
        RTS          ;
359 99 davidgb
*
360
* PRINT 16 HEX BYTES FOLLOWED BY 16 ASCII CHARACTERS
361
* FOR EACH LINE THROUGHOUT ADDRESS LIMITS.
362
*
363
EDUMP   PSHS X       ; PUSH LOWER ADDR LIMIT ON STACK
364
        LDX  #MSG5   ; POINT TO MSG " - "
365
        LBSR PSTRNG  ; PRINT MSG
366
        LDX  ,S      ; LOAD LOWER ADDR FROM TOP OF STACK
367
        LBSR OUT4H   ; PRINT THE ADDRESS
368
        LBSR OUT2S   ; 2 SPACES
369
        LDB  #$10    ; LOAD COUNT OF 16 BYTES TO DUMP
370
ELOOP   LDA  ,X+     ; GET FROM MEMORY HEX BYTE TO PRINT
371
        LBSR OUT2H   ; OUTPUT HEX BYTE AS ASCII
372
        LBSR OUT1S   ; OUTPUT SPACE
373
        DECB         ; $F9D1 DECREMENT BYTE COUNT
374
        BNE  ELOOP   ; CONTINUE TIL 16 HEX BYTES PRINTED
375
*
376
* PRINT 16 ASCII CHARACTERS
377
* IF NOT PRINTABLE OR NOT VALID
378
* ASCII PRINT A PERIOD (.)
379
        LBSR OUT2S   ; 2 SPACES
380
        LDX  ,S++    ; GET LOW LIMIT FRM STACK - ADJ STACK
381
        LDB  #$10    ; SET ASCII CHAR TO PRINT = 16
382
EDPASC  LDA  ,X+     ; GET CHARACTER FROM MEMORY
383
        CMPA #$20    ; IF LESS THAN $20, NON-PRINTABLE?
384
        BCS  PERIOD  ; IF SO, PRINT PERIOD INSTEAD
385
        CMPA #$7E    ; IS IT VALID ASCII?
386
        BLS  PRASC   ; IF SO PRINT IT
387
PERIOD  LDA  #'.     ; LOAD A PERIOD (.)
388
PRASC   LBSR OUTCH   ; PRINT ASCII CHARACTER
389
        DECB         ; DECREMENT COUNT
390
        BNE  EDPASC
391
        BRA  NXTLIN
392
*
393
***** "B" SET BREAKPOINT *****
394
*
395
BRKPNT  LBSR IN1ADR  ; GET BREAKPOINT ADDRESS
396
        BVS  EXITBP  ; EXIT IF INVALID HEX ADDR.
397
        CMPX #STACK  ; ADDRESS ILLEGAL IF >=$DFC0
398
        BCC  BPERR   ; IF ERROR PRINT (?), EXIT
399
        PSHS X       ; $FA82 PUSH BP ADDRESS ON STACK
400
        LDX  #$FFFF  ; LOAD DUMMY ADDR TO TEST BP TABLE
401
        BSR BPTEST   ; TEST BP TABLE FOR FREE SPACE
402
        PULS X       ; POP BP ADDRESS FROM STACK
403
        BEQ  BPERR   ; (Z) SET, OUT OF BP TABLE SPACE
404
        LDA  ,X      ; GET DATA AT BREAKPOINT ADDRESS
405
        CMPA #$3F    ; IS IT A SWI?
406
        BEQ  BPERR   ; IF SWI ALREADY, INDICATE ERROR
407
        STA  ,Y+     ; SAVE DATA BYTE IN BP TABLE
408
        STX  ,Y      ; SAVE BP ADDRESS IN BP TABLE
409
        LDA  #$3F    ; LOAD A SWI ($3F)
410
        STA  ,X      ; SAVE SWI AT BREAKPOINT ADDRESS
411 59 davidgb
EXITBP  RTS ;
412
*
413 99 davidgb
*  INDICATE ERROR SETTING BREAKPOINT
414
*
415
BPERR   LBSR OUT1S   ; OUTPUT SPACE
416
        LDA  #'?     ; LOAD (?), INDICATE BREAKPOINT ERROR
417
        LBRA OUTCH   ; PRINT "?"
418
*
419
*** "X" CLEAR OUTSTANDING BREAKPOINTS ***
420
*
421
XBKPNT  LDY  #BPTBL  ; POINT TO BREAKPOINT TABLE
422
        LDB  #8      ; LOAD BREAKPOINT COUNTER
423
XBPLP   BSR  RPLSWI  ; REMOVE USED ENTRY IN BP TABLE
424
        DECB  $FAAC  ; DECREMENT BP COUNTER
425
        BNE  XBPLP   ; END OF BREAKPOINT TABLE?
426
        RTS
427
*
428
***** SWI ENTRY POINT *****
429
*
430
SWIE    TFR  S,U     ; TRANSFER STACK TO USER POINTER
431
        LDX  10,U    ; LOAD PC FROM STACK INTO X-REG
432
        LEAX -1,X    ; ADJUST ADDR DOWN 1 BYTE.
433
        BSR  BPTEST  ; FIND BREAKPOINT IN BP TABLE
434
        BEQ  REGPR   ; IF FOUND, REPLACE DATA AT BP ADDR
435
        STX  10,U    ; SAVE BREAKPOINT ADDR IN STACK
436
        BSR  RPLSWI  ; GO REPLACE SWI WITH ORIGINAL DATA
437
REGPR   LBSR REGSTR  ; GO PRINT REGISTERS
438
*
439 59 davidgb
        IFD TRAOPT
440
        LDX #0
441
        STX TRACNT
442
        ENDIF TRAOPT
443
*
444 99 davidgb
        LBRA NEXTCMD ; GET NEXT COMMAND
445 59 davidgb
*
446 99 davidgb
RPLSWI  LDX  1,Y     ; LOAD BP ADDRESS FROM BP TABLE
447
        CMPX #STACK  ; COMPARE TO TOP AVAILABLE USER MEMORY
448
        BCC  FFSTBL  ; GO RESET TABLE ENTRY TO $FF'S
449
        LDA  ,X      ; GET DATA FROM BP ADDRESS
450
        CMPA #$3F    ; IS IT SWI?
451
        BNE  FFSTBL  ; IF NOT, RESET TABLE ENTRY TO $FF'S
452
        LDA  ,Y      ; GET ORIGINAL DATA FROM BP TABLE
453
        STA  ,X      ; $FAD3 RESTORE DATA AT BP ADDRESS
454
FFSTBL  LDA  #$FF    ; LOAD $FF IN A-ACC
455
        STA  ,Y+     ; RESET BREAKPOINT TABLE DATA TO $FF'S
456
        STA  ,Y+     ; RESET BREAKPOINT TABLE ADDR TO $FF'S
457
        STA  ,Y+
458
        RTS
459 59 davidgb
*
460 99 davidgb
** SEARCH BREAKPOINT TABLE FOR MATCH **
461
*
462
BPTEST  LDY  #BPTBL  ; POINT TO BREAKPOINT TABLE
463
        LDB  #8      ; LOAD BREAKPOINT COUNTER
464
FNDBP   LDA  ,Y+     ; LOAD DATA BYTE
465
        CMPX ,Y++    ; COMPARE ADDRESS, IS IT SAME?
466
        BEQ  BPADJ   ; IF SO, ADJUST POINTER FOR TABLE ENTRY
467
        DECB         ; IF NOT, DECREMENT BREAKPOINT COUNTER
468
        BNE  FNDBP   ; AND LOOK FOR NEXT POSSIBLE MATCH
469
        RTS          ;
470
*
471
*
472
BPADJ   LEAY -3,Y    ; MOVE POINTER TO BEGIN OF BP ENTRY
473
        RTS
474
*
475 59 davidgb
        IFD TRAOPT
476
*
477
** TRACE from address AAAA BB bytes
478
*
479 99 davidgb
TRACE   LBSR ALTPC1  ; SET UP NEW PC
480
        BVS  TREXIT  ; ADDRESS ERROR, EXIT
481 59 davidgb
        LBSR OUT1S
482 99 davidgb
        LBSR IN1ADR  ; Fetch Byte Count
483
        BVS TREXIT   ; Byte Count error, EXIT
484 59 davidgb
        STX TRACNT
485
*
486 99 davidgb
        LDX NMI      ; Save NMI Vector
487 59 davidgb
        STX NMISAV
488 99 davidgb
        LDX #NMIE    ; Set up NMI for Tracing
489 59 davidgb
        STX NMI
490 99 davidgb
        LBSR TRAINZ  ; Initialise Hardware
491
        BRA TRACEG   ; Start Trace
492 59 davidgb
TREXIT  RTS
493
*
494
* CRA0 = 0 CA1 IRQ DISAB, CRA0 = 1 CA1 IRQ ENAB
495
* CRA1 = 1 CA1 Rising edge IRQ
496
* CRA2 = 0 TADATA = Data Direction, CRA2 = 1 TADATA = I/O Register
497
* CRA3 = 0 CA2 = 0 output, CRA3 = 1 CA2 = 1
498
* CRA4 = 1 ] CA2 = Set/Reset output
499
* CRA5 = 1 ]
500
* CRA6 = X CA2 Input Interrupt Flag
501
* CRA7 = X CA1 Interrupt Flag
502
*
503
* CRB0 = 0 CB1 IRQ DISAB, CRB0 = 1 CA1 IRQ ENAB
504
* CRB1 = 1 CB1 Rising edge IRQ
505
* CRB2 = 0 TBDATA = Data Direction, CRB2 = 1 TBDATA = I/O Register
506
* CRB3 = 0 CB2 = 0 output, CRB3 = 1 CB2 = 1
507
* CRB4 = 1 ] CB2 = Set/Reset output
508
* CRB5 = 1 ]
509
* CRB6 = X CB2 Input Interrupt Flag
510
* CRB7 = X CB1 Interrupt Flag
511
*
512
*
513
** TRACE NMI ENTRY POINT
514
*
515 99 davidgb
NMIE    TFR  S,U
516
        LDA  #$36    ; Disable Interrupt, CA2 Low
517
        STA  TACTRL
518
        LDA  TADATA  ; Clear Interrupt flag by reading data port
519 59 davidgb
*
520 99 davidgb
        LBSR REGSTR  ; DUMP REGISTERS
521 59 davidgb
*
522 99 davidgb
        LDX  10,U    ; TEST IF NEXT INSTRUCTION IS A SWI
523
        LDA  ,X
524 59 davidgb
        CMPA #$3F
525 99 davidgb
        BEQ  TRACEX  ; EXIT ON SWI
526 59 davidgb
*
527 99 davidgb
        LDX  TRACNT  ; CHECK IF TRACE COUNT EXPIRED
528
        BEQ  TRACEX  ; YES, GO BACK TO THE MONITOR
529
        LEAX -1,X    ; ECREMENT TRACE COUNT
530
        STX  TRACNT
531 59 davidgb
*
532
**  TRACE GO (RESUME SINGLE STEP)
533
*
534 99 davidgb
TRACEG  TFR  U,S     ; SET UP PROGRAM STACK POINTER
535
        LDA  #TRADEL ; SET UP TIMER DELAY (NUMB CYCLES FOR RTI+1)
536
        STA  TADATA
537
        LDA  #$36    ; LOAD STROBE LOW
538
        STA  TACTRL
539
        LDA  TADATA  ; CLEAR INTERRUPT
540
        LDA  #$36    ; RELEASE RESET
541
        STA  TBCTRL
542
        LDA  #$3F    ; RELEASE LOAD, ENABLE CA1 NMI, CA1 RISING EDGE
543
        STA  TACTRL
544
        RTI          ; GO EXECUTE INSTRUCTION
545 59 davidgb
*
546 99 davidgb
TRACEX  LDX NMISAV   ; Restore NMI vector
547 59 davidgb
        STX NMI
548 99 davidgb
        LBRA NEXTCMD ; Jump back to the command loop.
549 59 davidgb
*
550
** TRACE HARDWARE INITIALISATION
551
*
552 99 davidgb
TRAINZ  LDA #$32     ; SELECT DDRA, CA2 LOW, NMI DISABLED
553 59 davidgb
        STA TACTRL
554 99 davidgb
        LDA #$3A     ; SELECT DDRB, CB2 HIGH, FIRQ DISABLED
555 59 davidgb
        STA TBCTRL
556 99 davidgb
        LDA #$FF     ; PORTA = OUTPUT
557 59 davidgb
        STA TADATA
558 99 davidgb
        LDA #$00     ; PORTB = INPUT
559 59 davidgb
        STA TBDATA
560 99 davidgb
        LDA #$36     ; SELECT OUTPUT REGISTER A, CA2 LOW
561 59 davidgb
        STA TACTRL
562 99 davidgb
        LDA #$3E     ; SELECT OUTPUT REGISTER B, CB2 HIGH
563 59 davidgb
        STA TBCTRL
564
        RTS
565
*
566
        ENDIF TRAOPT
567
        IFD  MFDCOPT
568
*
569
** "U" MINI DISK BOOT
570
*
571
MINBOOT TST  CMDFDC
572
        CLR  DRVFDC
573
        LDX  #$0000
574
LOOP    LEAX $01,X
575
        CMPX #$0000
576
        BNE  LOOP
577
        LDA  #$0F
578
        STA  CMDFDC
579
        BSR  DELAY
580
LOOP1   LDB  CMDFDC
581
        BITB #$01
582
        BNE  LOOP1
583
        LDA  #$01
584
        STA  SECFDC
585
        BSR  DELAY
586
        LDA  #$8C
587
        STA  CMDFDC
588
        BSR  DELAY
589
        LDX  #$C000
590
        BRA  LOOP3
591
LOOP2   BITB #$02
592
        BEQ  LOOP3
593
        LDA  DATFDC
594
        STA ,X+
595
LOOP3   LDB  CMDFDC
596
        BITB #$01
597
        BNE  LOOP2
598
        BITB #$2C
599
        BEQ  LOOP4
600
        RTS
601
*
602
LOOP4   LDX  #$C000
603
        STX  $0A,U
604
        TFR  U,S
605 99 davidgb
        RTI
606 59 davidgb
*
607
DELAY   LDB  #$04
608
LOOP5   DECB
609
        BNE  LOOP5
610
        RTS
611
        ENDIF MFDCOPT
612 99 davidgb
*
613 59 davidgb
        IFD  DMAFOPT
614 99 davidgb
*
615
*** "D" DISK BOOT FOR DMAF2 ***
616
*
617
DBOOT   LDA  #$DE
618
        STA  DRVREG
619
        LDA  #$FF
620
        STA  PRIREG  ; $FAF8
621
        STA  CCREG
622
        STA  AAAREG
623
        STA  BBBREG
624
        TST  CCREG
625
        LDA  #$D8
626
        STA  COMREG
627
        LBSR DLY
628
DBOOT0  LDA  COMREG
629
        BMI  DBOOT0
630
        LDA  #$09
631
        STA  COMREG
632
        LBSR DLY
633
*
634
DISKWT  LDA  COMREG  ; FETCH DRIVE STATUS
635
        BITA #1      ; TEST BUSY BIT
636
        BNE  DISKWT  ; LOOP UNTIL NOT BUSY
637
*
638
        BITA #$10
639
        BNE  DBOOT
640
*
641
        LDX  #$C000  ; LOGICAL ADDR. = $C000
642
        BSR LRA      ; GET 20 BIT PHYSICAL ADDR. OF LOG. ADDR.
643
        ORA  #$10
644
        STA  CCCREG
645
        TFR  X,D
646
        COMA  ;
647
        COMB  ;
648
        STD  ADDREG
649
        LDX  #$FEFF  ; LOAD DMA BYTE COUNT = $100
650
        STX  CNTREG  ; STORE IN COUNT REGISTER
651
        LDA  #$FF    ; LOAD THE CHANNEL REGISTER
652
        STA  CCREG
653
        LDA  #$FE    ; SET CHANNEL 0
654
        STA  PRIREG
655
        LDA  #1      ; SET SECTOR TO "1"
656
        STA  SECREG  ; ISSUE COMMAND
657
        LDA  #$8C    ; SET SINGLE SECTOR READ
658
        STA  COMREG  ; ISSUE COMMAND
659
        BSR  DLY
660
*
661
* THE FOLLOWING CODE TESTS THE STATUS OF THE
662
* CHANNEL CONTROL REGISTER. IF "D7" IS NOT
663
* ZERO THEN IT WILL LOOP WAITING FOR "D7"
664
* TO GO TO ZERO. IF AFTER 65,536 TRIES IT
665
* IS STILL A ONE THE BOOT OPERATION WILL
666
* BE STARTED OVER FROM THE BEGINING.
667
*
668
        CLRB         ;
669
DBOOT1  PSHS B       ; $FB55
670
        CLRB         ;
671
DBOOT2  TST  CCREG
672
        BPL  DBOOT3
673
        DECB  ;
674
        BNE  DBOOT2
675
        PULS B
676
        DECB
677
        BNE  DBOOT1
678
        BRA  DBOOT
679
DBOOT3  PULS B
680
        LDA  COMREG
681
        BITA #$1C
682
        BEQ  DBOOT4
683
        RTS  ;
684
*
685
*
686
DBOOT4  LDB  #$DE
687
        STB  DRVREG
688
        LDX  #$C000
689
        STX  10,U
690
        TFR  U,S     ; $FB7B
691
        RTI  ;
692 59 davidgb
        ENDIF DMAFOPT
693
*
694
        IFD CF8OPT
695
*
696
* COMPACT FLASH BOOT
697
*
698
CFBOOT  BSR  WAITRDY
699
        LDA  #HEADLBA
700
        STA  CF_HEAD
701
        BSR  WAITRDY
702
        LDA  #FEAT8BIT
703
        STA  CF_FEATURE
704
        LDA  #CMDFEATURE
705
        STA  CF_COMAND
706
        BSR  WAITRDY
707
*
708
* READ SECTORS FROM CF
709
*
710
CFREAD  LDA  #$01
711
        STA  CF_SECCNT
712
        CLRA
713
        STA  CF_SECNUM
714
        STA  CF_CYLLO
715
        STA  CF_CYLHI
716
*
717
        LDA  #CMDREAD ; IDE READ MULTIPLE
718
        STA  CF_COMAND
719
        BSR  WAITRDY
720
        LDX  #$C000
721
*
722
* READ LOOP
723
*
724
RDLOOP  BSR  WAITDRQ
725
        LDA  CF_DATA
726
        STA  ,X+
727
        CMPX #$C200
728
        BNE  RDLOOP
729
*
730
        LDX  #$C000
731
        STX  $0A,U
732
        TFR  U,S
733 99 davidgb
        RTI
734 59 davidgb
*
735
* WAIT UNTIL READY
736
*
737
WAITRDY LDA  CF_STATUS
738
        BITA #BUSY
739
        BNE  WAITRDY
740
        LDA  CF_STATUS
741
        BITA #DRDY
742
        BEQ  WAITRDY
743
        RTS
744
*
745
* WAIT FOR DATA REQUEST
746
*
747
WAITDRQ LDA  CF_STATUS
748
        BITA #DRQ
749
        BEQ  WAITDRQ
750
        RTS
751
        ENDIF CF8OPT
752
*
753
        IFD IDEOPT
754
*
755
* XESS 16 BIT IDE BOOT
756
*
757
IDEBOOT LDD  #AUXRESET
758
        STD  CF_AUX
759
        LDD #AUXRSTREL
760
        STD CF_AUX
761
        LDD  #HEADLBA
762
        STD  CF_HEAD
763
        BSR  WAITRDY
764
*
765
* READ SECTORS FROM CF
766
*
767
        LDD  #$01
768
        STD  CF_SECCNT
769
        CLRB
770
        STD  CF_SECNUM
771
        STD  CF_CYLLO
772
        STD  CF_CYLHI
773
*
774
        LDB  #CMDREAD ; IDE READ MULTIPLE
775
        STD  CF_COMAND
776
        BSR  WAITRDY
777
        LDX  #$C000
778
*
779
* READ LOOP
780
*
781
RDLOOP  BSR  WAITDRQ
782
        LDD  CF_DATA
783
        STB  ,X+
784
        CMPX #$C100
785
        BNE  RDLOOP
786
*
787
        LDX  #$C000
788
        STX  $0A,U
789
        TFR  U,S
790 99 davidgb
        RTI
791 59 davidgb
*
792
* WAIT UNTIL READY
793
*
794
WAITRDY LDD  CF_STATUS
795
        BITB #BUSY
796
        BNE  WAITRDY
797
        LDD  CF_STATUS
798
        BITB #DRDY
799
        BEQ  WAITRDY
800
        RTS
801
*
802
* WAIT FOR DATA REQUEST
803
*
804
WAITDRQ LDD  CF_STATUS
805
        BITB #DRQ
806
        BEQ  WAITDRQ
807
        RTS
808
        ENDIF IDEOPT
809
*
810
        IFD RTCOPT
811
*
812
* CLOCK INTER FACE UTILITY
813
*
814
* TIME   
815
* If no argument is specified, the current time
816
* will be displayed.
817
*
818
* READ A REGISTER FROM THE COUNTER.
819
* The X Index rgister points to the register
820
* to be read. The Status Register is checked
821
* before and after the register is read before
822
* returning a value in accumulator A
823
*
824
RDCLK  TST CLKSTA
825
       BNE RDCLK
826
RDCLK1 LDA 0,X
827
       TST CLKSTA
828
       BNE RDCLK1
829
       RTS
830
*
831
* MAIN PROGRAM:
832
*
833 99 davidgb
TIMSET LDX #COUNTR    ; POINT TO TIMER
834
      LBSR BYTE       ; READ HOURS
835
      BVS  SHOWTM     ; NO ARG, DISP TIME
836 59 davidgb
      STA HOUR,X
837
      LBSR OUT1S
838 99 davidgb
      LBSR BYTE       ; READ MINUITES
839 59 davidgb
      BVS  SHOWTM
840
      STA MINUIT,X
841
      LBSR OUT1S
842 99 davidgb
      LBSR BYTE       ; SECONDS.
843 59 davidgb
      BVS SHOWTM
844
      STA SECOND,X
845
*
846
* DISPLAY CURRENT TIME
847
*
848
SHOWTM LBSR PCRLF
849
       LDX #COUNTR+HOUR
850
       LDB #3
851
SHOWLP BSR RDCLK
852
       LBSR OUT2H
853
       LDA #':
854
       LBSR OUTCH
855
       LEAX -1,X
856
       DECB
857
       BNE SHOWLP
858
       RTS
859
*
860
* INITIATE CLOCK.
861
* MASK INTERRUPTS.
862
*
863 99 davidgb
CLKINZ CLR CINTCR     ; MASK ALL INTERRUPTS
864
       TST CINTSR     ; CLEAR ANY INTERRUPTS
865 59 davidgb
       RTS
866
       ENDIF RTCOPT
867
       IFD DATOPT
868
*
869 99 davidgb
***** LRA LOAD REAL ADDRESS *****
870
*
871
* THE FOLLOWING CODE LOADS THE 20-BIT
872
* PHYSICAL ADDRESS OF A MEMORY BYTE
873
* INTO THE "A" AND "X" REGISTERS. THIS
874
* ROUTINE IS ENTERED WITH THE LOGICAL
875
* ADDRESS OF A MEMORY BYTE IN THE "IX"
876
* REGISTER. EXIT IS MADE WITH THE HIGH-
877
* ORDER FOUR BITS OF THE 20-BIT PHYSICAL
878
* ADDRESS IN THE "A" REGISTER, AND THE
879
* LOW-ORDER 16-BITS OF THE 20-BIT
880
* PHYSICAL ADDRESS IN THE "IX" REGISTER.
881
* ALL OTHER REGISTERS ARE PRESERVED.
882
* THIS ROUTINE IS REQUIRED SINCE THE
883
* DMAF1 AND DMAF2 DISK CONTROLLERS MUST
884
* PRESENT PHYSICAL ADDRESSES ON THE
885
* SYSTEM BUS.
886
*
887
LRA     PSHS A,B,X,Y  ; PUSH REGISTERS ON STACK
888
        LDA  2,S      ; GET MSB LOGICAL ADDR FRM X REG ON STACK
889
        LSRA          ;
890
        LSRA          ; ADJ FOR INDEXED INTO
891
        LSRA          ; CORRESPONDING LOCATION
892
        LSRA          ; IN LRA TABLE
893
        LDY  #LRARAM  ; LOAD LRA TABLE BASE ADDRESS
894
        LDB  A,Y      ; GET PHYSICAL ADDR. DATA FROM LRA TABLE
895
        LSRB          ; ADJ. REAL ADDR. TO REFLECT EXTENDED
896
        LSRB          ; PHYSICAL ADDRESS.
897
        LSRB          ; EXTENDED MS 4-BITS ARE RETURNED
898
        LSRB          ; IN THE "A" ACCUMULATOR
899
        STB  ,S       ; MS 4 BITS IN A ACCUM. STORED ON STACK
900
        LDB  A,Y      ; LOAD REAL ADDRESS DATA FROM LRA TABLE
901
        COMB          ; COMP TO ADJ FOR PHYSICAL ADDR. IN X REG
902
        ASLB          ; ADJ DATA FOR RELOCATION IN X REG
903
        ASLB          ;
904
        ASLB          ; $FB97
905
        ASLB          ;
906
        LDA  2,S      ; GET MS BYTE OF LOGICAL ADDR.
907
        ANDA #$0F     ; MASK MS NIBBLE OF LOGICAL ADDRESS
908
        STA  2,S      ; SAVE IT IN X REG ON STACK
909
        ORB  2,S      ; SET MS BYTE IN X REG TO ADJ PHY ADDR.
910
*
911
* PLUS LS NIBBLE OF LOGICAL ADDRESS
912
*
913
        STB  2,S      ; SAVE AS LS 16 BITS OF PHY ADDR IN X REG ON STACK
914
        PULS A,B,X,Y,PC ; POP REGS. FROM STACK
915 59 davidgb
        ENDIF DATOPT
916 99 davidgb
*
917
* DELAY LOOP
918
*
919
DLY     PSHS B        ; SAVE CONTENTS OF "B"
920
        LDB  #$20     ; GET LOOP DELAY VALUE
921
SUB1    DECB          ; SUBTRACT ONE FROM VALUE
922
        BNE  SUB1     ; LOOP UNTIL ZERO
923
        PULS B,PC     ; RESTORE CONTENTS OF "B"
924 59 davidgb
* RTS  ;
925 99 davidgb
*
926
***** "L" LOAD MIKBUG TAPE *****
927
*
928 59 davidgb
LOAD    JSR  ACINIZ
929 99 davidgb
        LDA  #$11     ; LOAD 'DC1' CASS. READ ON CODE
930
        LBSR OUTCH    ; OUTPUT IT TO TERMINAL PORT
931
        CLR  ECHO     ; TURN OFF ECHO FLAG
932
LOAD1   LBSR ECHON    ; INPUT 8 BIT BYTE WITH NO ECHO
933
LOAD2   CMPA #'S      ; IS IT AN "S", START CHARACTER ?
934
        BNE  LOAD1    ; IF NOT, DISCARD AND GET NEXT CHAR.
935
        LBSR ECHON
936
        CMPA #'9      ; IS IT A "9" , END OF FILE CHAR ?
937
        BEQ  LOAD21   ; IF SO, EXIT LOAD
938
        CMPA #'1      ; IS IT A "1" , FILE LOAD CHAR ?
939
        BNE  LOAD2    ; IF NOT, LOOK FOR START CHAR.
940
        LBSR BYTE     ; INPUT BYTE COUNT
941
        PSHS A        ; PUSH COUNT ON STACK
942
        BVS  LODERR   ; (V) C-CODE SET, ILLEGAL HEX
943
        LBSR IN1ADR   ; INPUT LOAD ADDRESS
944
        BVS  LODERR   ; (V) C-CODE SET, ADDR NOT HEX
945
        PSHS X        ; PUSH ADDR ON STACK
946
        LDB  ,S+      ; LOAD MSB OF ADDR AS CHECKSUM BYTE
947
        ADDB ,S+      ; ADD LSB OF ADDR TO CHECKSUM
948
        ADDB ,S       ; ADD BYTE COUNT BYTE TO CHECKSUM
949
        DEC  ,S       ; $FC37 DECREMENT BYTE COUNT 2 TO BYPASS
950
        DEC  ,S       ; ADDRESS BYTES.
951
LOAD10  PSHS B        ; PUSH CHECKSUM ON STACK
952
        LBSR BYTE     ; INPUT DATA BYTE (2 HEX CHAR)
953
        PULS B        ; POP CHECKSUM FROM STACK
954
        BVS  LODERR   ; (V) SET, DATA BYTE NOT HEX
955
        PSHS A        ; PUSH DATA BYTE ON STACK
956
        ADDB ,S+      ; ADD DATA TO CHECKSUM, AUTO INC STACK
957
        DEC  ,S       ; DECREMENT BYTE COUNT 1
958
        BEQ  LOAD16   ; IF BYTE COUNT ZERO, TEST CHECKSUM
959
        STA  ,X+      ; SAVE DATA BYTE IN MEMORY
960
        BRA  LOAD10   ; GET NEXT DATA BYTE
961
LODERR  CLRB          ; ERROR CONDITION, ZERO CHECKSUM  ;
962
LOAD16  PULS A        ; ADJUST STACK (REMOVE BYTE COUNT)
963
        CMPB #$FF     ; CHECKSUM OK?
964
        BEQ  LOAD1    ; IF SO, LOAD NEXT LINE
965
        LDA  #'?      ; LOAD (?) ERROR INDICATOR
966
        LBSR OUTCH    ; OUTPUT IT TO TERMINAL
967
LOAD21  COM  ECHO     ; TURN ECHO ON
968
        LDA  #$13     ; $FC5F LOAD 'DC3' CASS. READ OFF CODE
969
        LBRA OUTCH    ; OUTPUT IT
970
*
971
***** "P" PUNCH MIKBUG TAPE *****
972
*
973
PUNCH   CLR  ,-S      ; CLEAR RESERVED BYTE ON STACK
974
        LBSR IN2ADR   ; GET BEGIN AND END ADDRESS
975
        PSHS X,Y      ; SAVE ADDRESSES ON STACK
976
        BVS  PUNEXT   ; (V) C-CODE SET, EXIT PUNCH
977
        CMPX 2,S      ; COMPARE BEGIN TO END ADDR
978
        BCS  PUNEXT   ; IF BEGIN GREATER THAN END, EXIT PUNCH
979
        LEAX 1,X      ; INCREMENT END ADDRESS
980
        STX  ,S       ; STORE END ADDR ON STACK
981 59 davidgb
        JSR  ACINIZ
982 99 davidgb
        LDA  #$12     ; LOAD 'DC2' PUNCH ON CODE
983
        LBSR OUTCH    ; OUTPUT IT TO TERMINAL
984
PUNCH2  LDD  ,S       ; LOAD END ADDR IN D-ACC
985
        SUBD 2,S      ; SUBTRACT BEGIN FROM END
986
        BEQ  PUNCH3   ; SAME, PUNCH 32 BYTES DEFAULT
987
        CMPD #$20     ; LESS THAN 32 BYTES?
988
        BLS  PUNCH4   ; PUNCH THAT MANY BYTES
989
PUNCH3  LDB  #$20     ; LOAD BYTE COUNT OF 32.
990
PUNCH4  STB  4,S      ; STORE ON STACK AS BYTE COUNT
991
        LDX  #MSG20   ; POINT TO MSG "S1"
992
        LBSR PSTRNG   ; PRINT MSG
993
        ADDB #3       ; ADD 3 BYTES TO BYTE COUNT
994
        TFR  B,A      ; GET BYTE COUNT IN A-ACC TO PUNCH
995
        LBSR OUT2H    ; OUTPUT BYTE COUNT
996
        LDX  2,S      ; LOAD BEGIN ADDRESS
997
        LBSR OUT4H    ; PUNCH ADDRESS
998
        ADDB 2,S      ; ADD ADDR MSB TO CHECKSUM
999
        ADDB 3,S      ; ADD ADDR LSB TO CHECKSUM
1000
PUNCHL  ADDB ,X       ; ADD DATA BYTE TO CHECKSUM
1001
        LDA  ,X+      ; LOAD DATA BYTE TO PUNCH
1002
        LBSR OUT2H    ; OUTPUT DATA BYTE
1003
        DEC  4,S      ; DECREMENT BYTE COUNT
1004
        BNE  PUNCHL   ; NOT DONE, PUNCH NEXT BYTE
1005
        COMB  1's     ; COMPLIMENT CHECKSUM BYTE
1006
        TFR  B,A      ; GET IT IN A-ACC TO PUNCH
1007
        LBSR OUT2H    ; OUTPUT CHECKSUM BYTE
1008
        STX  2,S      ; SAVE X-REG IN STACK AS NEW PUNCH ADDR
1009
        CMPX ,S       ; COMPARE IT TO END ADDR
1010
        BNE  PUNCH2   ; $FCB5 PUNCH NOT DONE, CONT.
1011
PUNEXT  LDA  #$14     ; LOAD 'DC4' PUNCH OFF CODE
1012
        LBSR OUTCH    ; OUTPUT IT
1013
        LEAS 5,S      ; READJUST STACK POINTER
1014
        RTS  ;
1015 59 davidgb
*
1016 99 davidgb
* PRINT STRING PRECEEDED BY A CR & LF.
1017
*
1018
PSTRNG  BSR  PCRLF    ; PRINT CR/LF
1019
        BRA  PDATA    ; PRINT STRING POINTED TO BY IX
1020
*
1021
* PCRLF
1022
*
1023
PCRLF   PSHS X        ; SAVE IX
1024
        LDX  #MSG2+1  ; POINT TO MSG CR/LF + 3 NULS
1025
        LBSR PDATA    ; PRINT MSG
1026
        PULS X,PC     ; RESTORE IX & RETURN
1027
*
1028 59 davidgb
* LONG BRANCHES TO COMMON ROUTINES
1029
*
1030
JOUT1S  LBRA OUT1S
1031
JBYTE   LBRA BYTE
1032
JIN1ADR LBRA IN1ADR
1033 99 davidgb
*
1034
* ALTER "PC" PROGRAM COUNTER
1035
*
1036
ALTRPC  LBSR  PRTPC   ; $FCF5 PRINT MSG " PC = "
1037
ALTPC1  BSR  JOUT1S   ; OUTPUT SPACE
1038
        BSR  JIN1ADR  ; GET NEW CONTENTS FOR "PC"
1039
        BVS  ALTPCD   ; EXIT IF INVALID HEX
1040
        STX  10,U     ; POKE IN NEW CONTENTS
1041
ALTPCD  RTS           ;
1042
*
1043
* ALTER "U" USER STACK POINTER
1044
*
1045
ALTRU   BSR  PRTUS    ; $FCCA PRINT MSG " US = "
1046
        BSR  JOUT1S   ; OUTPUT SPACE
1047
        BSR  JIN1ADR  ; GET NEW CONTENTS FOR "US"
1048
        BVS  ALTUD    ; EXIT IF INVALID HEX
1049
        STX  8,U      ; POKE IN NEW CONTENTS
1050
ALTUD   RTS           ;
1051
*
1052
* ALTER "Y" INDEX REGISTER
1053
*
1054
ALTRY   BSR  PRTIY    ; PRINT MSG " IY = "
1055
        BSR  JOUT1S   ; OUTPUT SPACE
1056
        BSR  JIN1ADR  ; GET NEW CONTENTS FOR "IY"
1057
        BVS  ALTYD    ; EXIT IF INVALID HEX
1058
        STX  6,U      ; $F8F0 POKE IN NEW CONTENTS
1059
ALTYD   RTS           ;
1060
*
1061
* ALTER "X" INDEX REGISTER
1062
*
1063
ALTRX   BSR  PRTIX    ; $FCE0 PRINT MSG " IX = "
1064
        BSR  JOUT1S   ; OUTPUT SPACE
1065
        BSR  JIN1ADR
1066
        BVS  ALTXD
1067
        STX  4,U
1068 59 davidgb
ALTXD   RTS ;
1069 99 davidgb
*
1070
* ALTER "DP" DIRECT PAGE REGISTER
1071
*
1072
ALTRDP  BSR  PRTDP    ; $FCD5 PRINT MSG " DP = "
1073
        BSR  JOUT1S   ; OUTPUT SPACE
1074
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
1075
        BVS  ALTDPD
1076
        STA  3,U
1077 59 davidgb
ALTDPD  RTS ;
1078 99 davidgb
*
1079
* ALTER "B" ACCUMULATOR
1080
*
1081
ALTRB   BSR  PRTB     ; $FD09 PRINT MSG " B = "
1082
        BSR  JOUT1S   ; OUTPUT SPACE
1083
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
1084
        BVS  ALTBD
1085
        STA  2,U
1086
ALTBD   RTS           ; $F91C
1087
*
1088
* ALTER "A" ACCUMULATOR
1089
*
1090
ALTRA   BSR  PRTA     ; $FCFF RINT MSG " A = "
1091
        BSR  JOUT1S   ; OUTPUT SPACE
1092
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
1093
        BVS  ALTAD
1094
        STA  1,U
1095 59 davidgb
ALTAD   RTS ;
1096 99 davidgb
*
1097
* ALTER "CC" REGISTER
1098
*
1099
ALTRCC  BSR  PRTCC    ; $FD13 PRINT MSG " CC: "
1100
        BSR  JOUT1S   ; OUTPUT SPACE
1101
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
1102
        BVS  ALTCCD
1103
        ORA  #$80     ; SETS "E" FLAG IN PRINT LIST
1104
        STA  ,U
1105 59 davidgb
ALTCCD  RTS ;
1106
*
1107 99 davidgb
* PDATA
1108
*
1109
PRINT   LBSR OUTCH
1110
PDATA   LDA  ,X+      ; GET 1st CHAR. TO PRINT
1111
        CMPA #4       ; IS IT EOT?
1112
        BNE  PRINT    ; IF NOT EOT PRINT IT
1113
        RTS  ;
1114
*
1115 59 davidgb
* PRINT REGISTERS
1116
*
1117 99 davidgb
PRTSP   LDX  #MSG10   ; POINT TO MSG "SP="
1118
        BSR  PDATA    ; PRINT MSG
1119
        TFR  U,X
1120
JOUT4H  LBRA OUT4H
1121 59 davidgb
*
1122 99 davidgb
PRTUS   LDX  #MSG12   ; POINT TO MSG "US="
1123
        BSR  PDATA    ; PRINT MSG
1124
        LDX  8,U
1125
        BRA  JOUT4H
1126 59 davidgb
*
1127 99 davidgb
PRTDP   LDX   #MSG15  ; POINT TO MSG "DP="
1128
        BSR  PDATA    ; PRINT MSG
1129
        LDA  3,U
1130
JOUT2H  LBRA OUT2H    ; OUTPUT HEX BYTE AS ASCII
1131 59 davidgb
*
1132 99 davidgb
PRTIX   LDX  #MSG14   ; POINT TO MSG "IX="
1133
        BSR  PDATA    ; PRINT MSG
1134
        LDX  4,U      ; $FCE6
1135
        BRA  JOUT4H
1136 59 davidgb
*
1137 99 davidgb
PRTIY   LDX  #MSG13   ; POINT TO MSG "IY="
1138
        BSR  PDATA    ; PRINT MSG
1139
        LDX  6,U
1140
        BRA  JOUT4H
1141 59 davidgb
*
1142 99 davidgb
PRTPC   LDX  #MSG11   ; POINT TO MSG "PC="
1143
        BSR  PDATA    ; PRINT MSG
1144
        LDX  10,U
1145
        BRA  JOUT4H
1146 59 davidgb
*
1147 99 davidgb
PRTA    LDX  #MSG16   ; POINT TO MSG "A="
1148
        BSR  PDATA    ; PRINT MSG
1149
        LDA  1,U
1150
        BRA  JOUT2H   ; OUTPUT HEX BYTE AS ASCII
1151 59 davidgb
*
1152 99 davidgb
PRTB    LDX  #MSG17   ; POINT TO MSG "B="
1153
        BSR  PDATA    ; PRINT MSG
1154
        LDA  2,U
1155
        BRA  JOUT2H   ; OUTPUT HEX BYTE AS ASCII
1156 59 davidgb
*
1157 99 davidgb
PRTCC   LDX  #MSG18   ; POINT TO MSG "CC:"
1158
        BSR  PDATA    ; PRINT MSG
1159
        LDA  ,U
1160
        LDX  #MSG19   ; POINT TO MSG "EFHINZVC"
1161
        LBRA BIASCI   ; OUTPUT IN BINARY/ASCII FORMAT
1162 59 davidgb
*
1163 99 davidgb
* "R" DISPLAY REGISTERS
1164 59 davidgb
*
1165 99 davidgb
REGSTR  LDX  #MSG5    ; POINT TO MSG " - "
1166
        LBSR PSTRNG   ; PRINT MSG
1167
        BSR  PRTSP    ; $FCBF
1168
        BSR  PRTUS    ; $FCCA
1169
        BSR  PRTDP    ; $FCD5
1170
        BSR  PRTIX    ; $FCE0
1171
        BSR  PRTIY    ; $FCEB
1172
        LDX  #MSG5    ; POINT TO MSG " - "
1173
        LBSR PSTRNG   ; PRINT MSG
1174
        BSR  PRTPC    ; $FCF5
1175
        BSR  PRTA     ; $FCFF
1176
        BSR  PRTB     ; $FD09
1177
        BRA  PRTCC    ; $FD13
1178
*
1179
* THE FOLLOWING ROUTINE LOOPS WAITING FOR THE
1180
* OPERATOR TO INPUT TWO VALID HEX ADDRESSES.
1181
* THE FIRST ADDRESS INPUT IS RETURNED IN "IY".
1182
* THE SECOND IS RETURNED IN "IX". THE "V" BIT
1183
* IN THE C-CODE REG. IS SET IF AN INVALID HEX
1184
* ADDRESS IS INPUT.
1185
*
1186
IN2ADR  BSR  IN1ADR   ; GET FIRST ADDRESS
1187
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
1188
        TFR  X,Y      ; SAVE FIRST ADDR. IN "IY"
1189
        LDA  #'-
1190
        LBSR OUTCH    ; PRINT " - "
1191
*
1192
* THE FOLLOWING ROUTINE LOOPS WAITING FOR THE
1193
* OPERATOR TO INPUT ONE VALID HEX ADDRESS. THE
1194
* ADDRESS IS RETURNED IN THE "X" REGISTER.
1195
*
1196
IN1ADR  BSR  BYTE     ; INPUT BYTE (2 HEX CHAR)
1197
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
1198
        TFR  D,X
1199
        BSR  BYTE     ; INPUT BYTE (2 HEX CHAR)
1200
        BVS  NOTHEX
1201
        PSHS X
1202
        STA  1,S
1203
        PULS X,PC
1204
*
1205
***** INPUT BYTE (2 HEX CHAR.) *****
1206
*
1207
BYTE    BSR  INHEX    ; GET HEX LEFT
1208
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
1209
        ASLA          ;
1210
        ASLA          ;
1211
        ASLA          ; SHIFT INTO LEFT NIBBLE
1212
        ASLA          ;
1213
        TFR  A,B      ; PUT HEXL IN "B"
1214
        BSR  INHEX    ; GET HEX RIGHT
1215
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
1216
        PSHS B        ; PUSH HEXL ON STACK
1217
        ADDA ,S+      ; ADD HEXL TO HEXR AND ADJ. STK
1218
        RTS           ; RETURN WITH HEX L&R IN "A"
1219
*
1220
*
1221
INHEX   BSR  ECHON    ; INPUT ASCII CHAR.
1222
        CMPA #'0      ; IS IT > OR = "0" ?
1223
        BCS  NOTHEX   ; IF LESS IT AIN'T HEX
1224
        CMPA #'9      ; IS IT < OR = "9" ?
1225
        BHI  INHEXA   ; IF > MAYBE IT'S ALPHA
1226
        SUBA #$30     ; ASCII ADJ. NUMERIC
1227
        RTS           ;
1228
*
1229
*
1230
INHEXA  CMPA #'A      ; IS IT > OR = "A"
1231
        BCS  NOTHEX   ; IF LESS IT AIN'T HEX
1232
        CMPA #'F      ; IS IT < OR = "F" ?
1233
        BHI  INHEXL   ; IF > IT AIN'T HEX
1234
        SUBA #'A-10   ; ($37) ASCII ADJ. ALPHA
1235
        RTS           ;
1236
*
1237
INHEXL  CMPA #'a      ; IS IT > OR = "a"
1238
        BCS  NOTHEX   ; IF LESS IT AIN'T HEX
1239
        CMPA #'f      ; IS IT < "f"
1240
        BHI  NOTHEX   ; IF > IT AIN'T HEX
1241
        SUBA #'a-10   ; ($57) ADJUST TO LOWER CASE
1242
        RTS           ;
1243
*
1244
*
1245
NOTHEX  ORCC #2       ; SET (V) FLAG IN C-CODES REGISTER
1246
        RTS           ;
1247
*
1248
*
1249
OUT4H   PSHS X        ; PUSH X-REG. ON THE STACK
1250
        PULS A        ; POP MS BYTE OF X-REG INTO A-ACC.
1251
        BSR  OUTHL    ; OUTPUT HEX LEFT
1252
        PULS A        ; POP LS BYTE OF X-REG INTO A-ACC.
1253
OUTHL   EQU *
1254
OUT2H   PSHS A        ; SAVE IT BACK ON STACK
1255
        LSRA          ; CONVERT UPPER HEX NIBBLE TO ASCII
1256
        LSRA          ;
1257
        LSRA          ;
1258
        LSRA          ;
1259
        BSR  XASCII   ; PRINT HEX NIBBLE AS ASCII
1260
OUTHR   PULS A        ; CONVERT LOWER HEX NIBBLE TO ASCII
1261
        ANDA #$0F     ; STRIP LEFT NIBBLE
1262
XASCII  ADDA #$30     ; ASCII ADJ
1263
        CMPA #$39     ; IS IT < OR = "9" ?
1264
        BLE  OUTC     ; IF LESS, OUTPUT IT
1265
        ADDA #7       ; IF > MAKE ASCII LETTER
1266
OUTC    BRA OUTCH     ;  OUTPUT CHAR
1267
*
1268
* BINARY / ASCII --- THIS ROUTINE
1269
* OUTPUTS A BYTE IN ENHANCED
1270
* BINARY FORMAT. THE ENHANCEMENT
1271
* IS DONE BY SUBSTITUTING ASCII
1272
* LETTERS FOR THE ONES IN THE BYTE.
1273
* THE ASCII ENHANCEMENT LETTERS
1274
* ARE OBTAINED FROM THE STRING
1275
* POINTED TO BY THE INDEX REG. "X".
1276
*
1277
BIASCI  PSHS A        ; SAVE "A" ON STACK
1278
        LDB  #8       ; PRESET LOOP# TO BITS PER BYTE
1279
OUTBA   LDA  ,X+      ; GET LETTER FROM STRING
1280
        ASL  ,S       ; TEST BYTE FOR "1" IN B7
1281
        BCS  PRTBA    ; IF ONE PRINT LETTER
1282
        LDA  #'-      ; IF ZERO PRINT "-"
1283
PRTBA   BSR  OUTCH    ; PRINT IT
1284
        BSR  OUT1S    ; PRINT SPACE
1285
        DECB          ; SUB 1 FROM #BITS YET TO PRINT
1286
        BNE  OUTBA
1287
        PULS A,PC
1288
*
1289
        IFD EXTOPT
1290
*
1291 59 davidgb
* EXTENDED USER COMMANDS
1292
*
1293 99 davidgb
USRCMD  JMP [MONEXT+EXTCMD]
1294
        ENDIF EXTOPT
1295
*
1296
*
1297
ECHON   TST  ECHO     ; IS ECHO REQUIRED ?
1298
        BEQ  INCH     ; ECHO NOT REQ. IF CLEAR
1299
*
1300
* INCHE
1301
*
1302
* GETS CHARACTER FROM TERMINAL AND
1303
* ECHOS SAME. THE CHARACTER IS RETURNED
1304
* IN THE "A" ACCUMULATOR WITH THE PARITY
1305
* BIT MASKED OFF. ALL OTHER REGISTERS
1306
* ARE PRESERVED.
1307
*
1308
INCHE   BSR  INCH     ; GET CHAR FROM TERMINAL
1309
        ANDA #$7F     ; STRIP PARITY FROM CHAR.
1310
        BRA  OUTCH    ; ECHO CHAR TO TERMINAL
1311
*
1312
* INCH
1313
*
1314
* GET CHARACTER FROM TERMINAL. RETURN
1315
* CHARACTER IN "A" ACCUMULATOR AND PRESERVE
1316
* ALL OTHER REGISTERS. THE INPUT CHARACTER
1317
* IS 8 BITS AND IS NOT ECHOED.
1318
*
1319
*
1320
INCH    PSHS X        ; SAVE IX
1321
        IFD  HFCOPT
1322
        LDA  #$11     ; SET RTS* LOW, REQUEST FAR END TO TX
1323
        STA  [CPORT]
1324
        ENDIF HFCOPT
1325
GETSTA  LDX  CPORT    ; POINT TO TERMINAL PORT
1326
        LDA  ,X       ; FETCH PORT STATUS
1327
        BITA #1       ; TEST READY BIT, RDRF ?
1328
        IFD  PS2OPT
1329
        BNE  GETST1
1330
        LDX  #PS2KBD
1331
        LDA  ,X
1332
        BITA #1
1333
        ENDIF PS2OPT
1334
        BEQ  GETSTA   ; IF NOT RDY, THEN TRY AGAIN
1335
GETST1  EQU  *
1336
        IFD  HFCOPT
1337
        LDA  #$51     ; SET RTS* HIGH, STOP FAR END FROM TXING, UNTIL NEXT INPUT
1338
        STA  [CPORT]
1339
        ENDIF HFCOPT
1340
        LDA  1,X      ; FETCH CHAR
1341
        PULS X,PC     ; RESTORE IX
1342
*
1343
* INCHEK
1344
*
1345
* CHECK FOR A CHARACTER AVAILABLE FROM
1346
* THE TERMINAL. THE SERIAL PORT IS CHECKED
1347
* FOR READ READY. ALL REGISTERS ARE
1348
* PRESERVED, AND THE "Z" BIT WILL BE
1349
* CLEAR IF A CHARACTER CAN BE READ.
1350
*
1351
*
1352
INCHEK  PSHS A        ; SAVE A ACCUM
1353
        IFD  HFCOPT
1354
        LDA  #$11     ; SET RTS* LOW, REQUEST FAR END TO TX
1355
        STA  [CPORT]
1356
        ENDIF HFCOPT
1357
        LDA  [CPORT]  ; FETCH PORT STATUS
1358
        BITA #1       ; TEST READY BIT, RDRF ?
1359
        IFD  PS2OPT
1360 59 davidgb
        BNE  INCHEK1
1361
        LDA  PS2KBD
1362 99 davidgb
        BITA #1       ; TEST READY BIT< RDRF ?
1363
        ENDIF PS2OPT
1364
INCHEK1 PULS A,PC     ; RESTORE A ACCUM.
1365
*
1366
OUT2S   BSR  OUT1S    ; OUTPUT 2 SPACES
1367
OUT1S   LDA  #$20     ; OUTPUT 1 SPACE
1368
*
1369
*
1370
* OUTCH
1371
*
1372
* OUTPUT CHARACTER TO TERMINAL.
1373
* THE CHAR. TO BE OUTPUT IS
1374
* PASSED IN THE A REGISTER.
1375
* ALL REGISTERS ARE PRESERVED.
1376
*
1377
OUTCH   IFD   VDUOPT
1378
        BSR   VOUTCH
1379 59 davidgb
        ENDIF VDUOPT
1380 99 davidgb
        IFD   DG640OPT
1381
        BSR   VOUTCH
1382 59 davidgb
        ENDIF DG640OPT
1383 99 davidgb
AOUTCH  PSHS A,X      ; SAVE A ACCUM AND IX
1384
        LDX  CPORT    ; GET ADDR. OF TERMINAL
1385
FETSTA  LDA  ,X       ; FETCH PORT STATUS
1386
        BITA #2       ; TEST TDRE, OK TO XMIT ?
1387
        BEQ  FETSTA   ; IF NOT LOOP UNTIL RDY
1388
        BITA #8       ; CLEAR TO SEND ?
1389
        BNE  FETSTA   ; NO, LOOP UNTIL CLEAR
1390
        PULS A        ; GET CHAR. FOR XMIT
1391
        STA  1,X      ; XMIT CHAR.
1392
        PULS X,PC     ; RESTORE IX
1393
*
1394 59 davidgb
* IO INITIALIZATION
1395
*
1396 99 davidgb
IOINIZ  EQU  *
1397 59 davidgb
        IFD  VDUOPT
1398
        BSR  VINIZ
1399
        ENDIF VDUOPT
1400
        IFD  DG640OPT
1401
        BSR  VINIZ
1402
        ENDIF DG640OPT
1403 99 davidgb
ACINIZ  LDX  CPORT    ; POINT TO CONTROL PORT ADDRESS
1404
        LDA  #3       ; RESET ACIA PORT CODE
1405
        STA  ,X       ; STORE IN CONTROL REGISTER
1406
        LDA  #$51     ; SET 8 DATA, 2 STOP AN 0 PARITY RTS* HIGH
1407
        STA  ,X       ; STORE IN CONTROL REGISTER
1408
        TST  1,X      ; ANYTHING IN DATA REGISTER?
1409
        LDA  #$FF     ; TURN ON ECHO FLAG
1410
        STA  ECHO
1411
        RTS
1412 59 davidgb
*
1413
        IFD VDUOPT
1414 99 davidgb
*
1415 59 davidgb
***************************************************
1416
*      VDU8 ADM3A REGISTER-MAPPED EMULATOR        *
1417
*                                                 *
1418
*      80 x 25 Characters
1419
*
1420
***************************************************
1421
*
1422
***************************************************
1423
*               INITIALIZE EMULATOR               *
1424
***************************************************
1425
*
1426 99 davidgb
VINIZ   LDX  #VDU
1427
        LDD  #0
1428
        STD  COLADX   ; AND ROWADX
1429
        STA  VDUCOL,X
1430
        STB  VDUROW,X
1431
        STB  VDUOFF,X
1432
        STD  NEWROW   ; AND ESCFLG
1433
        LDB  #$02
1434
        STB  VDUATT,X
1435
        CLR  ESCFLG
1436
        LDA  #$1B     ; SEND ESCAPE
1437
        BSR  VOUTCH
1438
        LDA  #'Y      ; CLEAR TO END OF SCREEN
1439 59 davidgb
*
1440
** VIDEO OUTPUT ROUTINE
1441
*
1442 99 davidgb
VOUTCH  PSHS A,B,X    ; SAVE REGISTERS
1443
        LDX  #VDU     ; POINT TO VDU REGISTERS
1444 59 davidgb
*
1445
** CHECK FOR ESCAPE SEQUENCE
1446
*
1447 99 davidgb
        TST  ESCFLG   ; ESCAPE ACTIVE?
1448
        BEQ  SOROU1   ; BRANCH IF NOT
1449
        BSR  ESCAPE   ; ELSE DO ESCAPE
1450
        BRA  RETURN   ; AND RETURN
1451 59 davidgb
*
1452
** CHECK FOR CONTROL CHARACTERS
1453
*
1454 99 davidgb
SOROU1  CMPA #$20     ; CONTROL CODES?
1455
        BHS  SOROU2
1456
        BSR  CONTRL   ; BRANCH IF SO
1457
        BRA  RETURN
1458 59 davidgb
*
1459
** OUTPUT TEXT CHARACTER
1460
*
1461 99 davidgb
SOROU2  STA  VDUCHR,X ; DISPLAY CHARACTER
1462
        LBSR NEWCOL   ; UPDATE COLUMN
1463 59 davidgb
*
1464
** DISPLAY CURSOR AND RETURN
1465
*
1466 99 davidgb
RETURN  PULS A,B,X,PC ; RESTORE REGISTERS AND RETURN
1467 59 davidgb
*
1468
***************************************************
1469
*              CONTROL CODE HANDLERS              *
1470
***************************************************
1471
*
1472 99 davidgb
CONTRL  CMPA #$08     ; CTRL H - BACKSPACE ?
1473
        BEQ  BACKSP
1474
        CMPA #$1B     ; ESCAPE SEQUENCE?
1475
        BEQ  SETESC
1476
        CMPA #$1A     ; CTRL Z - Clear Screen
1477
        LBEQ CLRSCR
1478
        CMPA #$16     ; CTRL ^ - Home
1479
        BEQ  HOME
1480
        CMPA #$0D     ; CTRL M - RETURN?
1481
        LBEQ CRETN
1482
        CMPA #$0C     ; CTRL L - CHAR RIGHT
1483
        BEQ  CHRIGHT
1484
        CMPA #$0B     ; CTRL K - MOVE UP ONE LINE
1485
        BEQ  LINEUP
1486
        CMPA #$0A     ; CTRL J - LINE FEED
1487
        BNE  RETESC   ; NONE OF THESE, RETURN
1488 59 davidgb
*
1489
***************************************** LINE FEED
1490
*
1491 99 davidgb
LINEFD  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
1492
        INCB          ; BUMP ROW
1493
        CMPB #NUMLIN  ; SCROLL TIME?
1494
        BNE  NEWCUR   ; POSITION CURSOR IF NOT
1495
        LBRA SCROLL   ; ELSE SCROLL IT
1496 59 davidgb
*
1497
***************************************** LINE FEED
1498
*
1499 99 davidgb
LINEUP  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
1500
        TSTB          ; AT TOP OF SCREEN ?
1501
        BEQ  RETESC   ; Yes, Ignore
1502
        DECB          ; No, Decrement ROW
1503
        BRA  NEWCUR   ; POSITION CURSOR
1504 59 davidgb
*
1505
*********************************** BACK SPACE
1506
*
1507 99 davidgb
BACKSP  LDA  COLADX
1508
        BEQ  RETESC   ; RETURN
1509 59 davidgb
        DECA
1510 99 davidgb
        BRA  POSCOL   ; POSITION CURSOR
1511 59 davidgb
*
1512
*********************************** CURSOR RIGHT
1513
*
1514 99 davidgb
CHRIGHT LDA  COLADX
1515 59 davidgb
        INCA
1516 99 davidgb
        CMPA #LINLEN
1517
        BEQ  RETESC
1518
        BRA  POSCOL
1519 59 davidgb
*
1520
*********************************** CURSOR RIGHT
1521
*
1522 99 davidgb
HOME    LDD  #0       ; HOME - POSITION TOP OF SCREEN
1523
        BRA  NEWCUR
1524 59 davidgb
*
1525
***************************************************
1526
*                 ESCAPE HANDLERS                 *
1527
***************************************************
1528
*
1529 99 davidgb
ESCAPE  LDB  ESCFLG   ; GET FLAG
1530
        CMPB #'=      ; SETTING CURSOR?
1531
        BEQ  ESCCUR   ; BRANCH IF SO
1532
        CMPA #'Y      ; CLEAR TO END OF SCREEN?
1533
        BEQ  ESCCLS
1534
        CMPA #'T      ; CLEAR TO END OF LINE?
1535
        BEQ  ESCCLL
1536
        CMPA #'=      ; STARTING CURSOR SET?
1537
        BNE  CLRESC   ; BRANCH IF NOT
1538 59 davidgb
*
1539
***************************** START ESCAPE SEQUENCE
1540
*
1541 99 davidgb
SETESC  STA  ESCFLG   ; ELSE START CURSORING
1542
        RTS           ; AND RETURN
1543 59 davidgb
*
1544 99 davidgb
CLRESC  CLR  ESCFLG   ; NO OTHERS SUPPORTED
1545
RETESC  RTS           ; SO RETURN
1546 59 davidgb
*
1547
********************************* SET SCREEN CURSOR
1548
*
1549 99 davidgb
ESCCUR  TST  NEWROW   ; ROW SET?
1550
        BNE  ESCCU1   ; BRANCH IF SO
1551
        STA  NEWROW   ; ELSE SET NEW ROW
1552
        RTS           ; AND RETURN
1553 59 davidgb
*
1554 99 davidgb
ESCCU1  CLR  ESCFLG
1555
        SUBA #$20     ; ADJUST COLUMN ADDRESS
1556
        CMPA #LINLEN-1 ;CHECK FOR ACCEPTABLE COLUM
1557
        BHI  RETESC   ; NOT OK, DO NOTHING
1558 59 davidgb
*
1559 99 davidgb
ESCCU2  LDB  NEWROW
1560
        CLR  NEWROW
1561
        SUBB #$20     ; ADJUST TO ROW ADDRESS
1562
        CMPB #NUMLIN-1 ; CHECK FOR ACCEPTABLE ROW
1563
        BHI  RETESC   ; ELSE RETURN DOING NOTHING
1564
        BRA  NEWCUR   ; GO SET NEW CURSOR IF SO
1565 59 davidgb
*
1566
****************** CLEAR FROM CURSOR TO END OF LINE
1567 99 davidgb
*
1568
CLRSCR  LDD  #0       ; CLEAR FROM TOP OF SCREEN
1569
        BSR  NEWCUR
1570
ESCCLL  LDA  COLADX
1571
        LDB  #$20     ; AND CLEAR CHAR
1572
ESCCL1  STB  VDUCHR,X ; DISPLAY TEXT
1573 59 davidgb
        INCA
1574 99 davidgb
        STA  VDUCOL,X
1575
        CMPA #LINLEN  ; UNTIL END OF LINE
1576
        BNE  ESCCL1
1577
        CLR  ESCFLG
1578 59 davidgb
        RTS
1579
*
1580
*********************************** CARRIAGE RETURN
1581
*
1582 99 davidgb
CRETN   CLRA          ; SET COLUMN ZERO
1583
POSCOL  LDB  ROWADX   ; GET CURRENT ROW
1584 59 davidgb
*
1585
*********** GENERATE NEW CURSOR POSITION AND RETURN
1586
*
1587 99 davidgb
NEWCUR  STD  COLADX   ; SAVE NEW ROW AND COLUMN
1588
        STA  VDUCOL,X ; SET NEW COLUMN
1589
        STB  VDUROW,X ; SET NEW ROW
1590
        RTS           ; AND RETURN
1591 59 davidgb
*
1592
********************* UPDATE CURRENT COLUMN AND ROW
1593
*
1594 99 davidgb
NEWCOL  LDD  COLADX   ; GET ROW AND COLUMN
1595
        INCA          ; BUMP COLUMN
1596
        CMPA #LINLEN  ; ROLL?
1597
        BNE  NEWCUR   ; BRANCH IF NOT
1598
        CLRA          ; ELSE RESET TO ZERO
1599
        INCB          ; AND BUMP ROW
1600
        CMPB #NUMLIN
1601
        BNE  NEWCUR
1602
        DECB          ; BOTTOM ROW
1603
        BSR  NEWCUR
1604 59 davidgb
*
1605
********************************* SCROLL THE SCREEN
1606
*
1607 99 davidgb
SCROLL  LDB  VDUOFF,X
1608 59 davidgb
        INCB
1609 99 davidgb
        CMPB #NUMLIN
1610
        BLO  SCROL1
1611 59 davidgb
        CLRB
1612 99 davidgb
SCROL1  STB  VDUOFF,X
1613 59 davidgb
*
1614
**************** CLEAR FROM CURSOR TO END OF SCREEN
1615
*
1616 99 davidgb
ESCCLS  LDB  COLADX   ; GET CURSOR
1617
        LDA  #$20     ; GET A SPACE
1618
ESCCLS1 STB  COLADX
1619
        STB  VDUCOL,X
1620
        STA  VDUCHR,X
1621 59 davidgb
        INCB
1622 99 davidgb
        CMPB #LINLEN
1623
        BNE  ESCCLS1
1624 59 davidgb
*
1625 99 davidgb
        LDB  ROWADX
1626 59 davidgb
        INCB
1627 99 davidgb
        CMPB #NUMLIN
1628
        BEQ  ESCCLS2
1629
        STB  ROWADX
1630
        STB  VDUROW,X
1631 59 davidgb
        CLRB
1632 99 davidgb
        BRA  ESCCLS1
1633 59 davidgb
*
1634
ESCCLS2 CLRB
1635 99 davidgb
        STB  COLADX
1636
        STB  VDUCOL,X
1637
        STB  ESCFLG
1638 59 davidgb
        RTS
1639
        ENDIF VDUOPT
1640 99 davidgb
*
1641 59 davidgb
        IFD DG640OPT
1642
***************************************************
1643
*      TELEVIDEO-TYPE MEMORY-MAPPED EMULATOR      *
1644
*                                                 *
1645
* FOR HARD-WIRED MEMORY-MAPPED DISPLAYS USING THE *
1646
* HIGH ORDER BIT OF EACH BYTE FOR  REVERSE  VIDEO *
1647
* CURSORING  (SUCH  AS THE THOMAS INSTRUMENTATION *
1648
* 16x64 BOARD).                                   *
1649
***************************************************
1650 99 davidgb
*
1651 59 davidgb
***************************************************
1652
*               INITIALIZE EMULATOR               *
1653
***************************************************
1654
*
1655 99 davidgb
VINIZ   LDX  #0
1656
        STX  COLADX   ; AND ROWADX
1657
        STX  NEWROW   ; AND ESCFLG
1658
        LDX  #SCREEN  ; POINT TO SCREEN
1659
        STX  CURSOR   ; SET PROGRAM CURSOR
1660
        LDA  #$1B     ; SEND ESCAPE
1661
        BSR  VOUTCH
1662
        LDA  #'Y      ; CLEAR TO END OF SCREEN
1663
*
1664 59 davidgb
** VIDEO OUTPUT ROUTINE
1665
*
1666 99 davidgb
VOUTCH  PSHS A,B,X    ; SAVE REGISTERS
1667 59 davidgb
*
1668
** CLEAR CURSOR
1669
*
1670 99 davidgb
        LDX  CURSOR
1671
        LDB  0,X
1672
        ANDB #$7F
1673
        STB  0,X
1674
*
1675 59 davidgb
** CHECK FOR ESCAPE SEQUENCE
1676
*
1677 99 davidgb
        TST  ESCFLG   ; ESCAPE ACTIVE?
1678
        BEQ  SOROU1   ; BRANCH IF NOT
1679
        BSR  ESCAPE   ; ELSE DO ESCAPE
1680
        BRA  RETURN   ; AND RETURN
1681
*
1682 59 davidgb
** CHECK FOR CONTROL CHARACTERS
1683
*
1684 99 davidgb
SOROU1  CMPA #$20     ; CONTROL CODES?
1685
        BHS  SOROU2
1686
        BSR  CONTRL   ; BRANCH IF SO
1687
        BRA  RETURN
1688
*
1689 59 davidgb
** OUTPUT TEXT CHARACTER
1690
*
1691 99 davidgb
SOROU2  LDX  CURSOR   ; ELSE GET CURSOR
1692
        STA  0,X      ; DISPLAY CHARACTER
1693
        LBSR NEWCOL   ; UPDATE COLUMN
1694
*
1695 59 davidgb
** DISPLAY CURSOR AND RETURN
1696 99 davidgb
*
1697
RETURN  LDX  CURSOR   ; AND DISPLAY IT
1698
        LDB  ,X
1699
        ORB  #$80     ; WITH REVID
1700
        STB  ,X
1701
        PULS A,B,X,PC ; RESTORE REGISTERS AND RETURN
1702
*
1703 59 davidgb
***************************************************
1704
*              CONTROL CODE HANDLERS              *
1705
***************************************************
1706 99 davidgb
*
1707
CONTRL  CMPA #$08     ; CTRL H - BACKSPACE ?
1708
        LBEQ BACKSP
1709
        CMPA #$1B     ; ESCAPE SEQUENCE?
1710
        LBEQ SETESC
1711
        CMPA #$D      ; CTRL M - RETURN?
1712
        LBEQ CRETN
1713
        CMPA #$0A     ; CTRL J - LINE FEED
1714
        BNE  RETESC   ; NONE OF THESE, RETURN
1715
*
1716 59 davidgb
***************************************** LINE FEED
1717 99 davidgb
*
1718
LINEFD  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
1719
        INCB          ; BUMP ROW
1720
        CMPB #NUMLIN  ; SCROLL TIME?
1721
        LBNE NEWCUR   ; POSITION CURSOR IF NOT
1722
        LBRA SCROLL   ; ELSE SCROLL IT
1723
*
1724 59 davidgb
***************************************** LINE FEED
1725 99 davidgb
*
1726
LINEUP  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
1727
        TSTB          ; AT TOP OF SCREEN ?
1728
        BEQ  RETESC   ; YES, RETURN
1729
        DECB          ; NO, DECREMENT ROW
1730
        LBRA NEWCUR   ; POSITION CURSOR
1731
*
1732 59 davidgb
*********************************** BACK SPACE
1733 99 davidgb
*
1734
BACKSP  LDA  COLADX    ; GET CURRENT COLUMN AND ROW
1735
        BEQ  RETESC    ; IF AT TOP LEFT CORNER RETURN
1736
        DECA           ; OTHERWISE BACK STEP ONE CHARACTER
1737
        LBRA POSCOL    ; POSITION CURSOR
1738
*
1739 59 davidgb
*********************************** CURSOR RIGHT
1740 99 davidgb
*
1741
CHRIGHT LDA  COLADX    ; GET CURRENT COLUMN AND ROW
1742
        INCA           ; MOVE RIGHT ONE CHARACTER
1743
        CMPA #LINLEN   ; ARE WE AT THE END OF THE LINE ?
1744
        BEQ  RETESC    ; YES, RETURN
1745
        LBRA POSCOL    ; NO, POSITION CURSOR
1746
*
1747 59 davidgb
***************************************************
1748
*                 ESCAPE HANDLERS                 *
1749
***************************************************
1750 99 davidgb
*
1751
ESCAPE  LDB  ESCFLG   ; ARE WE IN AN ESCAPE SEQUENCE ?
1752
        CMPB #'=      ; ARE WE SETTING CURSOR?
1753
        BEQ  ESCCUR   ; YES BRANCH TO SET CURSOR
1754
        CMPA #'Y      ; CLEAR TO END OF SCREEN?
1755
        LBEQ ESCCLS   ; YES, CLEAR SCREEN
1756
        CMPA #'T      ; CLEAR TO END OF LINE?
1757
        BEQ  ESCCLL   ; YES, CLEAR LINE
1758
        CMPA #'E      ; INSERT LINE?
1759
        BEQ  ESCINL
1760
        CMPA #'R      ; DELETE LINE?
1761
        BEQ  ESCDLL
1762
        CMPA #'=      ; STARTING CURSOR SET?
1763
        BNE  CLRESC   ; BRANCH IF NOT
1764
*
1765 59 davidgb
***************************** START ESCAPE SEQUENCE
1766 99 davidgb
*
1767
SETESC  STA  ESCFLG   ; ELSE START CURSORING
1768
        RTS           ; AND RETURN
1769
*
1770
CLRESC  CLR  ESCFLG   ; NO OTHERS SUPPORTED
1771
RETESC  RTS           ;  SO RETURN
1772
*
1773 59 davidgb
********************************* SET SCREEN CURSOR
1774
*
1775 99 davidgb
ESCCUR  TST  NEWROW   ; ROW SET?
1776
        BNE  ESCCU1   ; BRANCH IF SO
1777
        STA  NEWROW   ; ELSE SET NEW ROW
1778
        RTS           ;  AND RETURN
1779
*
1780
ESCCU1  CLR  ESCFLG
1781
        SUBA #$20      ; ADJUST COLUMN ADDRESS
1782
        CMPA #LINLEN-1 ; CHECK FOR ACCEPTABLE COLUM
1783
        BHI  RETESC    ; NOT OK, DO NOTHING
1784
*
1785
ESCCU2  LDB  NEWROW
1786
        CLR  NEWROW
1787
        SUBB #$20      ; ADJUST TO ROW ADDRESS
1788
        CMPB #NUMLIN-1 ; CHECK FOR ACCEPTABLE ROW
1789
        BHI  RETESC    ; ELSE RETURN DOING NOTHING
1790
        BRA  NEWCUR    ; GO SET NEW CURSOR IF SO
1791
*
1792 59 davidgb
*************************** DELETE LINE FROM SCREEN
1793 99 davidgb
*
1794
ESCDLL  BSR  CRETN     ; GO COL. ZERO
1795
        LDB  ROWADX
1796
        CMPB #NUMLIN-1
1797
        BEQ  SCROL3
1798
        BRA  SCROL1    ; AND DELETE THIS LINE
1799
*
1800 59 davidgb
*************************** INSERT LINE INTO SCREEN
1801
*
1802 99 davidgb
ESCINL  BSR  CRETN     ; GO TO COL. ZERO
1803
        LDB  ROWADX
1804
        CMPB #NUMLIN-1
1805
        BEQ  ESCCLL
1806
*
1807 59 davidgb
** SCROLL SCREEN DOWN FROM CURSOR
1808
*
1809 99 davidgb
        LDX  #SCREEN+SCNLEN-LINLEN
1810
ESCIN0  LDA  ,-X
1811
        STA  LINLEN,X
1812
        LDA  SCNLEN,X
1813
        STA  SCNLEN+LINLEN,X
1814
        CMPX CURSOR
1815
        BNE  ESCIN0
1816
*
1817 59 davidgb
****************** CLEAR FROM CURSOR TO END OF LINE
1818 99 davidgb
*
1819
ESCCLL  LDA  COLADX    ; GET CURRENT COLUMN
1820
        LDX  CURSOR    ; GET CURSOR
1821
        LDB  #$20      ; AND CLEAR CHAR
1822
ESCLL1  STB  SCNLEN,X  ; CLEAR ATTRIBUTE
1823
        STB  ,X+       ; CLEAR TEXT
1824 59 davidgb
        INCA
1825 99 davidgb
        CMPA #LINLEN   ; UNTIL END OF LINE
1826
        BNE  ESCLL1
1827
        CLR  ESCFLG
1828 59 davidgb
        RTS
1829 99 davidgb
*
1830 59 davidgb
*********************************** CARRIAGE RETURN
1831 99 davidgb
*
1832
CRETN   CLRA           ; SET COLUMN ZERO
1833
POSCOL  LDB  ROWADX    ; GET CURRENT ROW
1834
*
1835 59 davidgb
*********** GENERATE NEW CURSOR POSITION AND RETURN
1836 99 davidgb
*
1837
NEWCUR  STD  COLADX    ; SAVE NEW ROW AND COLUMN
1838
        LDA  #LINLEN   ; ELSE ADD A LINE
1839
        MUL            ; LINLEN * ROWADX
1840
        ADDB COLADX
1841
        ADCA #0
1842
        ADDD #SCREEN   ; ADD SCREEN BASE.
1843
        STD  CURSOR    ; SAVE NEW CURSOR
1844
        TFR  D,X       ; GET CURSOR IN X
1845
        RTS            ; AND RETURN
1846
*
1847 59 davidgb
********************* UPDATE CURRENT COLUMN AND ROW
1848 99 davidgb
*
1849
NEWCOL  LDD  COLADX    ; GET ROW AND COLUMN
1850
        INCA           ; BUMP COLUMN
1851
        CMPA #LINLEN   ; ROLL?
1852
        BNE  NEWCUR    ; BRANCH IF NOT
1853
        CLRA           ; ELSE RESET TO ZERO
1854
        INCB           ; AND BUMP ROW
1855
        CMPB #NUMLIN
1856
        BNE  NEWCUR
1857
        DECB           ; BOTTOM ROW
1858
        BSR  NEWCUR
1859
*
1860 59 davidgb
********************************* SCROLL THE SCREEN
1861 99 davidgb
*
1862
SCROLL  LDX  #SCREEN   ; POINT TO SCREEN
1863
SCROL1  LDA  SCNLEN+LINLEN,X
1864
        STA  SCNLEN,X
1865
        LDA  LINLEN,X  ; MOVE TWO BYTES
1866
        STA  ,X+       ; UP ONE LINE
1867
        CMPX #SCREEN+SCNLEN-LINLEN
1868
        BNE  SCROL1    ; LOOP UNTIL DONE
1869
        BRA  SCROL3
1870
*
1871 59 davidgb
**************** CLEAR FROM CURSOR TO END OF SCREEN
1872 99 davidgb
*
1873
ESCCLS  LDX   CURSOR   ; GET CURSOR
1874
SCROL3  LDA   #$20     ; GET A SPACE
1875
SCROL2  STA   SCNLEN,X ; CLEAR ATTRIBUTES
1876
        STA   ,X+      ; AND TEXT
1877 59 davidgb
        CMPX  #SCREEN+SCNLEN
1878 99 davidgb
        BNE   SCROL2   ; UNTIL DONE
1879 59 davidgb
        CLR   ESCFLG
1880
        RTS
1881
        ENDIF DG640OPT
1882
*
1883
        IFD PRTOPT
1884
*************************************
1885
*
1886
** PRINTER DRIVER ROUTINES
1887
*
1888
*************************************
1889
*
1890
** PINIZ - INITIATE PRINTER PORT
1891
*
1892
PINIZ   PSHS B
1893 99 davidgb
        LDD #DIRMSK*256+$04 ; ACCA=DIRMSK ACCB=$04
1894
        STD PADATA     ; SET DDR AND SELECT DATA
1895 59 davidgb
*
1896
** RESET PRINTER
1897
*
1898 99 davidgb
        LDB  #PRESET
1899
        STB  PADATA
1900
RESTLP  INCB           ; DELAY FOR RESET
1901
        BNE  RESTLP
1902
        STA  PADATA    ; ACCA=DIRMSK
1903
*
1904 59 davidgb
** INITALIZE PORT B (DATA PORT)
1905
*
1906 99 davidgb
        LDA  #$2A
1907
        STA  PBCTRL
1908
        LDD  #$FF2E    ; ACCA=$FF ACCB =%00101110
1909
        STD  PBDATA    ; PBDREG   PBCTRL
1910
*
1911 59 davidgb
** SELECT 66 LINES/PAGE
1912 99 davidgb
*
1913
        LDA  #$1B
1914
        BSR  POUTCH
1915
        LDA  #'C
1916
        BSR  POUTCH
1917
        LDA  #66
1918 59 davidgb
        PULS B
1919
*************************************
1920
*
1921
** OUTPUT A CHARACTER TO THE PRINTER
1922
*
1923
*************************************
1924
POUTCH  PSHS B
1925 99 davidgb
        LDB  PBDATA    ; CLEAR INTERRUPT BIT
1926 59 davidgb
*
1927
** WAIT TILL NOT BUSY
1928 99 davidgb
*
1929
BUSYLP  LDB  PADATA
1930 59 davidgb
        BITB #PERROR
1931 99 davidgb
        BEQ  PEXIT
1932 59 davidgb
        TSTB
1933 99 davidgb
        BMI  BUSYLP
1934 59 davidgb
*
1935
** NOW OUTPUT CHARACTER
1936 99 davidgb
*
1937
        STA  PBDATA
1938 59 davidgb
PEXIT   PULS B,PC
1939
*************************************
1940
*
1941
** PCHK TEST IFD PRINTER READY
1942
*
1943
*************************************
1944 99 davidgb
PCHK    TST  PBCTRL    ; TEST STATE OF CRB7
1945
        RTS            ; SET ON ACKNOWLEDGE
1946 59 davidgb
        ENDIF PRTOPT
1947
*************************************
1948
*
1949 99 davidgb
* MONITOR KEYBOARD COMMAND JUMP TABLE
1950
*
1951 59 davidgb
*************************************
1952 99 davidgb
*
1953
JMPTAB  EQU *
1954
        FCB 1 " ^A "
1955
        FDB ALTRA
1956
        FCB 2 " ^B "
1957
        FDB ALTRB
1958
        FCB 3 " ^C "
1959
        FDB ALTRCC
1960
        FCB 4 " ^D "
1961
        FDB ALTRDP
1962
        FCB $10 " ^P "
1963
        FDB ALTRPC
1964
        FCB $15 " ^U "
1965
        FDB ALTRU
1966
        FCB $18 " ^X "
1967
        FDB ALTRX
1968
        FCB $19 " ^Y "
1969
        FDB ALTRY
1970
*
1971
        FCC 'B'
1972
        FDB BRKPNT
1973
        FCC 'E'
1974
        FDB MEMDUMP
1975
        FCC 'G'
1976
        FDB GO
1977
        FCC 'L'
1978
        FDB LOAD
1979
        FCC 'P'
1980
        FDB PUNCH
1981
        FCC 'M'
1982
        FDB MEMCHG
1983
        FCC 'R'
1984
        FDB REGSTR
1985
        FCC 'S'
1986
        FDB DISSTK
1987
        FCC 'X'
1988
        FDB XBKPNT
1989
        IFD MFDCOPT
1990
        FCC 'D'        ; *** SWTPC USES 'U' FOR MINIBOOT
1991
        FDB MINBOOT
1992
        ENDIF MFDCOPT
1993
        IFD CF8OPT
1994
        FCC 'D'        ; *** FPGA 8 BIT USES 'D' FOR CFBOOT
1995
        FDB CFBOOT
1996
        ENDIF CF8OPT
1997
        IFD IDEOPT
1998
        FCC 'D'        ; *** XESS FPGA 16 BIT IDE USES 'D' FOR IDEBOOT
1999
        FDB IDEBOOT
2000
        ENDIF IDEOPT
2001
        IFD DMAFOPT
2002
        FCC 'U'        ; *** SWTPC USES 'D' FOR DMAF2 BOOT
2003
        FDB DBOOT
2004
        ENDIF DMAFOPT
2005
        IFD EXTOPT
2006
        FCC 'U'        ; *** IF FPGA, 'U' IS FOR USER
2007
        FDB USRCMD
2008
        ENDIF EXTOPT
2009
        IFD RTCOPT
2010
        FCC 'T'
2011
        FDB TIMSET
2012
        ENDIF RTCOPT
2013
        IFD TRAOPT
2014
        FCC "T"
2015
        FDB TRACE
2016
        ENDIF TRAOPT
2017
*
2018
TABEND  EQU *
2019
*
2020
* ** 6809 VECTOR ADDRESSES **
2021
*
2022
* FOLLOWING ARE THE ADDRESSES OF THE VECTOR ROUTINES
2023
* FOR THE 6809 PROCESSOR. DURING INITIALIZATION THEY
2024
* ARE RELOCATED TO RAM FROM $DFC0 TO $DFCF. THEY ARE
2025
* RELOCATED TO RAM SO THAT THE USER MAY REVECTOR TO
2026
* HIS OWN ROUTINES IF HE SO DESIRES.
2027
*
2028
*
2029
RAMVEC  FDB SWIE       ; USER-V
2030
        FDB RTI        ; SWI3-V
2031
        FDB RTI        ; SWI2-V
2032
        FDB RTI        ; FIRQ-V
2033
        FDB RTI        ; IRQ-V
2034
        FDB SWIE       ; SWI-V
2035
        FDB $FFFF      ; SVC-VO
2036
        FDB $FFFF      ; SVC-VL
2037
*
2038
* PRINTABLE MESSAGE STRINGS
2039
*
2040
MSG1    FCB  $D,$A,$0,$0,$0 * 0, CR/LF, 0
2041
        FCC  'SYS09BUG 1.6 FOR '
2042
        IFD  SWTOPT`
2043
        FCC  'SWTPC '
2044
        ENDIF SWTOPT
2045
        IFD  ADSOPT
2046
        FCC  'ADS6809 '
2047
        ENDIF ADSOPT
2048
        IFD  B3SOPT
2049
        FCC  'B3-S2+ '
2050
        ENDIF B3SOPT
2051
        IFD  B5XOPT
2052
        FCC  'B5-X300 '
2053
        ENDIF B5XOPT
2054
        IFD  S3SOPT
2055
        FCC  'S3STARTER '
2056
        ENDIF S3SOPT
2057
        IFD  S3EOPT
2058
        FCC  'S3E '
2059
        ENDIF S3EOPT
2060
        IFD  XESOPT`
2061
        FCC  'XESS '
2062
        ENDIF XESOPT
2063
        FCC ' - '
2064
        FCB 4
2065
MSG2    FCB 'K,$0D,$0A,$00,$00,$00,$04 ; K,,,3 NULS,
2066
MSG3    FCC '>'
2067
        FCB 4
2068
MSG4    FCC 'WHAT?'
2069
        FCB 4
2070
MSG5    FCC ' - '
2071
        FCB 4'
2072
MSG10   FCC '  SP='
2073
        FCB 4
2074
MSG11   FCC '  PC='
2075
        FCB 4
2076
MSG12   FCC '  US='
2077
        FCB 4
2078
MSG13   FCC '  IY='
2079
        FCB 4
2080
MSG14   FCC '  IX='
2081
        FCB 4
2082
MSG15   FCC '  DP='
2083
        FCB 4
2084
MSG16   FCC '  A='
2085
        FCB 4
2086
MSG17   FCC '  B='
2087
        FCB 4
2088
MSG18   FCC '  CC: '
2089
        FCB 4
2090
MSG19   FCC 'EFHINZVC'
2091
MSG20   FCC 'S1'
2092
        FCB 4
2093 59 davidgb
        IFD DATOPT
2094
*
2095 99 davidgb
* POWER UP/ RESET/ NMI ENTRY POINT
2096
*
2097
        ORG $FF00
2098
*
2099
*
2100
START   LDX  #IC11    ; POINT TO DAT RAM IC11
2101
        LDA  #$0F     ; GET COMPLIMENT OF ZERO
2102
*
2103
*
2104
* INITIALIZE DAT RAM --- LOADS $F-$0 IN LOCATIONS $0-$F
2105
* OF DAT RAM, THUS STORING COMPLEMENT OF MSB OF ADDRESS
2106
* IN THE DAT RAM. THE COMPLEMENT IS REQUIRED BECAUSE THE
2107
* OUTPUT OF IC11, A 74S189, IS THE INVERSE OF THE DATA
2108
* STORED IN IT.
2109
*
2110
*
2111
DATLP   STA  ,X+       ; STORE & POINT TO NEXT RAM LOCATION
2112
        DECA           ; GET COMP. VALUE FOR NEXT LOCATION
2113
        BNE  DATLP     ; ALL 16 LOCATIONS INITIALIZED ?
2114
*
2115
* NOTE: IX NOW CONTAINS $0000, DAT RAM IS NO LONGER
2116
*       ADDRESSED, AND LOGICAL ADDRESSES NOW EQUAL
2117
*       PHYSICAL ADDRESSES.
2118
*
2119
        LDA  #$F0
2120
        STA  ,X        ; STORE $F0 AT $FFFF
2121
        LDX  #$D0A0    ; ASSUME RAM TO BE AT $D000-$DFFF
2122
        LDY  #TSTPAT   ; LOAD TEST DATA PATTERN INTO "Y"
2123
TSTRAM  LDU  ,X        ; SAVE DATA FROM TEST LOCATION
2124
        STY  ,X        ; STORE TEST PATTERN AT $D0A0
2125
        CMPY ,X        ; IS THERE RAM AT THIS LOCATION ?
2126
        BEQ  CNVADR    ; IF MATCH THERE'S RAM, SO SKIP
2127
        LEAX -$1000,X  ; ELSE POINT 4K LOWER
2128
        CMPX #$F0A0    ; DECREMENTED PAST ZER0 YET ?
2129
        BNE  TSTRAM    ; IF NOT CONTINUE TESTING FOR RAM
2130
        BRA  START     ; ELSE START ALL OVER AGAIN
2131
*
2132
*
2133
* THE FOLLOWING CODE STORES THE COMPLEMENT OF
2134
* THE MS CHARACTER OF THE FOUR CHARACTER HEX
2135
* ADDRESS OF THE FIRST 4K BLOCK OF RAM LOCATED
2136
* BY THE ROUTINE "TSTRAM" INTO THE DAT RAM. IT
2137
* IS STORED IN RAM IN THE LOCATION THAT IS
2138
* ADDRESSED WHEN THE PROCESSOR ADDRESS IS $D---,
2139
* THUS IF THE FIRST 4K BLOCK OF RAM IS FOUND
2140
* WHEN TESTING LOCATION $70A0, MEANING THERE
2141
* IS NO RAM PHYSICALLY ADDRESSED IN THE RANGE
2142
* $8000-$DFFF, THEN THE COMPLEMENT OF THE
2143
* "7" IN THE $70A0 WILL BE STORED IN
2144
* THE DAT RAM. THUS WHEN THE PROCESSOR OUTPUTS
2145
* AN ADDRESS OF $D---, THE DAT RAM WILL RESPOND
2146
* BY RECOMPLEMENTING THE "7" AND OUTPUTTING THE
2147
* 7 ONTO THE A12-A15 ADDRESS LINES. THUS THE
2148
* RAM THAT IS PHYSICALLY ADDRESSED AT $7---
2149
* WILL RESPOND AND APPEAR TO THE 6809 THAT IT
2150
* IS AT $D--- SINCE THAT IS THE ADDRESS THE
2151
* 6809 WILL BE OUTPUTING WHEN THAT 4K BLOCK
2152
* OF RAM RESPONDS.
2153
*
2154
*
2155
CNVADR  STU  ,X        ; RESTORE DATA AT TEST LOCATION
2156
        TFR  X,D       ; PUT ADDR. OF PRESENT 4K BLOCK IN D
2157
        COMA           ; COMPLEMENT MSB OF THAT ADDRESS
2158
        LSRA           ; PUT MS 4 BITS OF ADDRESS IN
2159
        LSRA           ; LOCATION D0-D3 TO ALLOW STORING
2160
        LSRA           ; IT IN THE DYNAMIC ADDRESS
2161
        LSRA           ; TRANSLATION RAM.
2162
        STA  $FFFD     ; STORE XLATION FACTOR IN DAT "D"
2163
*
2164
        LDS  #STACK    ; INITIALIZE STACK POINTER
2165
*
2166
*
2167
* THE FOLLOWING CHECKS TO FIND THE REAL PHYSICAL ADDRESSES
2168
* OF ALL 4K BLKS OF RAM IN THE SYSTEM. WHEN EACH 4K BLK
2169
* OF RAM IS LOCATED, THE COMPLEMENT OF IT'S REAL ADDRESS
2170
* IS THEN STORED IN A "LOGICAL" TO "REAL" ADDRESS XLATION
2171
* TABLE THAT IS BUILT FROM $DFD0 TO $DFDF. FOR EXAMPLE IF
2172
* THE SYSTEM HAS RAM THAT IS PHYSICALLY LOCATED (WIRED TO
2173
* RESPOND) AT THE HEX LOCATIONS $0--- THRU $F---....
2174
*
2175
*  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
2176
* 4K 4K 4K 4K 4K 4K 4K 4K -- 4K 4K 4K 4K -- -- --
2177
*
2178
* ....FOR A TOTAL OF 48K OF RAM, THEN THE TRANSLATION TABLE
2179
* CREATED FROM $DFD0 TO $DFDF WILL CONSIST OF THE FOLLOWING....
2180
*
2181
*  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
2182
* 0F 0E 0D 0C 0B 0A 09 08 06 05 00 00 04 03 F1 F0
2183
*
2184
*
2185
* HERE WE SEE THE LOGICAL ADDRESSES OF MEMORY FROM $0000-$7FFF
2186
* HAVE NOT BEEN SELECTED FOR RELOCATION SO THAT THEIR PHYSICAL
2187
* ADDRESS WILL = THEIR LOGICAL ADDRESS; HOWEVER, THE 4K BLOCK
2188
* PHYSICALLY AT $9000 WILL HAVE ITS ADDRESS TRANSLATED SO THAT
2189
* IT WILL LOGICALLY RESPOND AT $8000. LIKEWISE $A,$B, AND $C000
2190
* WILL BE TRANSLATED TO RESPOND TO $9000,$C000, AND $D000
2191
* RESPECTIVELY. THE USER SYSTEM WILL LOGICALLY APPEAR TO HAVE
2192
* MEMORY ADDRESSED AS FOLLOWS....
2193
*
2194
*  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
2195
* 4K 4K 4K 4K 4K 4K 4K 4K 4K 4K -- -- 4K 4K -- --
2196
*
2197
*
2198
        LDY  #LRARAM   ; POINT TO LOGICAL/REAL ADDR. TABLE
2199
        STA  13,Y      ; STORE $D--- XLATION FACTOR AT $DFDD
2200
        CLR  14,Y      ; CLEAR $DFDE
2201
        LDA  #$F0      ; DESTINED FOR IC8 AN MEM EXPANSION ?
2202
        STA  15,Y      ; STORE AT $DFDF
2203
        LDA  #$0C      ; PRESET NUMBER OF BYTES TO CLEAR
2204
CLRLRT  CLR  A,Y       ; CLEAR $DFDC THRU $DFD0
2205
        DECA           ; SUB. 1 FROM BYTES LEFT TO CLEAR
2206
        BPL  CLRLRT    ; CONTINUE IF NOT DONE CLEARING
2207
FNDRAM  LEAX -$1000,X  ; POINT TO NEXT LOWER 4K OF RAM
2208
        CMPX #$F0A0    ; TEST FOR DECREMENT PAST ZERO
2209
        BEQ  FINTAB    ; SKIP IF FINISHED
2210
        LDU  ,X        ; SAVE DATA AT CURRENT TEST LOCATION
2211
        LDY  #TSTPAT   ; LOAD TEST DATA PATTERN INTO Y REG.
2212
        STY  ,X        ; STORE TEST PATT. INTO RAM TEST LOC.
2213
        CMPY ,X        ; VERIFY RAM AT TEST LOCATION
2214
        BNE  FNDRAM    ; IF NO RAM GO LOOK 4K LOWER
2215
        STU  ,X        ; ELSE RESTORE DATA TO TEST LOCATION
2216
        LDY  #LRARAM   ; POINT TO LOGICAL/REAL ADDR. TABLE
2217
        TFR  X,D       ; PUT ADDR. OF PRESENT 4K BLOCK IN D
2218
        LSRA           ; PUT MS 4 BITS OF ADDR. IN LOC. D0-D3
2219
        LSRA           ; TO ALLOW STORING IT IN THE DAT RAM.
2220
        LSRA
2221
        LSRA
2222
        TFR  A,B       ; SAVE OFFSET INTO LRARAM TABLE
2223
        EORA #$0F      ; INVERT MSB OF ADDR. OF CURRENT 4K BLK
2224
        STA  B,Y       ; SAVE TRANSLATION FACTOR IN LRARAM TABLE
2225
        BRA  FNDRAM    ; GO TRANSLATE ADDR. OF NEXT 4K BLK
2226
FINTAB  LDA  #$F1      ; DESTINED FOR IC8 AND MEM EXPANSION ?
2227
        LDY  #LRARAM   ; POINT TO LRARAM TABLE
2228
        STA  14,Y      ; STORE $F1 AT $DFCE
2229
*
2230
* THE FOLLOWING CHECKS TO SEE IF THERE IS A 4K BLK OF
2231
* RAM LOCATED AT $C000-$CFFF. IF NONE THERE IT LOCATES
2232
* THE NEXT LOWER 4K BLK AN XLATES ITS ADDR SO IT
2233
* LOGICALLY RESPONDS TO THE ADDRESS $C---.
2234
*
2235
*
2236
        LDA  #$0C      ; PRESET NUMBER HEX "C"
2237
FINDC   LDB  A,Y       ; GET ENTRY FROM LRARAM TABLE
2238
        BNE  FOUNDC    ; BRANCH IF RAM THIS PHYSICAL ADDR.
2239
        DECA           ; ELSE POINT 4K LOWER
2240
        BPL  FINDC     ; GO TRY AGAIN
2241
        BRA  XFERTF
2242
FOUNDC  CLR  A,Y       ; CLR XLATION FACTOR OF 4K BLOCK FOUND
2243
        STB  $0C,Y     ; GIVE IT XLATION FACTOR MOVING IT TO $C---
2244
*
2245
* THE FOLLOWING CODE ADJUSTS THE TRANSLATION
2246
* FACTORS SUCH THAT ALL REMAINING RAM WILL
2247
* RESPOND TO A CONTIGUOUS BLOCK OF LOGICAL
2248
* ADDRESSES FROM $0000 AND UP....
2249
*
2250
        CLRA           ; START AT ZERO
2251
        TFR  Y,X       ; START POINTER "X" START OF "LRARAM" TABLE.
2252
COMPRS  LDB  A,Y       ; GET ENTRY FROM "LRARAM" TABLE
2253
        BEQ  PNTNXT    ; IF IT'S ZER0 SKIP
2254
        CLR  A,Y       ; ELSE ERASE FROM TABLE
2255
        STB  ,X+       ; AND ENTER ABOVE LAST ENTRY- BUMP
2256
PNTNXT  INCA           ; GET OFFSET TO NEXT ENTRY
2257
        CMPA #$0C      ; LAST ENTRY YET ?
2258
        BLT  COMPRS
2259
*
2260
* THE FOLLOWING CODE TRANSFER THE TRANSLATION
2261
* FACTORS FROM THE LRARAM TABLE TO IC11 ON
2262
* THE MP-09 CPU CARD.
2263
*
2264
XFERTF  LDX  #IC11     ; POINT TO DAT RAM IC11
2265
        LDB  #$10      ; GET NO. OF BYTES TO MOVE
2266
FETCH   LDA  ,Y+       ; GET BYTE AND POINT TO NEXT
2267
        STA  ,X+       ; POKE XLATION FACTOR IN IC11
2268
        DECB           ; SUB 1 FROM BYTES TO MOVE
2269
        BNE  FETCH     ; CONTINUE UNTIL 16 MOVED
2270
*
2271 59 davidgb
        ELSE
2272
LRA     RTS
2273 99 davidgb
START   LDS  #STACK    ; INITIALIZE STACK POINTER
2274 59 davidgb
        CLRB
2275
        ENDIF DATOPT
2276
*
2277 99 davidgb
        COMB           ; SET "B" NON-ZERO
2278
        STB  ECHO      ; TURN ON ECHO FLAG
2279
        LBRA MONITOR   ; INITIALIZATION IS COMPLETE
2280
*
2281 59 davidgb
** INTERRUPT JUMP VECTORS
2282
*
2283 99 davidgb
V1      JMP  [STACK]
2284
V2      JMP  [SWI2]
2285
V3      JMP  [FIRQ]
2286
V4      JMP  [IRQ]
2287
V5      JMP  [SWI]
2288
*
2289
* SWI3 ENTRY POINT
2290
*
2291
SWI3E   TFR  S,U
2292
        LDX  10,U      *$FFC8
2293
        LDB  ,X+
2294
        STX  10,U
2295
        CLRA
2296
        ASLB
2297
        ROLA
2298
        LDX  SVCVO
2299
        CMPX #$FFFF
2300
        BEQ  SWI3Z
2301
        LEAX D,X
2302
        CMPX SVCVL
2303
        BHI  SWI3Z
2304
        PSHS X
2305
        LDD  ,U
2306
        LDX  4,U
2307
        JMP  [,S++]
2308
SWI3Z   PULU A,B,X,CC,DP
2309
        LDU  2,U
2310
        JMP  [SWI3]
2311
*
2312
* 6809 VECTORS
2313
*
2314
        ORG $FFF0
2315
        FDB V1    USER-V
2316
        FDB SWI3E SWI3-V
2317
        FDB V2    SWI2-V
2318
        FDB V3    FIRQ-V
2319
        FDB V4    IRQ-V
2320
        FDB V5    SWI-V
2321
        FDB V1    NMI-V
2322
        FDB START RESTART-V
2323
        END START

powered by: WebSVN 2.1.0

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