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

Subversion Repositories System09

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

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

powered by: WebSVN 2.1.0

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