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

Subversion Repositories System09

[/] [System09/] [branches/] [mkfiles_rev1/] [src/] [sys09bug/] [sys09bug.asm] - Blame information for rev 179

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

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

powered by: WebSVN 2.1.0

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