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

Subversion Repositories System09

[/] [System09/] [trunk/] [src/] [sys09bug/] [sys09bug.asm] - Diff between revs 66 and 99

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 66 Rev 99
Line 50... Line 50...
* BY:      JOHN KENT
* BY:      JOHN KENT
* DATE:    3RD FEB 2008
* DATE:    3RD FEB 2008
* ADDED:   CONDITIONALS FOR XESS BOARD WITH IDE
* ADDED:   CONDITIONALS FOR XESS BOARD WITH IDE
*          SEPERATE CONDITIONAL FOR S3 STARTER AND B5-X300
*          SEPERATE CONDITIONAL FOR S3 STARTER AND B5-X300
*          16 BIT IDE DISK BOOT STRAP ROUTINE
*          16 BIT IDE DISK BOOT STRAP ROUTINE
 
*
 
* Modified to SYS09BUG VER 1.5
 
* FOR:     SYSTEM09 FPGA SYSTEM
 
* BY:      JOHN KENT
 
* DATE:    7TH SEP 2008
 
* ADDED:   ADDED "B3-S2+" STRING
 
*
 
* Modified to SYS09BUG VER 1.6
 
* FOR:     SYSTEM09 FPGA SYSTEM
 
* BY:      JOHN KENT
 
* DATE:    2ND DEC 2008
 
* ADDED:   ADDED HARDWARE FLOW CONTROL
 
*
* CHANGED: SEPARARTED OPTIONS EQUATES AND BODY INTO SEPARATE FILES
* CHANGED: SEPARARTED OPTIONS EQUATES AND BODY INTO SEPARATE FILES
*
*
*       *** COMMANDS ***
*       *** COMMANDS ***
*
*
* CONTROL A   = ALTER THE "A" ACCUMULATOR
* CONTROL A   = ALTER THE "A" ACCUMULATOR
Line 83... Line 96...
***************************************************
***************************************************
*   SYS09BUG VARIABLE SPACE
*   SYS09BUG VARIABLE SPACE
***************************************************
***************************************************
*
*
        ORG   MONRAM
        ORG   MONRAM
STACK   EQU   *  TOP OF INTERNAL STACK
STACK   EQU   *         ; TOP OF INTERNAL STACK
NMI     RMB   2  USER NMI VECTOR
NMI     RMB   2         ; USER NMI VECTOR
SWI3    RMB   2  SOFTWARE INTERRUPT VECTOR #3
SWI3    RMB   2         ; SOFTWARE INTERRUPT VECTOR #3
SWI2    RMB   2  SOFTWARE INTERRUPT VECTOR #2
SWI2    RMB   2         ; SOFTWARE INTERRUPT VECTOR #2
FIRQ    RMB   2  FAST INTERRUPT VECTOR
FIRQ    RMB   2         ; FAST INTERRUPT VECTOR
IRQ     RMB   2  INTERRUPT VECTOR
IRQ     RMB   2         ; INTERRUPT VECTOR
SWI     RMB   2  SOFTWARE INTERRUPT VECTOR
SWI     RMB   2         ; SOFTWARE INTERRUPT VECTOR
SVCVO   RMB   2  SUPERVISOR CALL VECTOR ORGIN
SVCVO   RMB   2         ; SUPERVISOR CALL VECTOR ORGIN
SVCVL   RMB   2  SUPERVISOR CALL VECTOR LIMIT
SVCVL   RMB   2         ; SUPERVISOR CALL VECTOR LIMIT
        IFD DATOPT
        IFD DATOPT
LRARAM  RMB   16 LRA ADDRESSES
LRARAM  RMB  16         ; LRA ADDRESSES
        ENDIF DATOPT
        ENDIF DATOPT
CPORT   RMB   2  RE-VECTORABLE CONTROL PORT
CPORT   RMB   2         ; RE-VECTORABLE CONTROL PORT
ECHO    RMB   1  ECHO FLAG
ECHO    RMB   1         ; ECHO FLAG
BPTBL   RMB   24 BREAKPOINT TABLE BASE ADDR
BPTBL   RMB  24         ; BREAKPOINT TABLE BASE ADDR
        IFD  TRAOPT
        IFD  TRAOPT
NMISAV  RMB 2 NMI Jump Vector Backup
NMISAV  RMB   2         ; NMI Jump Vector Backup
TRACNT  RMB 2 Trace Count
TRACNT  RMB   2         ; Trace Count
        ENDIF TRAOPT
        ENDIF TRAOPT
        IFD VDUOPT
        IFD VDUOPT
*
*
**************************************************
**************************************************
*   VDU8 DISPLAY DRIVER VARIABLES                                    *
*   VDU8 DISPLAY DRIVER VARIABLES                                    *
**************************************************
**************************************************
*
*
**** ALWAYS KEEP COLADX AND ROWADX TOGETHER ******
**** ALWAYS KEEP COLADX AND ROWADX TOGETHER ******
COLADX  RMB   1         CURSOR COLUMN
COLADX  RMB   1         ; CURSOR COLUMN
ROWADX  RMB   1         CURSOR ROW
ROWADX  RMB   1         ; CURSOR ROW
**************************************************
**************************************************
*
*
NEWROW  RMB   1         NEW ROW TEMP FOR ESCAPE
NEWROW  RMB   1         ; NEW ROW TEMP FOR ESCAPE
ESCFLG  RMB   1         ESCAPE SEQUENCE ACTIVE
ESCFLG  RMB   1         ; ESCAPE SEQUENCE ACTIVE
        ENDIF VDUOPT
        ENDIF VDUOPT
       IFD DG640OPT
       IFD DG640OPT
*
*
***************************************************
***************************************************
*   DG640 MEMORY MAPPED DISPLAY DRIVER VARIABLES  *
*   DG640 MEMORY MAPPED DISPLAY DRIVER VARIABLES  *
***************************************************
***************************************************
*
*
***** ALWAYS KEEP THESE TWO BYTES TOGETHER *****
***** ALWAYS KEEP THESE TWO BYTES TOGETHER *****
COLADX  RMB   1           CURSOR COLUMN
COLADX  RMB   1        ; CURSOR COLUMN
ROWADX  RMB   1           CURSOR ROW
ROWADX  RMB   1        ; CURSOR ROW
*************************************************
*************************************************
CURSOR  RMB   2           ABSOLUTE SCREEN ADDRESS
CURSOR  RMB   2        ; ABSOLUTE SCREEN ADDRESS
NEWROW  RMB   1           NEW ROW TEMP FOR ESCAPE
NEWROW  RMB   1        ; NEW ROW TEMP FOR ESCAPE
ESCFLG  RMB   1           ESCAPE SEQUENCE ACTIVE
ESCFLG  RMB   1        ; ESCAPE SEQUENCE ACTIVE
        ENDIF DG640OPT
        ENDIF DG640OPT
*
*
*
*
***************************************************
***************************************************
*   START OF ROM                                  *
*   START OF ROM                                  *
Line 149... Line 162...
        FDB   PCRLF
        FDB   PCRLF
        FDB   PSTRNG
        FDB   PSTRNG
        FDB   LRA
        FDB   LRA
*
*
        IFD ADSOPT
        IFD ADSOPT
        FDB PCHK  CHECK FOR PRINTER INPUT
        FDB   PCHK     ; CHECK FOR PRINTER INPUT
        FDB PINIZ INITIATE PRINTER
        FDB   PINIZ    ; INITIATE PRINTER
        FDB POUTCH OUTPUT CH. TO PRINTER
        FDB   POUTCH   ; OUTPUT CH. TO PRINTER
        FDB VINIZ
        FDB VINIZ
        FDB VOUTCH
        FDB VOUTCH
        FDB ACINIZ
        FDB ACINIZ
        FDB AOUTCH
        FDB AOUTCH
        ENDIF ADSOPT
        ENDIF ADSOPT
Line 163... Line 176...
* MONITOR
* MONITOR
*
*
* VECTOR ADDRESS STRING IS.....
* VECTOR ADDRESS STRING IS.....
* $F8A1-$F8A1-$F8A1-$F8A1-$F8A1-$FAB0-$FFFF-$FFFF
* $F8A1-$F8A1-$F8A1-$F8A1-$F8A1-$FAB0-$FFFF-$FFFF
*
*
MONITOR LDX   #RAMVEC POINT TO VECTOR ADDR. STRING
MONITOR LDX   #RAMVEC  ; POINT TO VECTOR ADDR. STRING
        LDY   #STACK  POINT TO RAM VECTOR LOCATION
        LDY   #STACK   ; POINT TO RAM VECTOR LOCATION
        LDB   #$10    BYTES TO MOVE = 16
        LDB   #$10     ; BYTES TO MOVE = 16
LOOPA   LDA   ,X+     GET VECTOR BYTE
LOOPA   LDA   ,X+      ; GET VECTOR BYTE
        STA   ,Y+     PUT VECTORS IN RAM / $DFC0-$DFCF
        STA   ,Y+      ; PUT VECTORS IN RAM / $DFC0-$DFCF
        DECB          SUBTRACT 1 FROM NUMBER OF BYTES TO MOVE
        DECB           ; SUBTRACT 1 FROM NUMBER OF BYTES TO MOVE
        BNE   LOOPA   CONTINUE UNTIL ALL VECTORS MOVED
        BNE   LOOPA    ; CONTINUE UNTIL ALL VECTORS MOVED
*
*
* CONTENTS     FROM         TO      FUNCTION
* CONTENTS     FROM         TO      FUNCTION
*  $F8A1       $FE40      $DFC0     USER-V
*  $F8A1       $FE40      $DFC0     USER-V
*  $F8A1       $FE42      $DFC2     SWI3-V
*  $F8A1       $FE42      $DFC2     SWI3-V
*  $F8A1       $FE44      $DFC4     SWI2-V
*  $F8A1       $FE44      $DFC4     SWI2-V
Line 182... Line 195...
*  $FAB0       $FE4A      $DFCA     SWI-V
*  $FAB0       $FE4A      $DFCA     SWI-V
*  $FFFF       $FE4C      $DFCC     SVC-VO
*  $FFFF       $FE4C      $DFCC     SVC-VO
*  $FFFF       $FE4E      $DFCE     SVC-VL
*  $FFFF       $FE4E      $DFCE     SVC-VL
*
*
        LDX  #ACIAS
        LDX  #ACIAS
        STX  CPORT    STORE ADDR. IN RAM
        STX   CPORT    ; STORE ADDR. IN RAM
        LBSR XBKPNT   CLEAR OUTSTANDING BREAKPOINTS
        LBSR  XBKPNT   ; CLEAR OUTSTANDING BREAKPOINTS
        LDB  #12      CLEAR 12 BYTES ON STACK
        LDB   #12      ; CLEAR 12 BYTES ON STACK
CLRSTK  CLR  ,-S
CLRSTK  CLR  ,-S
        DECB
        DECB
        BNE  CLRSTK
        BNE  CLRSTK
        LEAX MONITOR,PCR  SET PC TO SBUG-E ENTRY
        LEAX  MONITOR,PCR  ; SET PC TO SBUG-E ENTRY
        STX  10,S    ON STACK
        STX   10,S    ; ON STACK
        LDA  #$D0    PRESET CONDITION CODES ON STACK
        LDA   #$D0    ; PRESET CONDITION CODES ON STACK
        STA  ,S
        STA  ,S
        TFR  S,U
        TFR  S,U
        LBSR IOINIZ  INITIALIZE CONTROL PORT
        LBSR  IOINIZ  ; INITIALIZE CONTROL PORT
        LDX  #MSG1   POINT TO MONITOR MESSAGE
        LDX   #MSG1   ; POINT TO MONITOR MESSAGE
        LBSR PDATA   PRINT MSG
        LBSR  PDATA   ; PRINT MSG
*
*
        IFD DATOPT
        IFD DATOPT
        LDX  #LRARAM POINT TO LRA RAM STORAGE AREA
        LDX   #LRARAM ; POINT TO LRA RAM STORAGE AREA
        CLRA START   TOTAL AT ZERO
        CLRA  START   ; TOTAL AT ZERO
        LDB  #13     TOTAL UP ALL ACTIVE RAM MEMORY
        LDB   #13     ; TOTAL UP ALL ACTIVE RAM MEMORY
FNDREL  TST  B,X     TEST FOR RAM AT NEXT LOC.
FNDREL  TST   B,X     ; TEST FOR RAM AT NEXT LOC.
        BEQ  RELPAS  IF NO RAM GO TO NEXT LOC.
        BEQ   RELPAS  ; IF NO RAM GO TO NEXT LOC.
        ADDA #4      ELSE ADD 4K TO TOTAL
        ADDA  #4      ; ELSE ADD 4K TO TOTAL
        DAA          ADJ. TOTAL FOR DECIMAL
        DAA           ; ADJ. TOTAL FOR DECIMAL
RELPAS  DECB         SUB. 1 FROM LOCS. TO TEST
RELPAS  DECB          ; SUB. 1 FROM LOCS. TO TEST
        BPL  FNDREL  PRINT TOTAL OF RAM
        BPL   FNDREL  ; PRINT TOTAL OF RAM
        LBSR OUT2H   OUTPUT HEX BYTE AS ASCII
        LBSR  OUT2H   ; OUTPUT HEX BYTE AS ASCII
        LDX  #MSG2   POINT TO MSG 'K' CR/LF + 3 NULS
        LDX   #MSG2   ; POINT TO MSG 'K' CR/LF + 3 NULS
        LBSR PDATA   PRINT MSG
        LBSR  PDATA   ; PRINT MSG
        ENDIF DATOPT
        ENDIF DATOPT
*
*
        IFD TRAOPT
        IFD TRAOPT
        LBSR TRAINZ
        LBSR TRAINZ
        ENDIF TRAOPT
        ENDIF TRAOPT
*
*
***** NEXTCMD *****
***** NEXTCMD *****
*
*
NEXTCMD LDX  #MSG3   POINT TO MSG ">"
NEXTCMD LDX  #MSG3   ; POINT TO MSG ">"
        LBSR PSTRNG  PRINT MSG
        LBSR PSTRNG  ; PRINT MSG
        LBSR INCH    GET ONE CHAR. FROM TERMINAL
        LBSR INCH    ; GET ONE CHAR. FROM TERMINAL
        ANDA #$7F    STRIP PARITY FROM CHAR.
        ANDA #$7F    ; STRIP PARITY FROM CHAR.
        CMPA #$0D    IS IT CARRIAGE RETURN ?
        CMPA #$0D    ; IS IT CARRIAGE RETURN ?
        BEQ  NEXTCMD IF CR THEN GET ANOTHER CHAR.
        BEQ  NEXTCMD ; IF CR THEN GET ANOTHER CHAR.
        TFR  A,B     PUT CHAR. IN "B" ACCUM.
        TFR  A,B     ; PUT CHAR. IN "B" ACCUM.
        CMPA #$20    IS IT CONTROL OR DATA CHAR ?
        CMPA #$20    ; IS IT CONTROL OR DATA CHAR ?
        BGE  PRTCMD  IF CMD CHAR IS DATA, PRNT IT
        BGE  PRTCMD  ; IF CMD CHAR IS DATA, PRNT IT
        LDA  #'^     ELSE CNTRL CHAR CMD SO...
        LDA  #'^     ; ELSE CNTRL CHAR CMD SO...
        LBSR OUTCH   PRINT "^"
        LBSR OUTCH   ; PRINT "^"
        TFR  B,A     RECALL CNTRL CMD CHAR
        TFR  B,A     ; RECALL CNTRL CMD CHAR
        ADDA #$40    CONVERT IT TO ASCII LETTER
        ADDA #$40    ; CONVERT IT TO ASCII LETTER
PRTCMD  LBSR OUTCH   PRNT CMD CHAR
PRTCMD  LBSR OUTCH   ; PRNT CMD CHAR
        LBSR OUT1S   PRNT SPACE
        LBSR OUT1S   ; PRNT SPACE
        CMPB #$60
        CMPB #$60
        BLE  NXTCH0
        BLE  NXTCH0
        SUBB #$20
        SUBB #$20
*
*
***** DO TABLE LOOKUP *****
***** DO TABLE LOOKUP *****
*   FOR COMMAND FUNCTIONS
*   FOR COMMAND FUNCTIONS
*
*
NXTCH0  LDX  #JMPTAB POINT TO JUMP TABLE
NXTCH0  LDX  #JMPTAB ; POINT TO JUMP TABLE
NXTCHR  CMPB ,X+     DOES COMMAND MATCH TABLE ENTRY ?
NXTCHR  CMPB ,X+     ; DOES COMMAND MATCH TABLE ENTRY ?
        BEQ  JMPCMD  BRANCH IF MATCH FOUND
        BEQ  JMPCMD  ; BRANCH IF MATCH FOUND
        LEAX 2,X     POINT TO NEXT ENTRY IN TABLE
        LEAX 2,X     ; POINT TO NEXT ENTRY IN TABLE
        CMPX #TABEND REACHED END OF TABLE YET ?
        CMPX #TABEND ; REACHED END OF TABLE YET ?
        BNE  NXTCHR  IF NOT END, CHECK NEXT ENTRY
        BNE  NXTCHR  ; IF NOT END, CHECK NEXT ENTRY
        LDX  #MSG4   POINT TO MSG "WHAT?"
        LDX  #MSG4   ; POINT TO MSG "WHAT?"
        LBSR PDATA   PRINT MSG
        LBSR PDATA   ; PRINT MSG
        BRA  NEXTCMD IF NO MATCH, PRMPT FOR NEW CMD
        BRA  NEXTCMD ; IF NO MATCH, PRMPT FOR NEW CMD
JMPCMD  JSR  [,X]    JUMP TO COMMAND ROUTINE
JMPCMD  JSR  [,X]    ; JUMP TO COMMAND ROUTINE
        BRA  NEXTCMD PROMPT FOR NEW COMMAND
        BRA  NEXTCMD ; PROMPT FOR NEW COMMAND
*
*
* "G" GO OR CONTINUE
* "G" GO OR CONTINUE
*
*
GO      TFR  U,S
GO      TFR  U,S
RTI     RTI
RTI     RTI
*
*
***** "M" MEMORY EXAMINE AND CHANGE *****
***** "M" MEMORY EXAMINE AND CHANGE *****
*
*
MEMCHG  LBSR IN1ADR  INPUT ADDRESS
MEMCHG  LBSR IN1ADR  ; INPUT ADDRESS
        BVS  CHRTN   IF NOT HEX, RETURN
        BVS  CHRTN   ; IF NOT HEX, RETURN
        TFR  X,Y     SAVE ADDR IN "Y"
        TFR  X,Y     ; SAVE ADDR IN "Y"
MEMC2   LDX  #MSG5   POINT TO MSG " - "
MEMC2   LDX  #MSG5   ; POINT TO MSG " - "
        LBSR PSTRNG  PRINT MSG
        LBSR PSTRNG  ; PRINT MSG
        TFR  Y,X     FETCH ADDRESS
        TFR  Y,X     ; FETCH ADDRESS
        LBSR OUT4H   PRINT ADDR IN HEX
        LBSR OUT4H   ; PRINT ADDR IN HEX
        LBSR OUT1S   OUTPUT SPACE
        LBSR OUT1S   ; OUTPUT SPACE
        LDA  ,Y      GET CONTENTS OF CURRENT ADDR.
        LDA  ,Y      ; GET CONTENTS OF CURRENT ADDR.
        LBSR OUT2H   OUTPUT CONTENTS IN ASCII
        LBSR OUT2H   ; OUTPUT CONTENTS IN ASCII
        LBSR OUT1S   OUTPUT SPACE
        LBSR OUT1S   ; OUTPUT SPACE
        LBSR BYTE    LOOP WAITING FOR OPERATOR INPUT
        LBSR BYTE    ; LOOP WAITING FOR OPERATOR INPUT
        BVC  CHANGE  IF VALID HEX GO CHANGE MEM. LOC.
        BVC  CHANGE  ; IF VALID HEX GO CHANGE MEM. LOC.
        CMPA #8      IS IT A BACKSPACE (CNTRL H)?
        CMPA #8      ; IS IT A BACKSPACE (CNTRL H)?
        BEQ  MEMC2   PROMPT OPERATOR AGAIN
        BEQ  MEMC2   ; PROMPT OPERATOR AGAIN
        CMPA #$18    IS IT A CANCEL (CNTRL X)?
        CMPA #$18    ; IS IT A CANCEL (CNTRL X)?
        BEQ  MEMC2   PROMPT OPERATOR AGAIN
        BEQ  MEMC2   ; PROMPT OPERATOR AGAIN
        CMPA #'^     IS IT AN UP ARROW?
        CMPA #'^     ; IS IT AN UP ARROW?
        BEQ  BACK    DISPLAY PREVIOUS BYTE
        BEQ  BACK    ; DISPLAY PREVIOUS BYTE
        CMPA #$D     IS IT A CR?
        CMPA #$D     ; IS IT A CR?
        BNE  FORWRD  DISPLAY NEXT BYTE
        BNE  FORWRD  ; DISPLAY NEXT BYTE
CHRTN   RTS          EXIT ROUTINE
CHRTN   RTS          ; EXIT ROUTINE
*
*
*
*
CHANGE  STA  ,Y      CHANGE BYTE IN MEMORY
CHANGE  STA  ,Y      ; CHANGE BYTE IN MEMORY
        CMPA ,Y      DID MEMORY BYTE CHANGE?
        CMPA ,Y      ; DID MEMORY BYTE CHANGE?
        BEQ  FORWRD  $F972
        BEQ  FORWRD  ; $F972
        LBSR OUT1S   OUTPUT SPACE
        LBSR OUT1S   ; OUTPUT SPACE
        LDA  #'?     LOAD QUESTION MARK
        LDA  #'?     ; LOAD QUESTION MARK
        LBSR OUTCH   PRINT IT
        LBSR OUTCH   ; PRINT IT
FORWRD  LEAY 1,Y     POINT TO NEXT HIGHER MEM LOCATION
FORWRD  LEAY 1,Y     ; POINT TO NEXT HIGHER MEM LOCATION
        BRA  MEMC2   PRINT LOCATION & CONTENTS
        BRA  MEMC2   ; PRINT LOCATION & CONTENTS
BACK    LEAY -1,Y    POINT TO LAST MEM LOCATION
BACK    LEAY -1,Y    ; POINT TO LAST MEM LOCATION
        BRA  MEMC2   PRINT LOCATION & CONTENTS
        BRA  MEMC2   ; PRINT LOCATION & CONTENTS
*
*
* "S" DISPLAY STACK
* "S" DISPLAY STACK
* HEX-ASCII DISPLAY OF CURRENT STACK CONTENTS FROM
* HEX-ASCII DISPLAY OF CURRENT STACK CONTENTS FROM
** CURRENT STACK POINTER TO INTERNAL STACK LIMIT.
** CURRENT STACK POINTER TO INTERNAL STACK LIMIT.
*
*
DISSTK  LBSR PRTSP   PRINT CURRENT STACK POINTER
DISSTK  LBSR PRTSP   ; PRINT CURRENT STACK POINTER
        TFR  U,Y
        TFR  U,Y
        LDX  #STACK  LOAD INTERNAL STACK AS UPPER LIMIT
        LDX  #STACK  ; LOAD INTERNAL STACK AS UPPER LIMIT
        LEAX -1,X    POINT TO CURRENT STACK
        LEAX -1,X    ; POINT TO CURRENT STACK
        BRA  MDUMP1  ENTER MEMORY DUMP OF STACK CONTENTS
        BRA  MDUMP1  ; ENTER MEMORY DUMP OF STACK CONTENTS
*
*
* "E" DUMP MEMORY FOR EXAMINE IN HEX AND ASCII
* "E" DUMP MEMORY FOR EXAMINE IN HEX AND ASCII
* AFTER CALLING 'IN2ADR' LOWER ADDRESS IN Y-REG.
* AFTER CALLING 'IN2ADR' LOWER ADDRESS IN Y-REG.
*                        UPPER ADDRESS IN X-REG.
*                        UPPER ADDRESS IN X-REG.
* IF HEX ADDRESSES ARE INVALID (V)=1.
* IF HEX ADDRESSES ARE INVALID (V)=1.
*
*
MEMDUMP LBSR IN2ADR  INPUT ADDRESS BOUNDRIES
MEMDUMP LBSR IN2ADR  ; INPUT ADDRESS BOUNDRIES
        BVS  EDPRTN  NEW COMMAND IF ILLEGAL HEX
        BVS  EDPRTN  ; NEW COMMAND IF ILLEGAL HEX
MDUMP1  PSHS Y       COMPARE LOWER TO UPPER BOUNDS
MDUMP1  PSHS Y       ; COMPARE LOWER TO UPPER BOUNDS
        CMPX ,S++    LOWER BOUNDS > UPPER BOUNDS?
        CMPX ,S++    ; LOWER BOUNDS > UPPER BOUNDS?
        BCC  AJDUMP  IF NOT, DUMP HEX AND ASCII
        BCC  AJDUMP  ; IF NOT, DUMP HEX AND ASCII
EDPRTN  RTS ;
EDPRTN  RTS ;
*
*
* ADJUST LOWER AND UPPER ADDRESS LIMITS
* ADJUST LOWER AND UPPER ADDRESS LIMITS
* TO EVEN 16 BYTE BOUNDRIES.
* TO EVEN 16 BYTE BOUNDRIES.
*
*
Line 328... Line 341...
* UPPER BOUNDS WILL BE ADJUSTED TO = $4570.
* UPPER BOUNDS WILL BE ADJUSTED TO = $4570.
*
*
* ENTER WITH LOWER ADDRESS IN X-REG.
* ENTER WITH LOWER ADDRESS IN X-REG.
*           -UPPER ADDRESS ON TOP OF STACK.
*           -UPPER ADDRESS ON TOP OF STACK.
*
*
AJDUMP  TFR  X,D     GET UPPER ADDR IN D-REG
AJDUMP  TFR  X,D     ; GET UPPER ADDR IN D-REG
        ADDD #$10    ADD 16 TO UPPER ADDRESS
        ADDD #$10    ; ADD 16 TO UPPER ADDRESS
        ANDB #$F0    MASK TO EVEN 16 BYTE BOUNDRY
        ANDB #$F0    ; MASK TO EVEN 16 BYTE BOUNDRY
        PSHS A,B     SAVE ON STACK AS UPPER DUMP LIMIT
        PSHS A,B     ; SAVE ON STACK AS UPPER DUMP LIMIT
        TFR  Y,D     $F9A5 GET LOWER ADDRESS IN D-REG
        TFR  Y,D     ; $F9A5 GET LOWER ADDRESS IN D-REG
        ANDB #$F0    MASK TO EVEN 16 BYTE BOUNDRY
        ANDB #$F0    ; MASK TO EVEN 16 BYTE BOUNDRY
        TFR  D,X     PUT IN X-REG AS LOWER DUMP LIMIT
        TFR  D,X     ; PUT IN X-REG AS LOWER DUMP LIMIT
NXTLIN  CMPX ,S      COMPARE LOWER TO UPPER LIMIT
NXTLIN  CMPX ,S      ; COMPARE LOWER TO UPPER LIMIT
        BEQ  SKPDMP  IF EQUAL SKIP HEX-ASCII DUMP
        BEQ  SKPDMP  ; IF EQUAL SKIP HEX-ASCII DUMP
        LBSR INCHEK  CHECK FOR INPUT FROM KEYBOARD
        LBSR INCHEK  ; CHECK FOR INPUT FROM KEYBOARD
        BEQ  EDUMP
        BEQ  EDUMP
SKPDMP  LEAS 2,S     READJUST STACK IF NOT DUMPING
SKPDMP  LEAS 2,S     ; READJUST STACK IF NOT DUMPING
        RTS          ;
        RTS          ;
*
*
* PRINT 16 HEX BYTES FOLLOWED BY 16 ASCII CHARACTERS
* PRINT 16 HEX BYTES FOLLOWED BY 16 ASCII CHARACTERS
* FOR EACH LINE THROUGHOUT ADDRESS LIMITS.
* FOR EACH LINE THROUGHOUT ADDRESS LIMITS.
*
*
EDUMP   PSHS X       PUSH LOWER ADDR LIMIT ON STACK
EDUMP   PSHS X       ; PUSH LOWER ADDR LIMIT ON STACK
        LDX  #MSG5   POINT TO MSG " - "
        LDX  #MSG5   ; POINT TO MSG " - "
        LBSR PSTRNG  PRINT MSG
        LBSR PSTRNG  ; PRINT MSG
        LDX  ,S      LOAD LOWER ADDR FROM TOP OF STACK
        LDX  ,S      ; LOAD LOWER ADDR FROM TOP OF STACK
        LBSR OUT4H   PRINT THE ADDRESS
        LBSR OUT4H   ; PRINT THE ADDRESS
        LBSR OUT2S   2 SPACES
        LBSR OUT2S   ; 2 SPACES
        LDB  #$10    LOAD COUNT OF 16 BYTES TO DUMP
        LDB  #$10    ; LOAD COUNT OF 16 BYTES TO DUMP
ELOOP   LDA  ,X+     GET FROM MEMORY HEX BYTE TO PRINT
ELOOP   LDA  ,X+     ; GET FROM MEMORY HEX BYTE TO PRINT
        LBSR OUT2H   OUTPUT HEX BYTE AS ASCII
        LBSR OUT2H   ; OUTPUT HEX BYTE AS ASCII
        LBSR OUT1S   OUTPUT SPACE
        LBSR OUT1S   ; OUTPUT SPACE
        DECB         $F9D1 DECREMENT BYTE COUNT
        DECB         ; $F9D1 DECREMENT BYTE COUNT
        BNE  ELOOP   CONTINUE TIL 16 HEX BYTES PRINTED
        BNE  ELOOP   ; CONTINUE TIL 16 HEX BYTES PRINTED
*
*
* PRINT 16 ASCII CHARACTERS
* PRINT 16 ASCII CHARACTERS
* IF NOT PRINTABLE OR NOT VALID
* IF NOT PRINTABLE OR NOT VALID
* ASCII PRINT A PERIOD (.)
* ASCII PRINT A PERIOD (.)
        LBSR OUT2S   2 SPACES
        LBSR OUT2S   ; 2 SPACES
        LDX  ,S++    GET LOW LIMIT FRM STACK - ADJ STACK
        LDX  ,S++    ; GET LOW LIMIT FRM STACK - ADJ STACK
        LDB  #$10    SET ASCII CHAR TO PRINT = 16
        LDB  #$10    ; SET ASCII CHAR TO PRINT = 16
EDPASC  LDA  ,X+     GET CHARACTER FROM MEMORY
EDPASC  LDA  ,X+     ; GET CHARACTER FROM MEMORY
        CMPA #$20    IF LESS THAN $20, NON-PRINTABLE?
        CMPA #$20    ; IF LESS THAN $20, NON-PRINTABLE?
        BCS  PERIOD  IF SO, PRINT PERIOD INSTEAD
        BCS  PERIOD  ; IF SO, PRINT PERIOD INSTEAD
        CMPA #$7E    IS IT VALID ASCII?
        CMPA #$7E    ; IS IT VALID ASCII?
        BLS  PRASC   IF SO PRINT IT
        BLS  PRASC   ; IF SO PRINT IT
PERIOD  LDA  #'.     LOAD A PERIOD (.)
PERIOD  LDA  #'.     ; LOAD A PERIOD (.)
PRASC   LBSR OUTCH   PRINT ASCII CHARACTER
PRASC   LBSR OUTCH   ; PRINT ASCII CHARACTER
        DECB         DECREMENT COUNT
        DECB         ; DECREMENT COUNT
        BNE  EDPASC
        BNE  EDPASC
        BRA  NXTLIN
        BRA  NXTLIN
*
*
***** "B" SET BREAKPOINT *****
***** "B" SET BREAKPOINT *****
*
*
BRKPNT  LBSR IN1ADR  GET BREAKPOINT ADDRESS
BRKPNT  LBSR IN1ADR  ; GET BREAKPOINT ADDRESS
        BVS  EXITBP  EXIT IF INVALID HEX ADDR.
        BVS  EXITBP  ; EXIT IF INVALID HEX ADDR.
        CMPX #STACK  ADDRESS ILLEGAL IF >=$DFC0
        CMPX #STACK  ; ADDRESS ILLEGAL IF >=$DFC0
        BCC  BPERR   IF ERROR PRINT (?), EXIT
        BCC  BPERR   ; IF ERROR PRINT (?), EXIT
        PSHS X       $FA82 PUSH BP ADDRESS ON STACK
        PSHS X       ; $FA82 PUSH BP ADDRESS ON STACK
        LDX  #$FFFF  LOAD DUMMY ADDR TO TEST BP TABLE
        LDX  #$FFFF  ; LOAD DUMMY ADDR TO TEST BP TABLE
        BSR BPTEST   TEST BP TABLE FOR FREE SPACE
        BSR BPTEST   ; TEST BP TABLE FOR FREE SPACE
        PULS X       POP BP ADDRESS FROM STACK
        PULS X       ; POP BP ADDRESS FROM STACK
        BEQ  BPERR   (Z) SET, OUT OF BP TABLE SPACE
        BEQ  BPERR   ; (Z) SET, OUT OF BP TABLE SPACE
        LDA  ,X      GET DATA AT BREAKPOINT ADDRESS
        LDA  ,X      ; GET DATA AT BREAKPOINT ADDRESS
        CMPA #$3F    IS IT A SWI?
        CMPA #$3F    ; IS IT A SWI?
        BEQ  BPERR   IF SWI ALREADY, INDICATE ERROR
        BEQ  BPERR   ; IF SWI ALREADY, INDICATE ERROR
        STA  ,Y+     SAVE DATA BYTE IN BP TABLE
        STA  ,Y+     ; SAVE DATA BYTE IN BP TABLE
        STX  ,Y      SAVE BP ADDRESS IN BP TABLE
        STX  ,Y      ; SAVE BP ADDRESS IN BP TABLE
        LDA  #$3F    LOAD A SWI ($3F)
        LDA  #$3F    ; LOAD A SWI ($3F)
        STA  ,X      SAVE SWI AT BREAKPOINT ADDRESS
        STA  ,X      ; SAVE SWI AT BREAKPOINT ADDRESS
EXITBP  RTS ;
EXITBP  RTS ;
*
*
*  INDICATE ERROR SETTING BREAKPOINT
*  INDICATE ERROR SETTING BREAKPOINT
*
*
BPERR   LBSR OUT1S   OUTPUT SPACE
BPERR   LBSR OUT1S   ; OUTPUT SPACE
        LDA  #'?     LOAD (?), INDICATE BREAKPOINT ERROR
        LDA  #'?     ; LOAD (?), INDICATE BREAKPOINT ERROR
        LBRA OUTCH   PRINT "?"
        LBRA OUTCH   ; PRINT "?"
*
*
*** "X" CLEAR OUTSTANDING BREAKPOINTS ***
*** "X" CLEAR OUTSTANDING BREAKPOINTS ***
*
*
XBKPNT  LDY  #BPTBL  POINT TO BREAKPOINT TABLE
XBKPNT  LDY  #BPTBL  ; POINT TO BREAKPOINT TABLE
        LDB  #8      LOAD BREAKPOINT COUNTER
        LDB  #8      ; LOAD BREAKPOINT COUNTER
XBPLP   BSR  RPLSWI  REMOVE USED ENTRY IN BP TABLE
XBPLP   BSR  RPLSWI  ; REMOVE USED ENTRY IN BP TABLE
        DECB  $FAAC  DECREMENT BP COUNTER
        DECB  $FAAC  ; DECREMENT BP COUNTER
        BNE  XBPLP   END OF BREAKPOINT TABLE?
        BNE  XBPLP   ; END OF BREAKPOINT TABLE?
        RTS
        RTS
*
*
***** SWI ENTRY POINT *****
***** SWI ENTRY POINT *****
*
*
SWIE    TFR  S,U     TRANSFER STACK TO USER POINTER
SWIE    TFR  S,U     ; TRANSFER STACK TO USER POINTER
        LDX  10,U    LOAD PC FROM STACK INTO X-REG
        LDX  10,U    ; LOAD PC FROM STACK INTO X-REG
        LEAX -1,X    ADJUST ADDR DOWN 1 BYTE.
        LEAX -1,X    ; ADJUST ADDR DOWN 1 BYTE.
        BSR  BPTEST  FIND BREAKPOINT IN BP TABLE
        BSR  BPTEST  ; FIND BREAKPOINT IN BP TABLE
        BEQ  REGPR   IF FOUND, REPLACE DATA AT BP ADDR
        BEQ  REGPR   ; IF FOUND, REPLACE DATA AT BP ADDR
        STX  10,U    SAVE BREAKPOINT ADDR IN STACK
        STX  10,U    ; SAVE BREAKPOINT ADDR IN STACK
        BSR  RPLSWI  GO REPLACE SWI WITH ORIGINAL DATA
        BSR  RPLSWI  ; GO REPLACE SWI WITH ORIGINAL DATA
REGPR   LBSR REGSTR  GO PRINT REGISTERS
REGPR   LBSR REGSTR  ; GO PRINT REGISTERS
*
*
        IFD TRAOPT
        IFD TRAOPT
        LDX #0
        LDX #0
        STX TRACNT
        STX TRACNT
        ENDIF TRAOPT
        ENDIF TRAOPT
*
*
        LBRA NEXTCMD GET NEXT COMMAND
        LBRA NEXTCMD ; GET NEXT COMMAND
*
*
RPLSWI  LDX  1,Y     LOAD BP ADDRESS FROM BP TABLE
RPLSWI  LDX  1,Y     ; LOAD BP ADDRESS FROM BP TABLE
        CMPX #STACK  COMPARE TO TOP AVAILABLE USER MEMORY
        CMPX #STACK  ; COMPARE TO TOP AVAILABLE USER MEMORY
        BCC  FFSTBL  GO RESET TABLE ENTRY TO $FF'S
        BCC  FFSTBL  ; GO RESET TABLE ENTRY TO $FF'S
        LDA  ,X      GET DATA FROM BP ADDRESS
        LDA  ,X      ; GET DATA FROM BP ADDRESS
        CMPA #$3F    IS IT SWI?
        CMPA #$3F    ; IS IT SWI?
        BNE  FFSTBL  IF NOT, RESET TABLE ENTRY TO $FF'S
        BNE  FFSTBL  ; IF NOT, RESET TABLE ENTRY TO $FF'S
        LDA  ,Y      GET ORIGINAL DATA FROM BP TABLE
        LDA  ,Y      ; GET ORIGINAL DATA FROM BP TABLE
        STA  ,X      $FAD3 RESTORE DATA AT BP ADDRESS
        STA  ,X      ; $FAD3 RESTORE DATA AT BP ADDRESS
FFSTBL  LDA  #$FF    LOAD $FF IN A-ACC
FFSTBL  LDA  #$FF    ; LOAD $FF IN A-ACC
        STA  ,Y+     RESET BREAKPOINT TABLE DATA TO $FF'S
        STA  ,Y+     ; RESET BREAKPOINT TABLE DATA TO $FF'S
        STA  ,Y+     RESET BREAKPOINT TABLE ADDR TO $FF'S
        STA  ,Y+     ; RESET BREAKPOINT TABLE ADDR TO $FF'S
        STA  ,Y+
        STA  ,Y+
        RTS
        RTS
*
*
** SEARCH BREAKPOINT TABLE FOR MATCH **
** SEARCH BREAKPOINT TABLE FOR MATCH **
*
*
BPTEST  LDY  #BPTBL  POINT TO BREAKPOINT TABLE
BPTEST  LDY  #BPTBL  ; POINT TO BREAKPOINT TABLE
        LDB  #8      LOAD BREAKPOINT COUNTER
        LDB  #8      ; LOAD BREAKPOINT COUNTER
FNDBP   LDA  ,Y+     LOAD DATA BYTE
FNDBP   LDA  ,Y+     ; LOAD DATA BYTE
        CMPX ,Y++    COMPARE ADDRESS, IS IT SAME?
        CMPX ,Y++    ; COMPARE ADDRESS, IS IT SAME?
        BEQ  BPADJ   IF SO, ADJUST POINTER FOR TABLE ENTRY
        BEQ  BPADJ   ; IF SO, ADJUST POINTER FOR TABLE ENTRY
        DECB         IF NOT, DECREMENT BREAKPOINT COUNTER
        DECB         ; IF NOT, DECREMENT BREAKPOINT COUNTER
        BNE  FNDBP   AND LOOK FOR NEXT POSSIBLE MATCH
        BNE  FNDBP   ; AND LOOK FOR NEXT POSSIBLE MATCH
        RTS ;
        RTS ;
*
*
*
*
BPADJ   LEAY -3,Y    MOVE POINTER TO BEGIN OF BP ENTRY
BPADJ   LEAY -3,Y    ; MOVE POINTER TO BEGIN OF BP ENTRY
        RTS
        RTS
*
*
        IFD TRAOPT
        IFD TRAOPT
*
*
** TRACE from address AAAA BB bytes
** TRACE from address AAAA BB bytes
*
*
TRACE   LBSR ALTPC1 SET UP NEW PC
TRACE   LBSR ALTPC1  ; SET UP NEW PC
        BVS TREXIT ADDRESS ERROR, EXIT
        BVS  TREXIT  ; ADDRESS ERROR, EXIT
        LBSR OUT1S
        LBSR OUT1S
        LBSR IN1ADR Fetch Byte Count
        LBSR IN1ADR  ; Fetch Byte Count
        BVS TREXIT Byte Count error, EXIT
        BVS TREXIT   ; Byte Count error, EXIT
        STX TRACNT
        STX TRACNT
*
*
        LDX NMI Save NMI Vector
        LDX NMI      ; Save NMI Vector
        STX NMISAV
        STX NMISAV
        LDX #NMIE Set up NMI for Tracing
        LDX #NMIE    ; Set up NMI for Tracing
        STX NMI
        STX NMI
        LBSR TRAINZ   Initialise Hardware
        LBSR TRAINZ  ; Initialise Hardware
        BRA TRACEG    Start Trace
        BRA TRACEG   ; Start Trace
TREXIT  RTS
TREXIT  RTS
*
*
* CRA0 = 0 CA1 IRQ DISAB, CRA0 = 1 CA1 IRQ ENAB
* CRA0 = 0 CA1 IRQ DISAB, CRA0 = 1 CA1 IRQ ENAB
* CRA1 = 1 CA1 Rising edge IRQ
* CRA1 = 1 CA1 Rising edge IRQ
* CRA2 = 0 TADATA = Data Direction, CRA2 = 1 TADATA = I/O Register
* CRA2 = 0 TADATA = Data Direction, CRA2 = 1 TADATA = I/O Register
Line 498... Line 511...
*
*
*
*
** TRACE NMI ENTRY POINT
** TRACE NMI ENTRY POINT
*
*
NMIE    TFR S,U
NMIE    TFR S,U
        LDA #$36         Disable Interrupt, CA2 Low
        LDA  #$36    ; Disable Interrupt, CA2 Low
        STA TACTRL
        STA TACTRL
        LDA TADATA       Clear Interrupt flag by reading data port
        LDA  TADATA  ; Clear Interrupt flag by reading data port
*
*
        LBSR REGSTR       DUMP REGISTERS
        LBSR REGSTR  ; DUMP REGISTERS
*
*
        LDX 10,U         TEST IF NEXT INSTRUCTION IS A SWI
        LDX  10,U    ; TEST IF NEXT INSTRUCTION IS A SWI
        LDA ,X
        LDA ,X
        CMPA #$3F
        CMPA #$3F
        BEQ TRACEX       EXIT ON SWI
        BEQ  TRACEX  ; EXIT ON SWI
*
*
        LDX TRACNT       CHECK IF TRACE COUNT EXPIRED
        LDX  TRACNT  ; CHECK IF TRACE COUNT EXPIRED
        BEQ TRACEX       YES, GO BACK TO THE MONITOR
        BEQ  TRACEX  ; YES, GO BACK TO THE MONITOR
        LEAX -1,X        DECREMENT TRACE COUNT
        LEAX -1,X    ; ECREMENT TRACE COUNT
        STX TRACNT
        STX TRACNT
*
*
**  TRACE GO (RESUME SINGLE STEP)
**  TRACE GO (RESUME SINGLE STEP)
*
*
TRACEG  TFR U,S          SET UP PROGRAM STACK POINTER
TRACEG  TFR  U,S     ; SET UP PROGRAM STACK POINTER
        LDA #TRADEL      SET UP TIMER DELAY (NUMB CYCLES FOR RTI+1)
        LDA  #TRADEL ; SET UP TIMER DELAY (NUMB CYCLES FOR RTI+1)
        STA TADATA
        STA TADATA
        LDA #$36         LOAD STROBE LOW
        LDA  #$36    ; LOAD STROBE LOW
        STA TACTRL
        STA TACTRL
        LDA TADATA       CLEAR INTERRUPT
        LDA  TADATA  ; CLEAR INTERRUPT
        LDA #$36         RELEASE RESET
        LDA  #$36    ; RELEASE RESET
        STA TBCTRL
        STA TBCTRL
        LDA #$3F         RELEASE LOAD, ENABLE CA1 NMI, CA1 RISING EDGE
        LDA  #$3F    ; RELEASE LOAD, ENABLE CA1 NMI, CA1 RISING EDGE
        STA TACTRL
        STA TACTRL
        RTI              GO EXECUTE INSTRUCTION
        RTI          ; GO EXECUTE INSTRUCTION
*
*
TRACEX  LDX NMISAV       Restore NMI vector
TRACEX  LDX NMISAV   ; Restore NMI vector
        STX NMI
        STX NMI
        LBRA NEXTCMD     Jump back to the command loop.
        LBRA NEXTCMD ; Jump back to the command loop.
*
*
** TRACE HARDWARE INITIALISATION
** TRACE HARDWARE INITIALISATION
*
*
TRAINZ  LDA #$32         SELECT DDRA, CA2 LOW, NMI DISABLED
TRAINZ  LDA #$32     ; SELECT DDRA, CA2 LOW, NMI DISABLED
        STA TACTRL
        STA TACTRL
        LDA #$3A         SELECT DDRB, CB2 HIGH, FIRQ DISABLED
        LDA #$3A     ; SELECT DDRB, CB2 HIGH, FIRQ DISABLED
        STA TBCTRL
        STA TBCTRL
        LDA #$FF         PORTA = OUTPUT
        LDA #$FF     ; PORTA = OUTPUT
        STA TADATA
        STA TADATA
        LDA #$00         PORTB = INPUT
        LDA #$00     ; PORTB = INPUT
        STA TBDATA
        STA TBDATA
        LDA #$36         SELECT OUTPUT REGISTER A, CA2 LOW
        LDA #$36     ; SELECT OUTPUT REGISTER A, CA2 LOW
        STA TACTRL
        STA TACTRL
        LDA #$3E         SELECT OUTPUT REGISTER B, CB2 HIGH
        LDA #$3E     ; SELECT OUTPUT REGISTER B, CB2 HIGH
        STA TBCTRL
        STA TBCTRL
        RTS
        RTS
*
*
        ENDIF TRAOPT
        ENDIF TRAOPT
        IFD  MFDCOPT
        IFD  MFDCOPT
Line 602... Line 615...
*** "D" DISK BOOT FOR DMAF2 ***
*** "D" DISK BOOT FOR DMAF2 ***
*
*
DBOOT   LDA  #$DE
DBOOT   LDA  #$DE
        STA  DRVREG
        STA  DRVREG
        LDA  #$FF
        LDA  #$FF
        STA  PRIREG     $FAF8
        STA  PRIREG  ; $FAF8
        STA  CCREG
        STA  CCREG
        STA  AAAREG
        STA  AAAREG
        STA  BBBREG
        STA  BBBREG
        TST  CCREG
        TST  CCREG
        LDA  #$D8
        LDA  #$D8
Line 616... Line 629...
        BMI  DBOOT0
        BMI  DBOOT0
        LDA  #$09
        LDA  #$09
        STA  COMREG
        STA  COMREG
        LBSR DLY
        LBSR DLY
*
*
DISKWT  LDA  COMREG FETCH DRIVE STATUS
DISKWT  LDA  COMREG  ; FETCH DRIVE STATUS
        BITA #1 TEST BUSY BIT
        BITA #1      ; TEST BUSY BIT
        BNE  DISKWT LOOP UNTIL NOT BUSY
        BNE  DISKWT  ; LOOP UNTIL NOT BUSY
*
*
        BITA #$10
        BITA #$10
        BNE  DBOOT
        BNE  DBOOT
*
*
        LDX  #$C000 LOGICAL ADDR. = $C000
        LDX  #$C000  ; LOGICAL ADDR. = $C000
        BSR LRA  GET 20 BIT PHYSICAL ADDR. OF LOG. ADDR.
        BSR LRA      ; GET 20 BIT PHYSICAL ADDR. OF LOG. ADDR.
        ORA  #$10
        ORA  #$10
        STA  CCCREG
        STA  CCCREG
        TFR  X,D
        TFR  X,D
        COMA  ;
        COMA  ;
        COMB  ;
        COMB  ;
        STD  ADDREG
        STD  ADDREG
        LDX  #$FEFF LOAD DMA BYTE COUNT = $100
        LDX  #$FEFF  ; LOAD DMA BYTE COUNT = $100
        STX  CNTREG STORE IN COUNT REGISTER
        STX  CNTREG  ; STORE IN COUNT REGISTER
        LDA  #$FF LOAD THE CHANNEL REGISTER
        LDA  #$FF    ; LOAD THE CHANNEL REGISTER
        STA  CCREG
        STA  CCREG
        LDA  #$FE SET CHANNEL 0
        LDA  #$FE    ; SET CHANNEL 0
        STA  PRIREG
        STA  PRIREG
        LDA  #1 SET SECTOR TO "1"
        LDA  #1      ; SET SECTOR TO "1"
        STA  SECREG ISSUE COMMAND
        STA  SECREG  ; ISSUE COMMAND
        LDA  #$8C SET SINGLE SECTOR READ
        LDA  #$8C    ; SET SINGLE SECTOR READ
        STA  COMREG ISSUE COMMAND
        STA  COMREG  ; ISSUE COMMAND
        BSR DLY
        BSR DLY
*
*
* THE FOLLOWING CODE TESTS THE STATUS OF THE
* THE FOLLOWING CODE TESTS THE STATUS OF THE
* CHANNEL CONTROL REGISTER. IF "D7" IS NOT
* CHANNEL CONTROL REGISTER. IF "D7" IS NOT
* ZERO THEN IT WILL LOOP WAITING FOR "D7"
* ZERO THEN IT WILL LOOP WAITING FOR "D7"
* TO GO TO ZERO. IF AFTER 65,536 TRIES IT
* TO GO TO ZERO. IF AFTER 65,536 TRIES IT
* IS STILL A ONE THE BOOT OPERATION WILL
* IS STILL A ONE THE BOOT OPERATION WILL
* BE STARTED OVER FROM THE BEGINING.
* BE STARTED OVER FROM THE BEGINING.
*
*
        CLRB  ;
        CLRB  ;
DBOOT1  PSHS B     $FB55
DBOOT1  PSHS B       ; $FB55
        CLRB  ;
        CLRB  ;
DBOOT2  TST  CCREG
DBOOT2  TST  CCREG
        BPL  DBOOT3
        BPL  DBOOT3
        DECB  ;
        DECB  ;
        BNE  DBOOT2
        BNE  DBOOT2
Line 672... Line 685...
*
*
DBOOT4  LDB  #$DE
DBOOT4  LDB  #$DE
        STB  DRVREG
        STB  DRVREG
        LDX  #$C000
        LDX  #$C000
        STX  10,U
        STX  10,U
        TFR  U,S    $FB7B
        TFR  U,S     ; $FB7B
        RTI  ;
        RTI  ;
        ENDIF DMAFOPT
        ENDIF DMAFOPT
*
*
        IFD CF8OPT
        IFD CF8OPT
*
*
Line 815... Line 828...
       BNE RDCLK1
       BNE RDCLK1
       RTS
       RTS
*
*
* MAIN PROGRAM:
* MAIN PROGRAM:
*
*
TIMSET LDX #COUNTR POINT TO TIMER
TIMSET LDX #COUNTR    ; POINT TO TIMER
      LBSR BYTE READ HOURS
      LBSR BYTE       ; READ HOURS
      BVS  SHOWTM NO ARG, DISP TIME
      BVS  SHOWTM     ; NO ARG, DISP TIME
      STA HOUR,X
      STA HOUR,X
      LBSR OUT1S
      LBSR OUT1S
      LBSR BYTE READ MINUITES
      LBSR BYTE       ; READ MINUITES
      BVS  SHOWTM
      BVS  SHOWTM
      STA MINUIT,X
      STA MINUIT,X
      LBSR OUT1S
      LBSR OUT1S
      LBSR BYTE SECONDS.
      LBSR BYTE       ; SECONDS.
      BVS SHOWTM
      BVS SHOWTM
      STA SECOND,X
      STA SECOND,X
*
*
* DISPLAY CURRENT TIME
* DISPLAY CURRENT TIME
*
*
Line 845... Line 858...
       RTS
       RTS
*
*
* INITIATE CLOCK.
* INITIATE CLOCK.
* MASK INTERRUPTS.
* MASK INTERRUPTS.
*
*
CLKINZ CLR CINTCR  MASK ALL INTERRUPTS
CLKINZ CLR CINTCR     ; MASK ALL INTERRUPTS
       TST CINTSR  CLEAR ANY INTERRUPTS
       TST CINTSR     ; CLEAR ANY INTERRUPTS
       RTS
       RTS
       ENDIF RTCOPT
       ENDIF RTCOPT
       IFD DATOPT
       IFD DATOPT
*
*
***** LRA LOAD REAL ADDRESS *****
***** LRA LOAD REAL ADDRESS *****
Line 869... Line 882...
* THIS ROUTINE IS REQUIRED SINCE THE
* THIS ROUTINE IS REQUIRED SINCE THE
* DMAF1 AND DMAF2 DISK CONTROLLERS MUST
* DMAF1 AND DMAF2 DISK CONTROLLERS MUST
* PRESENT PHYSICAL ADDRESSES ON THE
* PRESENT PHYSICAL ADDRESSES ON THE
* SYSTEM BUS.
* SYSTEM BUS.
*
*
LRA     PSHS A,B,X,Y PUSH REGISTERS ON STACK
LRA     PSHS A,B,X,Y  ; PUSH REGISTERS ON STACK
        LDA  2,S     GET MSB LOGICAL ADDR FRM X REG ON STACK
        LDA  2,S      ; GET MSB LOGICAL ADDR FRM X REG ON STACK
        LSRA         ;
        LSRA         ;
        LSRA         ADJ FOR INDEXED INTO
        LSRA          ; ADJ FOR INDEXED INTO
        LSRA         CORRESPONDING LOCATION
        LSRA          ; CORRESPONDING LOCATION
        LSRA         IN LRA TABLE
        LSRA          ; IN LRA TABLE
        LDY  #LRARAM LOAD LRA TABLE BASE ADDRESS
        LDY  #LRARAM  ; LOAD LRA TABLE BASE ADDRESS
        LDB  A,Y     GET PHYSICAL ADDR. DATA FROM LRA TABLE
        LDB  A,Y      ; GET PHYSICAL ADDR. DATA FROM LRA TABLE
        LSRB         ADJ. REAL ADDR. TO REFLECT EXTENDED
        LSRB          ; ADJ. REAL ADDR. TO REFLECT EXTENDED
        LSRB         PHYSICAL ADDRESS.
        LSRB          ; PHYSICAL ADDRESS.
        LSRB         EXTENDED MS 4-BITS ARE RETURNED
        LSRB          ; EXTENDED MS 4-BITS ARE RETURNED
        LSRB         IN THE "A" ACCUMULATOR
        LSRB          ; IN THE "A" ACCUMULATOR
        STB  ,S      MS 4 BITS IN A ACCUM. STORED ON STACK
        STB  ,S       ; MS 4 BITS IN A ACCUM. STORED ON STACK
        LDB  A,Y     LOAD REAL ADDRESS DATA FROM LRA TABLE
        LDB  A,Y      ; LOAD REAL ADDRESS DATA FROM LRA TABLE
        COMB         COMP TO ADJ FOR PHYSICAL ADDR. IN X REG
        COMB          ; COMP TO ADJ FOR PHYSICAL ADDR. IN X REG
        ASLB         ADJ DATA FOR RELOCATION IN X REG
        ASLB          ; ADJ DATA FOR RELOCATION IN X REG
        ASLB         ;
        ASLB         ;
        ASLB         $FB97
        ASLB          ; $FB97
        ASLB         ;
        ASLB         ;
        LDA  2,S     GET MS BYTE OF LOGICAL ADDR.
        LDA  2,S      ; GET MS BYTE OF LOGICAL ADDR.
        ANDA #$0F    MASK MS NIBBLE OF LOGICAL ADDRESS
        ANDA #$0F     ; MASK MS NIBBLE OF LOGICAL ADDRESS
        STA  2,S     SAVE IT IN X REG ON STACK
        STA  2,S      ; SAVE IT IN X REG ON STACK
        ORB  2,S     SET MS BYTE IN X REG TO ADJ PHY ADDR.
        ORB  2,S      ; SET MS BYTE IN X REG TO ADJ PHY ADDR.
*
*
* PLUS LS NIBBLE OF LOGICAL ADDRESS
* PLUS LS NIBBLE OF LOGICAL ADDRESS
        STB  2,S     SAVE AS LS 16 BITS OF PHY ADDR IN X REG
*
* ON STACK
        STB  2,S      ; SAVE AS LS 16 BITS OF PHY ADDR IN X REG ON STACK
        PULS A,B,X,Y,PC POP REGS. FROM STACK
        PULS A,B,X,Y,PC ; POP REGS. FROM STACK
        ENDIF DATOPT
        ENDIF DATOPT
*
*
* DELAY LOOP
* DELAY LOOP
*
*
DLY     PSHS B       SAVE CONTENTS OF "B"
DLY     PSHS B        ; SAVE CONTENTS OF "B"
        LDB  #$20    GET LOOP DELAY VALUE
        LDB  #$20     ; GET LOOP DELAY VALUE
SUB1    DECB         SUBTRACT ONE FROM VALUE
SUB1    DECB          ; SUBTRACT ONE FROM VALUE
        BNE  SUB1    LOOP UNTIL ZERO
        BNE  SUB1     ; LOOP UNTIL ZERO
        PULS B,PC    RESTORE CONTENTS OF "B"
        PULS B,PC     ; RESTORE CONTENTS OF "B"
* RTS  ;
* RTS  ;
*
*
***** "L" LOAD MIKBUG TAPE *****
***** "L" LOAD MIKBUG TAPE *****
*
*
LOAD    JSR  ACINIZ
LOAD    JSR  ACINIZ
        LDA  #$11   LOAD 'DC1' CASS. READ ON CODE
        LDA  #$11     ; LOAD 'DC1' CASS. READ ON CODE
        LBSR OUTCH  OUTPUT IT TO TERMINAL PORT
        LBSR OUTCH    ; OUTPUT IT TO TERMINAL PORT
        CLR  ECHO   TURN OFF ECHO FLAG
        CLR  ECHO     ; TURN OFF ECHO FLAG
LOAD1   LBSR ECHON  INPUT 8 BIT BYTE WITH NO ECHO
LOAD1   LBSR ECHON    ; INPUT 8 BIT BYTE WITH NO ECHO
LOAD2   CMPA #'S    IS IT AN "S", START CHARACTER ?
LOAD2   CMPA #'S      ; IS IT AN "S", START CHARACTER ?
        BNE  LOAD1  IF NOT, DISCARD AND GET NEXT CHAR.
        BNE  LOAD1    ; IF NOT, DISCARD AND GET NEXT CHAR.
        LBSR ECHON
        LBSR ECHON
        CMPA #'9    IS IT A "9" , END OF FILE CHAR ?
        CMPA #'9      ; IS IT A "9" , END OF FILE CHAR ?
        BEQ  LOAD21 IF SO, EXIT LOAD
        BEQ  LOAD21   ; IF SO, EXIT LOAD
        CMPA #'1    IS IT A "1" , FILE LOAD CHAR ?
        CMPA #'1      ; IS IT A "1" , FILE LOAD CHAR ?
        BNE  LOAD2  IF NOT, LOOK FOR START CHAR.
        BNE  LOAD2    ; IF NOT, LOOK FOR START CHAR.
        LBSR BYTE   INPUT BYTE COUNT
        LBSR BYTE     ; INPUT BYTE COUNT
        PSHS A      PUSH COUNT ON STACK
        PSHS A        ; PUSH COUNT ON STACK
        BVS  LODERR (V) C-CODE SET, ILLEGAL HEX
        BVS  LODERR   ; (V) C-CODE SET, ILLEGAL HEX
        LBSR IN1ADR INPUT LOAD ADDRESS
        LBSR IN1ADR   ; INPUT LOAD ADDRESS
        BVS  LODERR (V) C-CODE SET, ADDR NOT HEX
        BVS  LODERR   ; (V) C-CODE SET, ADDR NOT HEX
        PSHS X      PUSH ADDR ON STACK
        PSHS X        ; PUSH ADDR ON STACK
        LDB  ,S+    LOAD MSB OF ADDR AS CHECKSUM BYTE
        LDB  ,S+      ; LOAD MSB OF ADDR AS CHECKSUM BYTE
        ADDB ,S+    ADD LSB OF ADDR TO CHECKSUM
        ADDB ,S+      ; ADD LSB OF ADDR TO CHECKSUM
        ADDB ,S     ADD BYTE COUNT BYTE TO CHECKSUM
        ADDB ,S       ; ADD BYTE COUNT BYTE TO CHECKSUM
        DEC  ,S     $FC37 DECREMENT BYTE COUNT 2 TO BYPASS
        DEC  ,S       ; $FC37 DECREMENT BYTE COUNT 2 TO BYPASS
        DEC  ,S     ADDRESS BYTES.
        DEC  ,S       ; ADDRESS BYTES.
LOAD10  PSHS B      PUSH CHECKSUM ON STACK
LOAD10  PSHS B        ; PUSH CHECKSUM ON STACK
        LBSR BYTE   INPUT DATA BYTE (2 HEX CHAR)
        LBSR BYTE     ; INPUT DATA BYTE (2 HEX CHAR)
        PULS B      POP CHECKSUM FROM STACK
        PULS B        ; POP CHECKSUM FROM STACK
        BVS  LODERR (V) SET, DATA BYTE NOT HEX
        BVS  LODERR   ; (V) SET, DATA BYTE NOT HEX
        PSHS A      PUSH DATA BYTE ON STACK
        PSHS A        ; PUSH DATA BYTE ON STACK
        ADDB ,S+    ADD DATA TO CHECKSUM, AUTO INC STACK
        ADDB ,S+      ; ADD DATA TO CHECKSUM, AUTO INC STACK
        DEC  ,S     DECREMENT BYTE COUNT 1
        DEC  ,S       ; DECREMENT BYTE COUNT 1
        BEQ  LOAD16 IF BYTE COUNT ZERO, TEST CHECKSUM
        BEQ  LOAD16   ; IF BYTE COUNT ZERO, TEST CHECKSUM
        STA  ,X+    SAVE DATA BYTE IN MEMORY
        STA  ,X+      ; SAVE DATA BYTE IN MEMORY
        BRA  LOAD10 GET NEXT DATA BYTE
        BRA  LOAD10   ; GET NEXT DATA BYTE
LODERR  CLRB        ;ERROR CONDITION, ZERO CHECKSUM  ;
LODERR  CLRB        ;ERROR CONDITION, ZERO CHECKSUM  ;
LOAD16  PULS A      ADJUST STACK (REMOVE BYTE COUNT)
LOAD16  PULS A        ; ADJUST STACK (REMOVE BYTE COUNT)
        CMPB #$FF   CHECKSUM OK?
        CMPB #$FF     ; CHECKSUM OK?
        BEQ  LOAD1  IF SO, LOAD NEXT LINE
        BEQ  LOAD1    ; IF SO, LOAD NEXT LINE
        LDA  #'?    LOAD (?) ERROR INDICATOR
        LDA  #'?      ; LOAD (?) ERROR INDICATOR
        LBSR OUTCH  OUTPUT IT TO TERMINAL
        LBSR OUTCH    ; OUTPUT IT TO TERMINAL
LOAD21  COM  ECHO   TURN ECHO ON
LOAD21  COM  ECHO     ; TURN ECHO ON
        LDA  #$13   $FC5F LOAD 'DC3' CASS. READ OFF CODE
        LDA  #$13     ; $FC5F LOAD 'DC3' CASS. READ OFF CODE
        LBRA OUTCH  OUTPUT IT
        LBRA OUTCH    ; OUTPUT IT
*
*
***** "P" PUNCH MIKBUG TAPE *****
***** "P" PUNCH MIKBUG TAPE *****
*
*
PUNCH   CLR  ,-S CLEAR RESERVED BYTE ON STACK
PUNCH   CLR  ,-S      ; CLEAR RESERVED BYTE ON STACK
        LBSR IN2ADR GET BEGIN AND END ADDRESS
        LBSR IN2ADR   ; GET BEGIN AND END ADDRESS
        PSHS X,Y SAVE ADDRESSES ON STACK
        PSHS X,Y      ; SAVE ADDRESSES ON STACK
        BVS  PUNEXT (V) C-CODE SET, EXIT PUNCH
        BVS  PUNEXT   ; (V) C-CODE SET, EXIT PUNCH
        CMPX 2,S COMPARE BEGIN TO END ADDR
        CMPX 2,S      ; COMPARE BEGIN TO END ADDR
        BCS  PUNEXT IF BEGIN GREATER THAN END, EXIT PUNCH
        BCS  PUNEXT   ; IF BEGIN GREATER THAN END, EXIT PUNCH
        LEAX 1,X INCREMENT END ADDRESS
        LEAX 1,X      ; INCREMENT END ADDRESS
        STX  ,S STORE END ADDR ON STACK
        STX  ,S       ; STORE END ADDR ON STACK
        JSR  ACINIZ
        JSR  ACINIZ
        LDA  #$12 LOAD 'DC2' PUNCH ON CODE
        LDA  #$12     ; LOAD 'DC2' PUNCH ON CODE
        LBSR OUTCH OUTPUT IT TO TERMINAL
        LBSR OUTCH    ; OUTPUT IT TO TERMINAL
PUNCH2  LDD  ,S LOAD END ADDR IN D-ACC
PUNCH2  LDD  ,S       ; LOAD END ADDR IN D-ACC
        SUBD 2,S SUBTRACT BEGIN FROM END
        SUBD 2,S      ; SUBTRACT BEGIN FROM END
        BEQ  PUNCH3 SAME, PUNCH 32 BYTES DEFAULT
        BEQ  PUNCH3   ; SAME, PUNCH 32 BYTES DEFAULT
        CMPD #$20 LESS THAN 32 BYTES?
        CMPD #$20     ; LESS THAN 32 BYTES?
        BLS  PUNCH4 PUNCH THAT MANY BYTES
        BLS  PUNCH4   ; PUNCH THAT MANY BYTES
PUNCH3  LDB  #$20 LOAD BYTE COUNT OF 32.
PUNCH3  LDB  #$20     ; LOAD BYTE COUNT OF 32.
PUNCH4  STB  4,S STORE ON STACK AS BYTE COUNT
PUNCH4  STB  4,S      ; STORE ON STACK AS BYTE COUNT
        LDX  #MSG20 POINT TO MSG "S1"
        LDX  #MSG20   ; POINT TO MSG "S1"
        LBSR PSTRNG PRINT MSG
        LBSR PSTRNG   ; PRINT MSG
        ADDB #3 ADD 3 BYTES TO BYTE COUNT
        ADDB #3       ; ADD 3 BYTES TO BYTE COUNT
        TFR  B,A GET BYTE COUNT IN A-ACC TO PUNCH
        TFR  B,A      ; GET BYTE COUNT IN A-ACC TO PUNCH
        LBSR OUT2H OUTPUT BYTE COUNT
        LBSR OUT2H    ; OUTPUT BYTE COUNT
        LDX  2,S LOAD BEGIN ADDRESS
        LDX  2,S      ; LOAD BEGIN ADDRESS
        LBSR OUT4H PUNCH ADDRESS
        LBSR OUT4H    ; PUNCH ADDRESS
        ADDB 2,S ADD ADDR MSB TO CHECKSUM
        ADDB 2,S      ; ADD ADDR MSB TO CHECKSUM
        ADDB 3,S ADD ADDR LSB TO CHECKSUM
        ADDB 3,S      ; ADD ADDR LSB TO CHECKSUM
PUNCHL  ADDB ,X ADD DATA BYTE TO CHECKSUM
PUNCHL  ADDB ,X       ; ADD DATA BYTE TO CHECKSUM
        LDA  ,X+ LOAD DATA BYTE TO PUNCH
        LDA  ,X+      ; LOAD DATA BYTE TO PUNCH
        LBSR OUT2H OUTPUT DATA BYTE
        LBSR OUT2H    ; OUTPUT DATA BYTE
        DEC  4,S DECREMENT BYTE COUNT
        DEC  4,S      ; DECREMENT BYTE COUNT
        BNE  PUNCHL NOT DONE, PUNCH NEXT BYTE
        BNE  PUNCHL   ; NOT DONE, PUNCH NEXT BYTE
        COMB  1's COMPLIMENT CHECKSUM BYTE
        COMB  1's     ; COMPLIMENT CHECKSUM BYTE
        TFR  B,A GET IT IN A-ACC TO PUNCH
        TFR  B,A      ; GET IT IN A-ACC TO PUNCH
        LBSR OUT2H OUTPUT CHECKSUM BYTE
        LBSR OUT2H    ; OUTPUT CHECKSUM BYTE
        STX  2,S SAVE X-REG IN STACK AS NEW PUNCH ADDR
        STX  2,S      ; SAVE X-REG IN STACK AS NEW PUNCH ADDR
        CMPX ,S COMPARE IT TO END ADDR
        CMPX ,S       ; COMPARE IT TO END ADDR
        BNE  PUNCH2      $FCB5 PUNCH NOT DONE, CONT.
        BNE  PUNCH2   ; $FCB5 PUNCH NOT DONE, CONT.
PUNEXT  LDA  #$14 LOAD 'DC4' PUNCH OFF CODE
PUNEXT  LDA  #$14     ; LOAD 'DC4' PUNCH OFF CODE
        LBSR OUTCH OUTPUT IT
        LBSR OUTCH    ; OUTPUT IT
        LEAS 5,S READJUST STACK POINTER
        LEAS 5,S      ; READJUST STACK POINTER
        RTS  ;
        RTS  ;
*
*
* PRINT STRING PRECEEDED BY A CR & LF.
* PRINT STRING PRECEEDED BY A CR & LF.
*
*
PSTRNG BSR PCRLF PRINT CR/LF
PSTRNG  BSR  PCRLF    ; PRINT CR/LF
       BRA  PDATA  PRINT STRING POINTED TO BY IX
        BRA  PDATA    ; PRINT STRING POINTED TO BY IX
*
*
* PCRLF
* PCRLF
*
*
PCRLF  PSHS X SAVE IX
PCRLF   PSHS X        ; SAVE IX
       LDX  #MSG2+1  POINT TO MSG CR/LF + 3 NULS
        LDX  #MSG2+1  ; POINT TO MSG CR/LF + 3 NULS
       LBSR PDATA  PRINT MSG
        LBSR PDATA    ; PRINT MSG
       PULS X,PC RESTORE IX & RETURN
        PULS X,PC     ; RESTORE IX & RETURN
*
*
* LONG BRANCHES TO COMMON ROUTINES
* LONG BRANCHES TO COMMON ROUTINES
*
*
JOUT1S  LBRA OUT1S
JOUT1S  LBRA OUT1S
JBYTE   LBRA BYTE
JBYTE   LBRA BYTE
JIN1ADR LBRA IN1ADR
JIN1ADR LBRA IN1ADR
*
*
* ALTER "PC" PROGRAM COUNTER
* ALTER "PC" PROGRAM COUNTER
*
*
ALTRPC  LBSR  PRTPC   $FCF5 PRINT MSG " PC = "
ALTRPC  LBSR  PRTPC   ; $FCF5 PRINT MSG " PC = "
ALTPC1  BSR  JOUT1S   OUTPUT SPACE
ALTPC1  BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JIN1ADR  GET NEW CONTENTS FOR "PC"
        BSR  JIN1ADR  ; GET NEW CONTENTS FOR "PC"
        BVS  ALTPCD  EXIT IF INVALID HEX
        BVS  ALTPCD   ; EXIT IF INVALID HEX
        STX  10,U    POKE IN NEW CONTENTS
        STX  10,U     ; POKE IN NEW CONTENTS
ALTPCD  RTS          ;
ALTPCD  RTS          ;
*
*
* ALTER "U" USER STACK POINTER
* ALTER "U" USER STACK POINTER
*
*
ALTRU   BSR  PRTUS   $FCCA PRINT MSG " US = "
ALTRU   BSR  PRTUS    ; $FCCA PRINT MSG " US = "
        BSR  JOUT1S   OUTPUT SPACE
        BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JIN1ADR
        BSR  JIN1ADR  ; GET NEW CONTENTS FOR "US"
        BVS  ALTUD
        BVS  ALTUD    ; EXIT IF INVALID HEX
        STX  8,U
        STX  8,U      ; POKE IN NEW CONTENTS
ALTUD   RTS ;
ALTUD   RTS ;
*
*
* ALTER "Y" INDEX REGISTER
* ALTER "Y" INDEX REGISTER
*
*
ALTRY   BSR  PRTIY   PRINT MSG " IY = "
ALTRY   BSR  PRTIY    ; PRINT MSG " IY = "
        BSR  JOUT1S   OUTPUT SPACE
        BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JIN1ADR
        BSR  JIN1ADR  ; GET NEW CONTENTS FOR "IY"
        BVS  ALTYD
        BVS  ALTYD    ; EXIT IF INVALID HEX
        STX  6,U     $F8F0
        STX  6,U      ; $F8F0 POKE IN NEW CONTENTS
ALTYD   RTS ;
ALTYD   RTS ;
*
*
* ALTER "X" INDEX REGISTER
* ALTER "X" INDEX REGISTER
*
*
ALTRX   BSR  PRTIX   $FCE0 PRINT MSG " IX = "
ALTRX   BSR  PRTIX    ; $FCE0 PRINT MSG " IX = "
        BSR  JOUT1S   OUTPUT SPACE
        BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JIN1ADR
        BSR  JIN1ADR
        BVS  ALTXD
        BVS  ALTXD
        STX  4,U
        STX  4,U
ALTXD   RTS ;
ALTXD   RTS ;
*
*
* ALTER "DP" DIRECT PAGE REGISTER
* ALTER "DP" DIRECT PAGE REGISTER
*
*
ALTRDP  BSR  PRTDP   $FCD5 PRINT MSG " DP = "
ALTRDP  BSR  PRTDP    ; $FCD5 PRINT MSG " DP = "
        BSR  JOUT1S   OUTPUT SPACE
        BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JBYTE    INPUT BYTE (2 HEX CHAR)
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
        BVS  ALTDPD
        BVS  ALTDPD
        STA  3,U
        STA  3,U
ALTDPD  RTS ;
ALTDPD  RTS ;
*
*
* ALTER "B" ACCUMULATOR
* ALTER "B" ACCUMULATOR
*
*
ALTRB   BSR  PRTB    $FD09 PRINT MSG " B = "
ALTRB   BSR  PRTB     ; $FD09 PRINT MSG " B = "
        BSR  JOUT1S   OUTPUT SPACE
        BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JBYTE    INPUT BYTE (2 HEX CHAR)
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
        BVS  ALTBD
        BVS  ALTBD
        STA  2,U
        STA  2,U
ALTBD   RTS          $F91C
ALTBD   RTS           ; $F91C
*
*
* ALTER "A" ACCUMULATOR
* ALTER "A" ACCUMULATOR
*
*
ALTRA   BSR  PRTA    $FCFF RINT MSG " A = "
ALTRA   BSR  PRTA     ; $FCFF RINT MSG " A = "
        BSR  JOUT1S   OUTPUT SPACE
        BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JBYTE    INPUT BYTE (2 HEX CHAR)
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
        BVS  ALTAD
        BVS  ALTAD
        STA  1,U
        STA  1,U
ALTAD   RTS ;
ALTAD   RTS ;
*
*
* ALTER "CC" REGISTER
* ALTER "CC" REGISTER
*
*
ALTRCC  BSR  PRTCC   $FD13 PRINT MSG " CC: "
ALTRCC  BSR  PRTCC    ; $FD13 PRINT MSG " CC: "
        BSR  JOUT1S   OUTPUT SPACE
        BSR  JOUT1S   ; OUTPUT SPACE
        BSR  JBYTE    INPUT BYTE (2 HEX CHAR)
        BSR  JBYTE    ; INPUT BYTE (2 HEX CHAR)
        BVS  ALTCCD
        BVS  ALTCCD
        ORA  #$80    SETS "E" FLAG IN PRINT LIST
        ORA  #$80     ; SETS "E" FLAG IN PRINT LIST
        STA  ,U
        STA  ,U
ALTCCD  RTS ;
ALTCCD  RTS ;
*
*
* PDATA
* PDATA
*
*
PRINT LBSR OUTCH
PRINT LBSR OUTCH
PDATA LDA  ,X+ GET 1st CHAR. TO PRINT
PDATA   LDA  ,X+      ; GET 1st CHAR. TO PRINT
      CMPA #4 IS IT EOT?
        CMPA #4       ; IS IT EOT?
      BNE  PRINT IF NOT EOT PRINT IT
        BNE  PRINT    ; IF NOT EOT PRINT IT
      RTS  ;
      RTS  ;
*
*
* PRINT REGISTERS
* PRINT REGISTERS
*
*
PRTSP  LDX  #MSG10 POINT TO MSG "SP="
PRTSP   LDX  #MSG10   ; POINT TO MSG "SP="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       TFR  U,X
       TFR  U,X
JOUT4H LBRA OUT4H
JOUT4H LBRA OUT4H
*
*
PRTUS  LDX  #MSG12 POINT TO MSG "US="
PRTUS   LDX  #MSG12   ; POINT TO MSG "US="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDX  8,U
       LDX  8,U
       BRA  JOUT4H
       BRA  JOUT4H
*
*
PRTDP  LDX   #MSG15 POINT TO MSG "DP="
PRTDP   LDX   #MSG15  ; POINT TO MSG "DP="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDA  3,U
       LDA  3,U
JOUT2H LBRA OUT2H OUTPUT HEX BYTE AS ASCII
JOUT2H  LBRA OUT2H    ; OUTPUT HEX BYTE AS ASCII
*
*
PRTIX  LDX  #MSG14 POINT TO MSG "IX="
PRTIX   LDX  #MSG14   ; POINT TO MSG "IX="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDX  4,U      $FCE6
        LDX  4,U      ; $FCE6
       BRA  JOUT4H
       BRA  JOUT4H
*
*
PRTIY  LDX  #MSG13 POINT TO MSG "IY="
PRTIY   LDX  #MSG13   ; POINT TO MSG "IY="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDX  6,U
       LDX  6,U
       BRA  JOUT4H
       BRA  JOUT4H
*
*
PRTPC  LDX  #MSG11 POINT TO MSG "PC="
PRTPC   LDX  #MSG11   ; POINT TO MSG "PC="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDX  10,U
       LDX  10,U
       BRA  JOUT4H
       BRA  JOUT4H
*
*
PRTA   LDX  #MSG16 POINT TO MSG "A="
PRTA    LDX  #MSG16   ; POINT TO MSG "A="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDA  1,U
       LDA  1,U
       BRA  JOUT2H OUTPUT HEX BYTE AS ASCII
        BRA  JOUT2H   ; OUTPUT HEX BYTE AS ASCII
*
*
PRTB   LDX  #MSG17 POINT TO MSG "B="
PRTB    LDX  #MSG17   ; POINT TO MSG "B="
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDA  2,U
       LDA  2,U
       BRA  JOUT2H OUTPUT HEX BYTE AS ASCII
        BRA  JOUT2H   ; OUTPUT HEX BYTE AS ASCII
*
*
PRTCC  LDX  #MSG18 POINT TO MSG "CC:"
PRTCC   LDX  #MSG18   ; POINT TO MSG "CC:"
       BSR  PDATA  PRINT MSG
        BSR  PDATA    ; PRINT MSG
       LDA  ,U
       LDA  ,U
       LDX  #MSG19 POINT TO MSG "EFHINZVC"
        LDX  #MSG19   ; POINT TO MSG "EFHINZVC"
       LBRA BIASCI OUTPUT IN BINARY/ASCII FORMAT
        LBRA BIASCI   ; OUTPUT IN BINARY/ASCII FORMAT
*
*
* "R" DISPLAY REGISTERS
* "R" DISPLAY REGISTERS
*
*
REGSTR  LDX  #MSG5   POINT TO MSG " - "
REGSTR  LDX  #MSG5    ; POINT TO MSG " - "
        LBSR PSTRNG  PRINT MSG
        LBSR PSTRNG   ; PRINT MSG
        BSR PRTSP   $FCBF
        BSR  PRTSP    ; $FCBF
        BSR PRTUS   $FCCA
        BSR  PRTUS    ; $FCCA
        BSR PRTDP   $FCD5
        BSR  PRTDP    ; $FCD5
        BSR PRTIX   $FCE0
        BSR  PRTIX    ; $FCE0
        BSR PRTIY   $FCEB
        BSR  PRTIY    ; $FCEB
        LDX  #MSG5   POINT TO MSG " - "
        LDX  #MSG5    ; POINT TO MSG " - "
        LBSR PSTRNG  PRINT MSG
        LBSR PSTRNG   ; PRINT MSG
        BSR PRTPC   $FCF5
        BSR  PRTPC    ; $FCF5
        BSR PRTA    $FCFF
        BSR  PRTA     ; $FCFF
        BSR PRTB    $FD09
        BSR  PRTB     ; $FD09
        BRA PRTCC   $FD13
        BRA  PRTCC    ; $FD13
*
*
* THE FOLLOWING ROUTINE LOOPS WAITING FOR THE
* THE FOLLOWING ROUTINE LOOPS WAITING FOR THE
* OPERATOR TO INPUT TWO VALID HEX ADDRESSES.
* OPERATOR TO INPUT TWO VALID HEX ADDRESSES.
* THE FIRST ADDRESS INPUT IS RETURNED IN "IY".
* THE FIRST ADDRESS INPUT IS RETURNED IN "IY".
* THE SECOND IS RETURNED IN "IX". THE "V" BIT
* THE SECOND IS RETURNED IN "IX". THE "V" BIT
* IN THE C-CODE REG. IS SET IF AN INVALID HEX
* IN THE C-CODE REG. IS SET IF AN INVALID HEX
* ADDRESS IS INPUT.
* ADDRESS IS INPUT.
*
*
IN2ADR BSR IN1ADR GET FIRST ADDRESS
IN2ADR  BSR  IN1ADR   ; GET FIRST ADDRESS
       BVS NOTHEX EXIT IF NOT VALID HEX
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
       TFR  X,Y SAVE FIRST ADDR. IN "IY"
        TFR  X,Y      ; SAVE FIRST ADDR. IN "IY"
       LDA #'-
       LDA #'-
       LBSR OUTCH PRINT " - "
        LBSR OUTCH    ; PRINT " - "
*
*
* THE FOLLOWING ROUTINE LOOPS WAITING FOR THE
* THE FOLLOWING ROUTINE LOOPS WAITING FOR THE
* OPERATOR TO INPUT ONE VALID HEX ADDRESS. THE
* OPERATOR TO INPUT ONE VALID HEX ADDRESS. THE
* ADDRESS IS RETURNED IN THE "X" REGISTER.
* ADDRESS IS RETURNED IN THE "X" REGISTER.
*
*
IN1ADR BSR BYTE INPUT BYTE (2 HEX CHAR)
IN1ADR  BSR  BYTE     ; INPUT BYTE (2 HEX CHAR)
       BVS NOTHEX EXIT IF NOT VALID HEX
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
       TFR  D,X
       TFR  D,X
       BSR BYTE INPUT BYTE (2 HEX CHAR)
        BSR  BYTE     ; INPUT BYTE (2 HEX CHAR)
       BVS NOTHEX
       BVS NOTHEX
       PSHS X
       PSHS X
       STA  1,S
       STA  1,S
       PULS X,PC
       PULS X,PC
*
*
***** INPUT BYTE (2 HEX CHAR.) *****
***** INPUT BYTE (2 HEX CHAR.) *****
*
*
BYTE   BSR INHEX GET HEX LEFT
BYTE    BSR  INHEX    ; GET HEX LEFT
       BVS NOTHEX EXIT IF NOT VALID HEX
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
       ASLA   ;
       ASLA   ;
       ASLA   ;
       ASLA   ;
       ASLA   ; SHIFT INTO LEFT NIBBLE
       ASLA   ; SHIFT INTO LEFT NIBBLE
       ASLA   ;
       ASLA   ;
       TFR  A,B PUT HEXL IN "B"
        TFR  A,B      ; PUT HEXL IN "B"
       BSR INHEX GET HEX RIGHT
        BSR  INHEX    ; GET HEX RIGHT
       BVS NOTHEX EXIT IF NOT VALID HEX
        BVS  NOTHEX   ; EXIT IF NOT VALID HEX
       PSHS B PUSH HEXL ON STACK
        PSHS B        ; PUSH HEXL ON STACK
       ADDA ,S+ ADD HEXL TO HEXR AND ADJ. STK
        ADDA ,S+      ; ADD HEXL TO HEXR AND ADJ. STK
       RTS  RETURN WITH HEX L&R IN "A"
        RTS           ; RETURN WITH HEX L&R IN "A"
*
*
*
*
INHEX  BSR ECHON INPUT ASCII CHAR.
INHEX   BSR  ECHON    ; INPUT ASCII CHAR.
       CMPA #'0 IS IT > OR = "0" ?
        CMPA #'0      ; IS IT > OR = "0" ?
       BCS NOTHEX IF LESS IT AIN'T HEX
        BCS  NOTHEX   ; IF LESS IT AIN'T HEX
       CMPA #'9 IS IT < OR = "9" ?
        CMPA #'9      ; IS IT < OR = "9" ?
       BHI INHEXA IF > MAYBE IT'S ALPHA
        BHI  INHEXA   ; IF > MAYBE IT'S ALPHA
       SUBA #$30 ASCII ADJ. NUMERIC
        SUBA #$30     ; ASCII ADJ. NUMERIC
       RTS  ;
       RTS  ;
*
*
*
*
INHEXA CMPA #'A IS IT > OR = "A"
INHEXA  CMPA #'A      ; IS IT > OR = "A"
       BCS NOTHEX IF LESS IT AIN'T HEX
        BCS  NOTHEX   ; IF LESS IT AIN'T HEX
       CMPA #'F IS IT < OR = "F" ?
        CMPA #'F      ; IS IT < OR = "F" ?
       BHI INHEXL IF > IT AIN'T HEX
        BHI  INHEXL   ; IF > IT AIN'T HEX
       SUBA #$37 ASCII ADJ. ALPHA
        SUBA #'A-10   ; ($37) ASCII ADJ. ALPHA
       RTS  ;
       RTS  ;
*
*
INHEXL CMPA #'a IS IT > OR = "a"
INHEXL  CMPA #'a      ; IS IT > OR = "a"
       BCS NOTHEX IF LESS IT AIN'T HEX
        BCS  NOTHEX   ; IF LESS IT AIN'T HEX
       CMPA #'f IS IT < "f"
        CMPA #'f      ; IS IT < "f"
       BHI NOTHEX IF > IT AIN'T HEX
        BHI  NOTHEX   ; IF > IT AIN'T HEX
       SUBA #$57 ADJUST TO LOWER CASE
        SUBA #'a-10   ; ($57) ADJUST TO LOWER CASE
       RTS  ;
       RTS  ;
*
*
*
*
NOTHEX ORCC #2 SET (V) FLAG IN C-CODES REGISTER
NOTHEX  ORCC #2       ; SET (V) FLAG IN C-CODES REGISTER
       RTS  ;
       RTS  ;
*
*
*
*
OUT4H  PSHS X PUSH X-REG. ON THE STACK
OUT4H   PSHS X        ; PUSH X-REG. ON THE STACK
       PULS A POP MS BYTE OF X-REG INTO A-ACC.
        PULS A        ; POP MS BYTE OF X-REG INTO A-ACC.
       BSR OUTHL OUTPUT HEX LEFT
        BSR  OUTHL    ; OUTPUT HEX LEFT
       PULS A POP LS BYTE OF X-REG INTO A-ACC.
        PULS A        ; POP LS BYTE OF X-REG INTO A-ACC.
OUTHL  EQU *
OUTHL  EQU *
OUT2H  PSHS A SAVE IT BACK ON STACK
OUT2H   PSHS A        ; SAVE IT BACK ON STACK
       LSRA CONVERT UPPER HEX NIBBLE TO ASCII
        LSRA          ; CONVERT UPPER HEX NIBBLE TO ASCII
       LSRA  ;
       LSRA  ;
       LSRA  ;
       LSRA  ;
       LSRA  ;
       LSRA  ;
       BSR XASCII PRINT HEX NIBBLE AS ASCII
        BSR  XASCII   ; PRINT HEX NIBBLE AS ASCII
OUTHR  PULS A CONVERT LOWER HEX NIBBLE TO ASCII
OUTHR   PULS A        ; CONVERT LOWER HEX NIBBLE TO ASCII
       ANDA #$0F STRIP LEFT NIBBLE
        ANDA #$0F     ; STRIP LEFT NIBBLE
XASCII ADDA #$30 ASCII ADJ
XASCII  ADDA #$30     ; ASCII ADJ
       CMPA #$39 IS IT < OR = "9" ?
        CMPA #$39     ; IS IT < OR = "9" ?
       BLE  OUTC IF LESS, OUTPUT IT
        BLE  OUTC     ; IF LESS, OUTPUT IT
       ADDA #7 IF > MAKE ASCII LETTER
        ADDA #7       ; IF > MAKE ASCII LETTER
OUTC   BRA  OUTCH OUTPUT CHAR
OUTC    BRA OUTCH     ;  OUTPUT CHAR
*
*
* BINARY / ASCII --- THIS ROUTINE
* BINARY / ASCII --- THIS ROUTINE
* OUTPUTS A BYTE IN ENHANCED
* OUTPUTS A BYTE IN ENHANCED
* BINARY FORMAT. THE ENHANCEMENT
* BINARY FORMAT. THE ENHANCEMENT
* IS DONE BY SUBSTITUTING ASCII
* IS DONE BY SUBSTITUTING ASCII
* LETTERS FOR THE ONES IN THE BYTE.
* LETTERS FOR THE ONES IN THE BYTE.
* THE ASCII ENHANCEMENT LETTERS
* THE ASCII ENHANCEMENT LETTERS
* ARE OBTAINED FROM THE STRING
* ARE OBTAINED FROM THE STRING
* POINTED TO BY THE INDEX REG. "X".
* POINTED TO BY THE INDEX REG. "X".
*
*
BIASCI PSHS A SAVE "A" ON STACK
BIASCI  PSHS A        ; SAVE "A" ON STACK
       LDB  #8 PRESET LOOP# TO BITS PER BYTE
        LDB  #8       ; PRESET LOOP# TO BITS PER BYTE
OUTBA  LDA ,X+ GET LETTER FROM STRING
OUTBA   LDA  ,X+      ; GET LETTER FROM STRING
       ASL  ,S TEST BYTE FOR "1" IN B7
        ASL  ,S       ; TEST BYTE FOR "1" IN B7
       BCS PRTBA IF ONE PRINT LETTER
        BCS  PRTBA    ; IF ONE PRINT LETTER
       LDA #'- IF ZERO PRINT "-"
        LDA  #'-      ; IF ZERO PRINT "-"
PRTBA  BSR OUTCH PRINT IT
PRTBA   BSR  OUTCH    ; PRINT IT
       BSR OUT1S PRINT SPACE
        BSR  OUT1S    ; PRINT SPACE
       DECB SUB 1 FROM #BITS YET TO PRINT
        DECB          ; SUB 1 FROM #BITS YET TO PRINT
       BNE OUTBA
       BNE OUTBA
       PULS A,PC
       PULS A,PC
*
*
       IFD EXTOPT
       IFD EXTOPT
*
*
Line 1279... Line 1292...
*
*
USRCMD JMP [MONEXT+EXTCMD]
USRCMD JMP [MONEXT+EXTCMD]
       ENDIF EXTOPT
       ENDIF EXTOPT
*
*
*
*
ECHON  TST  ECHO IS ECHO REQUIRED ?
ECHON   TST  ECHO     ; IS ECHO REQUIRED ?
       BEQ  INCH ECHO NOT REQ. IF CLEAR
        BEQ  INCH     ; ECHO NOT REQ. IF CLEAR
*
*
* INCHE
* INCHE
*
*
* ---GETS CHARACTER FROM TERMINAL AND
* GETS CHARACTER FROM TERMINAL AND
* ECHOS SAME. THE CHARACTER IS RETURNED
* ECHOS SAME. THE CHARACTER IS RETURNED
* IN THE "A" ACCUMULATOR WITH THE PARITY
* IN THE "A" ACCUMULATOR WITH THE PARITY
* BIT MASKED OFF. ALL OTHER REGISTERS
* BIT MASKED OFF. ALL OTHER REGISTERS
* ARE PRESERVED.
* ARE PRESERVED.
*
*
INCHE  BSR INCH GET CHAR FROM TERMINAL
INCHE   BSR  INCH     ; GET CHAR FROM TERMINAL
       ANDA #$7F      STRIP PARITY FROM CHAR.
        ANDA #$7F     ; STRIP PARITY FROM CHAR.
       BRA  OUTCH     ECHO CHAR TO TERMINAL
        BRA  OUTCH    ; ECHO CHAR TO TERMINAL
*
*
* INCH
* INCH
*
*
* GET CHARACTER FROM TERMINAL. RETURN
* GET CHARACTER FROM TERMINAL. RETURN
* CHARACTER IN "A" ACCUMULATOR AND PRESERVE
* CHARACTER IN "A" ACCUMULATOR AND PRESERVE
* ALL OTHER REGISTERS. THE INPUT CHARACTER
* ALL OTHER REGISTERS. THE INPUT CHARACTER
* IS 8 BITS AND IS NOT ECHOED.
* IS 8 BITS AND IS NOT ECHOED.
*
*
*
*
INCH   PSHS X SAVE IX
INCH    PSHS X        ; SAVE IX
GETSTA LDX  CPORT POINT TO TERMINAL PORT
        IFD  HFCOPT
       LDA  ,X  FETCH PORT STATUS
        LDA  #$11     ; SET RTS* LOW, REQUEST FAR END TO TX
       BITA #1 TEST READY BIT, RDRF ?
        STA  [CPORT]
 
        ENDIF HFCOPT
 
GETSTA  LDX  CPORT    ; POINT TO TERMINAL PORT
 
        LDA  ,X       ; FETCH PORT STATUS
 
        BITA #1       ; TEST READY BIT, RDRF ?
       IFD  PS2OPT
       IFD  PS2OPT
       BNE GETST1
       BNE GETST1
       LDX  #PS2KBD
       LDX  #PS2KBD
       LDA  ,X
       LDA  ,X
       BITA #1
       BITA #1
       ENDIF PS2OPT
       ENDIF PS2OPT
       BEQ  GETSTA IF NOT RDY, THEN TRY AGAIN
        BEQ  GETSTA   ; IF NOT RDY, THEN TRY AGAIN
GETST1 LDA  1,X FETCH CHAR
GETST1  EQU  *
       PULS X,PC RESTORE IX
        IFD  HFCOPT
 
        LDA  #$51     ; SET RTS* HIGH, STOP FAR END FROM TXING, UNTIL NEXT INPUT
 
        STA  [CPORT]
 
        ENDIF HFCOPT
 
        LDA  1,X      ; FETCH CHAR
 
        PULS X,PC     ; RESTORE IX
*
*
* INCHEK
* INCHEK
*
*
* CHECK FOR A CHARACTER AVAILABLE FROM
* CHECK FOR A CHARACTER AVAILABLE FROM
* THE TERMINAL. THE SERIAL PORT IS CHECKED
* THE TERMINAL. THE SERIAL PORT IS CHECKED
* FOR READ READY. ALL REGISTERS ARE
* FOR READ READY. ALL REGISTERS ARE
* PRESERVED, AND THE "Z" BIT WILL BE
* PRESERVED, AND THE "Z" BIT WILL BE
* CLEAR IF A CHARACTER CAN BE READ.
* CLEAR IF A CHARACTER CAN BE READ.
*
*
*
*
INCHEK  PSHS A SAVE A ACCUM.
INCHEK  PSHS A        ; SAVE A ACCUM
        LDA  [CPORT] FETCH PORT STATUS
        IFD  HFCOPT
        BITA #1 TEST READY BIT, RDRF ?
        LDA  #$11     ; SET RTS* LOW, REQUEST FAR END TO TX
 
        STA  [CPORT]
 
        ENDIF HFCOPT
 
        LDA  [CPORT]  ; FETCH PORT STATUS
 
        BITA #1       ; TEST READY BIT, RDRF ?
        IFD PS2OPT
        IFD PS2OPT
        BNE  INCHEK1
        BNE  INCHEK1
        LDA  PS2KBD
        LDA  PS2KBD
        BITA #1 TEST READY BIT< RDRF ?
        BITA #1       ; TEST READY BIT< RDRF ?
        ENDIF PS2OPT
        ENDIF PS2OPT
INCHEK1 PULS A,PC RESTORE A ACCUM.
INCHEK1 PULS A,PC     ; RESTORE A ACCUM.
*
*
OUT2S BSR OUT1S OUTPUT 2 SPACES
OUT2S   BSR  OUT1S    ; OUTPUT 2 SPACES
OUT1S LDA  #$20  OUTPUT 1 SPACE
OUT1S   LDA  #$20     ; OUTPUT 1 SPACE
*
*
*
*
* OUTCH
* OUTCH
*
*
* OUTPUT CHARACTER TO TERMINAL.
* OUTPUT CHARACTER TO TERMINAL.
Line 1352... Line 1378...
        BSR  VOUTCH
        BSR  VOUTCH
        ENDIF VDUOPT
        ENDIF VDUOPT
        IFD  DG640OPT
        IFD  DG640OPT
        BSR  VOUTCH
        BSR  VOUTCH
        ENDIF DG640OPT
        ENDIF DG640OPT
AOUTCH  PSHS A,X    SAVE A ACCUM AND IX
AOUTCH  PSHS A,X      ; SAVE A ACCUM AND IX
        LDX  CPORT  GET ADDR. OF TERMINAL
        LDX  CPORT    ; GET ADDR. OF TERMINAL
FETSTA  LDA  ,X     FETCH PORT STATUS
FETSTA  LDA  ,X       ; FETCH PORT STATUS
        BITA #2     TEST TDRE, OK TO XMIT ?
        BITA #2       ; TEST TDRE, OK TO XMIT ?
        BEQ  FETSTA IF NOT LOOP UNTIL RDY
        BEQ  FETSTA   ; IF NOT LOOP UNTIL RDY
        PULS A      GET CHAR. FOR XMIT
        BITA #8       ; CLEAR TO SEND ?
        STA  1,X    XMIT CHAR.
        BNE  FETSTA   ; NO, LOOP UNTIL CLEAR
        PULS X,PC   RESTORE IX
        PULS A        ; GET CHAR. FOR XMIT
 
        STA  1,X      ; XMIT CHAR.
 
        PULS X,PC     ; RESTORE IX
*
*
* IO INITIALIZATION
* IO INITIALIZATION
*
*
IOINIZ  EQU  *
IOINIZ  EQU  *
        IFD  VDUOPT
        IFD  VDUOPT
        BSR  VINIZ
        BSR  VINIZ
        ENDIF VDUOPT
        ENDIF VDUOPT
        IFD  DG640OPT
        IFD  DG640OPT
        BSR  VINIZ
        BSR  VINIZ
        ENDIF DG640OPT
        ENDIF DG640OPT
ACINIZ  LDX  CPORT  POINT TO CONTROL PORT ADDRESS
ACINIZ  LDX  CPORT    ; POINT TO CONTROL PORT ADDRESS
        LDA  #3     RESET ACIA PORT CODE
        LDA  #3       ; RESET ACIA PORT CODE
        STA  ,X     STORE IN CONTROL REGISTER
        STA  ,X       ; STORE IN CONTROL REGISTER
        LDA  #$11   SET 8 DATA, 2 STOP AN 0 PARITY
        LDA  #$51     ; SET 8 DATA, 2 STOP AN 0 PARITY RTS* HIGH
        STA  ,X     STORE IN CONTROL REGISTER
        STA  ,X       ; STORE IN CONTROL REGISTER
        TST  1,X    ANYTHING IN DATA REGISTER?
        TST  1,X      ; ANYTHING IN DATA REGISTER?
        LDA  #$FF   TURN ON ECHO FLAG
        LDA  #$FF     ; TURN ON ECHO FLAG
        STA  ECHO
        STA  ECHO
        RTS
        RTS
*
*
        IFD VDUOPT
        IFD VDUOPT
*
*
Line 1395... Line 1423...
*               INITIALIZE EMULATOR               *
*               INITIALIZE EMULATOR               *
***************************************************
***************************************************
*
*
VINIZ   LDX    #VDU
VINIZ   LDX    #VDU
        LDD    #0
        LDD    #0
        STD    COLADX    AND ROWADX
        STD  COLADX   ; AND ROWADX
        STA    VDUCOL,X
        STA    VDUCOL,X
        STB    VDUROW,X
        STB    VDUROW,X
        STB    VDUOFF,X
        STB    VDUOFF,X
        STD    NEWROW    AND ESCFLG
        STD  NEWROW   ; AND ESCFLG
        LDB    #$02
        LDB    #$02
        STB    VDUATT,X
        STB    VDUATT,X
        CLR    ESCFLG
        CLR    ESCFLG
        LDA    #$1B      SEND ESCAPE
        LDA  #$1B     ; SEND ESCAPE
        BSR    VOUTCH
        BSR    VOUTCH
        LDA    #'Y       CLEAR TO END OF SCREEN
        LDA  #'Y      ; CLEAR TO END OF SCREEN
*
*
** VIDEO OUTPUT ROUTINE
** VIDEO OUTPUT ROUTINE
*
*
VOUTCH  PSHS   A,B,X     SAVE REGISTERS
VOUTCH  PSHS A,B,X    ; SAVE REGISTERS
        LDX    #VDU      POINT TO VDU REGISTERS
        LDX  #VDU     ; POINT TO VDU REGISTERS
*
*
** CHECK FOR ESCAPE SEQUENCE
** CHECK FOR ESCAPE SEQUENCE
*
*
        TST    ESCFLG    ESCAPE ACTIVE?
        TST  ESCFLG   ; ESCAPE ACTIVE?
        BEQ    SOROU1    BRANCH IF NOT
        BEQ  SOROU1   ; BRANCH IF NOT
        BSR    ESCAPE    ELSE DO ESCAPE
        BSR  ESCAPE   ; ELSE DO ESCAPE
        BRA    RETURN    AND RETURN
        BRA  RETURN   ; AND RETURN
*
*
** CHECK FOR CONTROL CHARACTERS
** CHECK FOR CONTROL CHARACTERS
*
*
SOROU1  CMPA   #$20      CONTROL CODES?
SOROU1  CMPA #$20     ; CONTROL CODES?
        BHS    SOROU2
        BHS    SOROU2
        BSR    CONTRL    BRANCH IF SO
        BSR  CONTRL   ; BRANCH IF SO
        BRA    RETURN
        BRA    RETURN
*
*
** OUTPUT TEXT CHARACTER
** OUTPUT TEXT CHARACTER
*
*
SOROU2  STAA   VDUCHR,X  DISPLAY CHARACTER
SOROU2  STA  VDUCHR,X ; DISPLAY CHARACTER
        LBSR   NEWCOL    UPDATE COLUMN
        LBSR NEWCOL   ; UPDATE COLUMN
*
*
** DISPLAY CURSOR AND RETURN
** DISPLAY CURSOR AND RETURN
*
*
RETURN  PULS   A,B,X,PC  RESTORE REGISTERS AND RETURN
RETURN  PULS A,B,X,PC ; RESTORE REGISTERS AND RETURN
*
*
***************************************************
***************************************************
*              CONTROL CODE HANDLERS              *
*              CONTROL CODE HANDLERS              *
***************************************************
***************************************************
*
*
CONTRL  CMPA   #$08      CTRL H - BACKSPACE ?
CONTRL  CMPA #$08     ; CTRL H - BACKSPACE ?
        LBEQ   BACKSP
        BEQ  BACKSP
        CMPA   #$1B      ESCAPE SEQUENCE?
        CMPA #$1B     ; ESCAPE SEQUENCE?
        LBEQ   SETESC
        BEQ  SETESC
        CMPA   #$1A      CTRL Z - Clear Screen
        CMPA #$1A     ; CTRL Z - Clear Screen
        LBEQ   CLRSCR
        LBEQ   CLRSCR
        CMPA   #$16      CTRL ^ - Home
        CMPA #$16     ; CTRL ^ - Home
        LBEQ   HOME
        BEQ  HOME
        CMPA   #$D       CTRL M - RETURN?
        CMPA #$0D     ; CTRL M - RETURN?
        LBEQ   CRETN
        LBEQ   CRETN
        CMPA   #$0C      CTRL L - CHAR RIGHT
        CMPA #$0C     ; CTRL L - CHAR RIGHT
        LBEQ   CHRIGHT
        BEQ  CHRIGHT
        CMPA   #$0B      CTRL K - MOVE UP ONE LINE
        CMPA #$0B     ; CTRL K - MOVE UP ONE LINE
        LBEQ   LINEUP
        BEQ  LINEUP
        CMPA   #$0A      CTRL J - LINE FEED
        CMPA #$0A     ; CTRL J - LINE FEED
        BNE    RETESC    NONE OF THESE, RETURN
        BNE  RETESC   ; NONE OF THESE, RETURN
*
*
***************************************** LINE FEED
***************************************** LINE FEED
*
*
LINEFD  LDD    COLADX    GET CURRENT COLUMN AND ROW
LINEFD  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
        INCB             BUMP ROW
        INCB          ; BUMP ROW
        CMPB   #NUMLIN   SCROLL TIME?
        CMPB #NUMLIN  ; SCROLL TIME?
        LBNE   NEWCUR    POSITION CURSOR IF NOT
        BNE  NEWCUR   ; POSITION CURSOR IF NOT
        LBRA   SCROLL    ELSE SCROLL IT
        LBRA SCROLL   ; ELSE SCROLL IT
*
*
***************************************** LINE FEED
***************************************** LINE FEED
*
*
LINEUP  LDD    COLADX    GET CURRENT COLUMN AND ROW
LINEUP  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
        TSTB             AT TOP OF SCREEN ?
        TSTB          ; AT TOP OF SCREEN ?
        LBEQ   RETESC    Yes, Ignore
        BEQ  RETESC   ; Yes, Ignore
        DECB             No, Decrement ROW
        DECB          ; No, Decrement ROW
        LBRA   NEWCUR    POSITION CURSOR
        BRA  NEWCUR   ; POSITION CURSOR
*
*
*********************************** BACK SPACE
*********************************** BACK SPACE
*
*
BACKSP  LDA    COLADX
BACKSP  LDA    COLADX
        BEQ    RETESC      RETURN
        BEQ  RETESC   ; RETURN
        DECA
        DECA
        LBRA   POSCOL    POSITION CURSOR
        BRA  POSCOL   ; POSITION CURSOR
*
*
*********************************** CURSOR RIGHT
*********************************** CURSOR RIGHT
*
*
CHRIGHT LDA    COLADX
CHRIGHT LDA    COLADX
        INCA
        INCA
        CMPA   #LINLEN
        CMPA   #LINLEN
        LBEQ   RETESC
        BEQ  RETESC
        LBRA   POSCOL
        BRA  POSCOL
*
*
*********************************** CURSOR RIGHT
*********************************** CURSOR RIGHT
*
*
HOME    LDD    #0        HOME - POSITION TOP OF SCREEN
HOME    LDD  #0       ; HOME - POSITION TOP OF SCREEN
        LBRA    NEWCUR
        BRA  NEWCUR
*
*
***************************************************
***************************************************
*                 ESCAPE HANDLERS                 *
*                 ESCAPE HANDLERS                 *
***************************************************
***************************************************
*
*
ESCAPE  LDAB   ESCFLG    GET FLAG
ESCAPE  LDB  ESCFLG   ; GET FLAG
        CMPB   #'=       SETTING CURSOR?
        CMPB #'=      ; SETTING CURSOR?
        BEQ    ESCCUR    BRANCH IF SO
        BEQ  ESCCUR   ; BRANCH IF SO
        CMPA   #'Y       CLEAR TO END OF SCREEN?
        CMPA #'Y      ; CLEAR TO END OF SCREEN?
        LBEQ   ESCCLS
        BEQ  ESCCLS
        CMPA   #'T       CLEAR TO END OF LINE?
        CMPA #'T      ; CLEAR TO END OF LINE?
        BEQ   ESCCLL
        BEQ   ESCCLL
        CMPA   #'=       STARTING CURSOR SET?
        CMPA #'=      ; STARTING CURSOR SET?
        BNE    CLRESC    BRANCH IF NOT
        BNE  CLRESC   ; BRANCH IF NOT
*
*
***************************** START ESCAPE SEQUENCE
***************************** START ESCAPE SEQUENCE
*
*
SETESC  STAA   ESCFLG    ELSE START CURSORING
SETESC  STA  ESCFLG   ; ELSE START CURSORING
        RTS              AND RETURN
        RTS           ; AND RETURN
*
*
CLRESC  CLR    ESCFLG    NO OTHERS SUPPORTED
CLRESC  CLR  ESCFLG   ; NO OTHERS SUPPORTED
RETESC  RTS              SO RETURN
RETESC  RTS           ; SO RETURN
*
*
********************************* SET SCREEN CURSOR
********************************* SET SCREEN CURSOR
*
*
ESCCUR  TST    NEWROW    ROW SET?
ESCCUR  TST  NEWROW   ; ROW SET?
        BNE    ESCCU1    BRANCH IF SO
        BNE  ESCCU1   ; BRANCH IF SO
        STAA   NEWROW    ELSE SET NEW ROW
        STA  NEWROW   ; ELSE SET NEW ROW
        RTS              AND RETURN
        RTS           ; AND RETURN
*
*
ESCCU1  CLR    ESCFLG
ESCCU1  CLR    ESCFLG
        SUBA   #$20      ADJUST COLUMN ADDRESS
        SUBA #$20     ; ADJUST COLUMN ADDRESS
        CMPA   #LINLEN-1 CHECK FOR ACCEPTABLE COLUM
        CMPA #LINLEN-1 ;CHECK FOR ACCEPTABLE COLUM
        BHI    RETESC    NOT OK, DO NOTHING
        BHI  RETESC   ; NOT OK, DO NOTHING
*
*
ESCCU2  LDAB   NEWROW
ESCCU2  LDB  NEWROW
        CLR    NEWROW
        CLR    NEWROW
        SUBB   #$20      ADJUST TO ROW ADDRESS
        SUBB #$20     ; ADJUST TO ROW ADDRESS
        CMPB   #NUMLIN-1 CHECK FOR ACCEPTABLE ROW
        CMPB #NUMLIN-1 ; CHECK FOR ACCEPTABLE ROW
        BHI    RETESC    ELSE RETURN DOING NOTHING
        BHI  RETESC   ; ELSE RETURN DOING NOTHING
        BRA    NEWCUR    GO SET NEW CURSOR IF SO
        BRA  NEWCUR   ; GO SET NEW CURSOR IF SO
*
*
****************** CLEAR FROM CURSOR TO END OF LINE
****************** CLEAR FROM CURSOR TO END OF LINE
CLRSCR  LDD    #0        CLEAR FROM TOP OF SCREEN
*
 
CLRSCR  LDD  #0       ; CLEAR FROM TOP OF SCREEN
        BSR    NEWCUR
        BSR    NEWCUR
ESCCLL  LDA    COLADX
ESCCLL  LDA    COLADX
        LDB    #$20      AND CLEAR CHAR
        LDB  #$20     ; AND CLEAR CHAR
ESCCL1  STB    VDUCHR,X  DISPLAY TEXT
ESCCL1  STB  VDUCHR,X ; DISPLAY TEXT
        INCA
        INCA
        STA    VDUCOL,X
        STA    VDUCOL,X
        CMPA   #LINLEN   UNTIL END OF LINE
        CMPA #LINLEN  ; UNTIL END OF LINE
        BNE    ESCCL1
        BNE    ESCCL1
        CLR    ESCFLG
        CLR    ESCFLG
        RTS
        RTS
*
*
*********************************** CARRIAGE RETURN
*********************************** CARRIAGE RETURN
*
*
CRETN   CLRA               SET COLUMN ZERO
CRETN   CLRA          ; SET COLUMN ZERO
POSCOL  LDB    ROWADX    GET CURRENT ROW
POSCOL  LDB  ROWADX   ; GET CURRENT ROW
*
*
*********** GENERATE NEW CURSOR POSITION AND RETURN
*********** GENERATE NEW CURSOR POSITION AND RETURN
*
*
NEWCUR  STD    COLADX    SAVE NEW ROW AND COLUMN
NEWCUR  STD  COLADX   ; SAVE NEW ROW AND COLUMN
        STA    VDUCOL,X  SET NEW COLUMN
        STA  VDUCOL,X ; SET NEW COLUMN
        STB    VDUROW,X  SET NEW ROW
        STB  VDUROW,X ; SET NEW ROW
        RTS              AND RETURN
        RTS           ; AND RETURN
*
*
********************* UPDATE CURRENT COLUMN AND ROW
********************* UPDATE CURRENT COLUMN AND ROW
*
*
NEWCOL  LDD    COLADX    GET ROW AND COLUMN
NEWCOL  LDD  COLADX   ; GET ROW AND COLUMN
        INCA             BUMP COLUMN
        INCA          ; BUMP COLUMN
        CMPA   #LINLEN   ROLL?
        CMPA #LINLEN  ; ROLL?
        BNE    NEWCUR    BRANCH IF NOT
        BNE  NEWCUR   ; BRANCH IF NOT
        CLRA             ELSE RESET TO ZERO
        CLRA          ; ELSE RESET TO ZERO
        INCB             AND BUMP ROW
        INCB          ; AND BUMP ROW
        CMPB   #NUMLIN
        CMPB   #NUMLIN
        BNE    NEWCUR
        BNE    NEWCUR
        DECB             BOTTOM ROW
        DECB          ; BOTTOM ROW
        BSR    NEWCUR
        BSR    NEWCUR
*
*
********************************* SCROLL THE SCREEN
********************************* SCROLL THE SCREEN
*
*
SCROLL  LDB    VDUOFF,X
SCROLL  LDB    VDUOFF,X
Line 1582... Line 1611...
        CLRB
        CLRB
SCROL1  STB    VDUOFF,X
SCROL1  STB    VDUOFF,X
*
*
**************** CLEAR FROM CURSOR TO END OF SCREEN
**************** CLEAR FROM CURSOR TO END OF SCREEN
*
*
ESCCLS  LDB    COLADX    GET CURSOR
ESCCLS  LDB  COLADX   ; GET CURSOR
        LDA    #$20      GET A SPACE
        LDA  #$20     ; GET A SPACE
ESCCLS1 STB    COLADX
ESCCLS1 STB    COLADX
        STB    VDUCOL,X
        STB    VDUCOL,X
        STA    VDUCHR,X
        STA    VDUCHR,X
        INCB
        INCB
        CMPB   #LINLEN
        CMPB   #LINLEN
Line 1616... Line 1645...
* FOR HARD-WIRED MEMORY-MAPPED DISPLAYS USING THE *
* FOR HARD-WIRED MEMORY-MAPPED DISPLAYS USING THE *
* HIGH ORDER BIT OF EACH BYTE FOR  REVERSE  VIDEO *
* HIGH ORDER BIT OF EACH BYTE FOR  REVERSE  VIDEO *
* CURSORING  (SUCH  AS THE THOMAS INSTRUMENTATION *
* CURSORING  (SUCH  AS THE THOMAS INSTRUMENTATION *
* 16x64 BOARD).                                   *
* 16x64 BOARD).                                   *
***************************************************
***************************************************
 
*
***************************************************
***************************************************
*               INITIALIZE EMULATOR               *
*               INITIALIZE EMULATOR               *
***************************************************
***************************************************
 
*
VINIZ   LDX    #0
VINIZ   LDX    #0
        STX    COLADX    AND ROWADX
        STX  COLADX   ; AND ROWADX
        STX    NEWROW    AND ESCFLG
        STX  NEWROW   ; AND ESCFLG
        LDX    #SCREEN   POINT TO SCREEN
        LDX  #SCREEN  ; POINT TO SCREEN
        STX    CURSOR    SET PROGRAM CURSOR
        STX  CURSOR   ; SET PROGRAM CURSOR
        LDA    #$1B      SEND ESCAPE
        LDA  #$1B     ; SEND ESCAPE
        BSR    VOUTCH
        BSR    VOUTCH
        LDA    #'Y       CLEAR TO END OF SCREEN
        LDA  #'Y      ; CLEAR TO END OF SCREEN
*
*
** VIDEO OUTPUT ROUTINE
** VIDEO OUTPUT ROUTINE
*
*
VOUTCH  PSHS   A,B,X     SAVE REGISTERS
VOUTCH  PSHS A,B,X    ; SAVE REGISTERS
*
*
** CLEAR CURSOR
** CLEAR CURSOR
 
*
        LDX    CURSOR
        LDX    CURSOR
        LDB   0,X
        LDB   0,X
        ANDB   #$7F
        ANDB   #$7F
        STB   0,X
        STB   0,X
*
*
** CHECK FOR ESCAPE SEQUENCE
** CHECK FOR ESCAPE SEQUENCE
        TST    ESCFLG    ESCAPE ACTIVE?
*
        BEQ    SOROU1    BRANCH IF NOT
        TST  ESCFLG   ; ESCAPE ACTIVE?
        BSR   ESCAPE    ELSE DO ESCAPE
        BEQ  SOROU1   ; BRANCH IF NOT
        BRA    RETURN    AND RETURN
        BSR  ESCAPE   ; ELSE DO ESCAPE
 
        BRA  RETURN   ; AND RETURN
*
*
** CHECK FOR CONTROL CHARACTERS
** CHECK FOR CONTROL CHARACTERS
SOROU1  CMPA   #$20      CONTROL CODES?
*
 
SOROU1  CMPA #$20     ; CONTROL CODES?
        BHS    SOROU2
        BHS    SOROU2
        BSR    CONTRL    BRANCH IF SO
        BSR  CONTRL   ; BRANCH IF SO
        BRA    RETURN
        BRA    RETURN
*
*
** OUTPUT TEXT CHARACTER
** OUTPUT TEXT CHARACTER
SOROU2  LDX    CURSOR    ELSE GET CURSOR
*
        STAA   0,X       DISPLAY CHARACTER
SOROU2  LDX  CURSOR   ; ELSE GET CURSOR
        LBSR   NEWCOL    UPDATE COLUMN
        STA  0,X      ; DISPLAY CHARACTER
 
        LBSR NEWCOL   ; UPDATE COLUMN
*
*
** DISPLAY CURSOR AND RETURN
** DISPLAY CURSOR AND RETURN
RETURN  LDX    CURSOR    AND DISPLAY IT
*
 
RETURN  LDX  CURSOR   ; AND DISPLAY IT
        LDB    ,X
        LDB    ,X
        ORAB   #$80      WITH REVID
        ORB  #$80     ; WITH REVID
        STB    ,X
        STB    ,X
        PULS   A,B,X,PC  RESTORE REGISTERS AND RETURN
        PULS A,B,X,PC ; RESTORE REGISTERS AND RETURN
 
*
***************************************************
***************************************************
*              CONTROL CODE HANDLERS              *
*              CONTROL CODE HANDLERS              *
***************************************************
***************************************************
 
*
CONTRL  CMPA   #$08      CTRL H - BACKSPACE ?
CONTRL  CMPA #$08     ; CTRL H - BACKSPACE ?
        LBEQ   BACKSP
        LBEQ   BACKSP
        CMPA   #$1B      ESCAPE SEQUENCE?
        CMPA #$1B     ; ESCAPE SEQUENCE?
        LBEQ   SETESC
        LBEQ   SETESC
        CMPA   #$D       CTRL M - RETURN?
        CMPA #$D      ; CTRL M - RETURN?
        LBEQ   CRETN
        LBEQ   CRETN
        CMPA   #$0A      CTRL J - LINE FEED
        CMPA #$0A     ; CTRL J - LINE FEED
        BNE    RETESC    NONE OF THESE, RETURN
        BNE  RETESC   ; NONE OF THESE, RETURN
 
*
***************************************** LINE FEED
***************************************** LINE FEED
 
*
LINEFD  LDD    COLADX    GET CURRENT COLUMN AND ROW
LINEFD  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
        INCB             BUMP ROW
        INCB          ; BUMP ROW
        CMPB   #NUMLIN   SCROLL TIME?
        CMPB #NUMLIN  ; SCROLL TIME?
        LBNE   NEWCUR    POSITION CURSOR IF NOT
        LBNE NEWCUR   ; POSITION CURSOR IF NOT
        LBRA   SCROLL    ELSE SCROLL IT
        LBRA SCROLL   ; ELSE SCROLL IT
 
*
***************************************** LINE FEED
***************************************** LINE FEED
 
*
LINEUP  LDD    COLADX    GET CURRENT COLUMN AND ROW
LINEUP  LDD  COLADX   ; GET CURRENT COLUMN AND ROW
        TSTB             AT TOP OF SCREEN ?
        TSTB          ; AT TOP OF SCREEN ?
        BEQ   RETESC    Yes, Ignore
        BEQ  RETESC   ; YES, RETURN
        DECB             No, Decrement ROW
        DECB          ; NO, DECREMENT ROW
        LBRA   NEWCUR    POSITION CURSOR
        LBRA NEWCUR   ; POSITION CURSOR
 
*
 
 
*********************************** BACK SPACE
*********************************** BACK SPACE
 
*
BACKSP  LDA    COLADX
BACKSP  LDA  COLADX    ; GET CURRENT COLUMN AND ROW
        BEQ    RETESC      RETURN
        BEQ  RETESC    ; IF AT TOP LEFT CORNER RETURN
        DECA
        DECA           ; OTHERWISE BACK STEP ONE CHARACTER
        LBRA   POSCOL    POSITION CURSOR
        LBRA POSCOL    ; POSITION CURSOR
 
*
*********************************** CURSOR RIGHT
*********************************** CURSOR RIGHT
 
*
CHRIGHT LDA    COLADX
CHRIGHT LDA  COLADX    ; GET CURRENT COLUMN AND ROW
        INCA
        INCA           ; MOVE RIGHT ONE CHARACTER
        CMPA   #LINLEN
        CMPA #LINLEN   ; ARE WE AT THE END OF THE LINE ?
        BEQ   RETESC
        BEQ  RETESC    ; YES, RETURN
        LBRA   POSCOL
        LBRA POSCOL    ; NO, POSITION CURSOR
 
*
***************************************************
***************************************************
*                 ESCAPE HANDLERS                 *
*                 ESCAPE HANDLERS                 *
***************************************************
***************************************************
 
*
ESCAPE  LDAB   ESCFLG    GET FLAG
ESCAPE  LDB  ESCFLG   ; ARE WE IN AN ESCAPE SEQUENCE ?
        CMPB   #'=       SETTING CURSOR?
        CMPB #'=      ; ARE WE SETTING CURSOR?
        BEQ    ESCCUR    BRANCH IF SO
        BEQ  ESCCUR   ; YES BRANCH TO SET CURSOR
        CMPA   #'Y       CLEAR TO END OF SCREEN?
        CMPA #'Y      ; CLEAR TO END OF SCREEN?
        LBEQ   ESCCLS
        LBEQ ESCCLS   ; YES, CLEAR SCREEN
        CMPA   #'T       CLEAR TO END OF LINE?
        CMPA #'T      ; CLEAR TO END OF LINE?
        BEQ   ESCCLL
        BEQ  ESCCLL   ; YES, CLEAR LINE
        CMPA   #'E       INSERT LINE?
        CMPA #'E      ; INSERT LINE?
        BEQ   ESCINL
        BEQ   ESCINL
        CMPA   #'R       DELETE LINE?
        CMPA #'R      ; DELETE LINE?
        BEQ   ESCDLL
        BEQ   ESCDLL
        CMPA   #'=       STARTING CURSOR SET?
        CMPA #'=      ; STARTING CURSOR SET?
        BNE    CLRESC    BRANCH IF NOT
        BNE  CLRESC   ; BRANCH IF NOT
 
*
***************************** START ESCAPE SEQUENCE
***************************** START ESCAPE SEQUENCE
 
*
SETESC  STAA   ESCFLG    ELSE START CURSORING
SETESC  STA  ESCFLG   ; ELSE START CURSORING
        RTS              AND RETURN
        RTS           ; AND RETURN
 
*
CLRESC  CLR    ESCFLG    NO OTHERS SUPPORTED
CLRESC  CLR  ESCFLG   ; NO OTHERS SUPPORTED
RETESC  RTS              SO RETURN
RETESC  RTS           ;  SO RETURN
 
*
********************************* SET SCREEN CURSOR
********************************* SET SCREEN CURSOR
 
*
ESCCUR  TST   NEWROW    ROW SET?
ESCCUR  TST  NEWROW   ; ROW SET?
        BNE   ESCCU1    BRANCH IF SO
        BNE  ESCCU1   ; BRANCH IF SO
        STAA  NEWROW    ELSE SET NEW ROW
        STA  NEWROW   ; ELSE SET NEW ROW
        RTS              AND RETURN
        RTS           ;  AND RETURN
 
*
ESCCU1  CLR   ESCFLG
ESCCU1  CLR   ESCFLG
        SUBA  #$20      ADJUST COLUMN ADDRESS
        SUBA #$20      ; ADJUST COLUMN ADDRESS
        CMPA  #LINLEN-1 CHECK FOR ACCEPTABLE COLUM
        CMPA #LINLEN-1 ; CHECK FOR ACCEPTABLE COLUM
        BHI   RETESC    NOT OK, DO NOTHING
        BHI  RETESC    ; NOT OK, DO NOTHING
 
*
ESCCU2  LDAB  NEWROW
ESCCU2  LDB  NEWROW
        CLR   NEWROW
        CLR   NEWROW
        SUBB  #$20      ADJUST TO ROW ADDRESS
        SUBB #$20      ; ADJUST TO ROW ADDRESS
        CMPB  #NUMLIN-1 CHECK FOR ACCEPTABLE ROW
        CMPB #NUMLIN-1 ; CHECK FOR ACCEPTABLE ROW
        BHI   RETESC    ELSE RETURN DOING NOTHING
        BHI  RETESC    ; ELSE RETURN DOING NOTHING
        BRA   NEWCUR    GO SET NEW CURSOR IF SO
        BRA  NEWCUR    ; GO SET NEW CURSOR IF SO
*
*
*************************** DELETE LINE FROM SCREEN
*************************** DELETE LINE FROM SCREEN
 
*
ESCDLL  BSR   CRETN     GO COL. ZERO
ESCDLL  BSR  CRETN     ; GO COL. ZERO
        LDB   ROWADX
        LDB   ROWADX
        CMPB  #NUMLIN-1
        CMPB  #NUMLIN-1
        BEQ   SCROL3
        BEQ   SCROL3
        BRA   SCROL1    AND DELETE THIS LINE
        BRA  SCROL1    ; AND DELETE THIS LINE
 
*
*************************** INSERT LINE INTO SCREEN
*************************** INSERT LINE INTO SCREEN
 
*
ESCINL  BSR   CRETN    GO TO COL. ZERO
ESCINL  BSR  CRETN     ; GO TO COL. ZERO
        LDAB  ROWADX
        LDB  ROWADX
        CMPB  #NUMLIN-1
        CMPB  #NUMLIN-1
        BEQ   ESCCLL
        BEQ   ESCCLL
*
*
** SCROLL SCREEN DOWN FROM CURSOR
** SCROLL SCREEN DOWN FROM CURSOR
*
*
        LDX   #SCREEN+SCNLEN-LINLEN
        LDX   #SCREEN+SCNLEN-LINLEN
ESCIN0  LDAA  0,-X
ESCIN0  LDA  ,-X
        STAA  LINLEN,X
        STA  LINLEN,X
        LDA   SCNLEN,X
        LDA   SCNLEN,X
        STA   SCNLEN+LINLEN,X
        STA   SCNLEN+LINLEN,X
        CPX   CURSOR
        CMPX CURSOR
        BNE   ESCIN0
        BNE   ESCIN0
 
*
****************** CLEAR FROM CURSOR TO END OF LINE
****************** CLEAR FROM CURSOR TO END OF LINE
 
*
ESCCLL  LDA   COLADX    GET CURRENT COLUMN
ESCCLL  LDA  COLADX    ; GET CURRENT COLUMN
        LDX   CURSOR    GET CURSOR
        LDX  CURSOR    ; GET CURSOR
        LDB   #$20      AND CLEAR CHAR
        LDB  #$20      ; AND CLEAR CHAR
ESCLL1  STB   SCNLEN,X  CLEAR ATTRIBUTE
ESCLL1  STB  SCNLEN,X  ; CLEAR ATTRIBUTE
        STB   ,X+       CLEAR TEXT
        STB  ,X+       ; CLEAR TEXT
        INCA
        INCA
        CMPA  #LINLEN   UNTIL END OF LINE
        CMPA #LINLEN   ; UNTIL END OF LINE
        BNE   ESCLL1
        BNE   ESCLL1
        CLR   ESCFLG
        CLR   ESCFLG
        RTS
        RTS
 
*
*********************************** CARRIAGE RETURN
*********************************** CARRIAGE RETURN
 
*
CRETN   CLRA               SET COLUMN ZERO
CRETN   CLRA           ; SET COLUMN ZERO
POSCOL  LDB   ROWADX    GET CURRENT ROW
POSCOL  LDB  ROWADX    ; GET CURRENT ROW
 
*
*********** GENERATE NEW CURSOR POSITION AND RETURN
*********** GENERATE NEW CURSOR POSITION AND RETURN
 
*
NEWCUR  STD   COLADX    SAVE NEW ROW AND COLUMN
NEWCUR  STD  COLADX    ; SAVE NEW ROW AND COLUMN
        LDA   #LINLEN   ELSE ADD A LINE
        LDA  #LINLEN   ; ELSE ADD A LINE
        MUL              LINLEN * ROWADX
        MUL            ; LINLEN * ROWADX
        ADDB  COLADX
        ADDB  COLADX
        ADCA  #0
        ADCA  #0
        ADDD  #SCREEN   ADD SCREEN BASE.
        ADDD #SCREEN   ; ADD SCREEN BASE.
        STD   CURSOR    SAVE NEW CURSOR
        STD  CURSOR    ; SAVE NEW CURSOR
        TFR   D,X       GET CURSOR IN X
        TFR  D,X       ; GET CURSOR IN X
        RTS              AND RETURN
        RTS            ; AND RETURN
 
*
********************* UPDATE CURRENT COLUMN AND ROW
********************* UPDATE CURRENT COLUMN AND ROW
 
*
NEWCOL  LDD   COLADX    GET ROW AND COLUMN
NEWCOL  LDD  COLADX    ; GET ROW AND COLUMN
        INCA             BUMP COLUMN
        INCA           ; BUMP COLUMN
        CMPA  #LINLEN   ROLL?
        CMPA #LINLEN   ; ROLL?
        BNE   NEWCUR    BRANCH IF NOT
        BNE  NEWCUR    ; BRANCH IF NOT
        CLRA             ELSE RESET TO ZERO
        CLRA           ; ELSE RESET TO ZERO
        INCB             AND BUMP ROW
        INCB           ; AND BUMP ROW
        CMPB  #NUMLIN
        CMPB  #NUMLIN
        BNE   NEWCUR
        BNE   NEWCUR
        DECB             BOTTOM ROW
        DECB           ; BOTTOM ROW
        BSR   NEWCUR
        BSR   NEWCUR
 
*
********************************* SCROLL THE SCREEN
********************************* SCROLL THE SCREEN
 
*
SCROLL  LDX   #SCREEN   POINT TO SCREEN
SCROLL  LDX  #SCREEN   ; POINT TO SCREEN
SCROL1  LDA   SCNLEN+LINLEN,X
SCROL1  LDA   SCNLEN+LINLEN,X
        STA   SCNLEN,X
        STA   SCNLEN,X
        LDAA  LINLEN,X  MOVE TWO BYTES
        LDA  LINLEN,X  ; MOVE TWO BYTES
        STAA  0,X+      UP ONE LINE
        STA  ,X+       ; UP ONE LINE
        CMPX  #SCREEN+SCNLEN-LINLEN
        CMPX  #SCREEN+SCNLEN-LINLEN
        BNE   SCROL1    LOOP UNTIL DONE
        BNE  SCROL1    ; LOOP UNTIL DONE
        BRA   SCROL3
        BRA   SCROL3
 
*
**************** CLEAR FROM CURSOR TO END OF SCREEN
**************** CLEAR FROM CURSOR TO END OF SCREEN
 
*
ESCCLS  LDX   CURSOR    GET CURSOR
ESCCLS  LDX   CURSOR   ; GET CURSOR
SCROL3  LDAA  #$20      GET A SPACE
SCROL3  LDA   #$20     ; GET A SPACE
SCROL2  STA   SCNLEN,X  CLEAR ATTRIBUTES
SCROL2  STA   SCNLEN,X ; CLEAR ATTRIBUTES
        STA   ,X+       AND TEXT
        STA   ,X+      ; AND TEXT
        CMPX  #SCREEN+SCNLEN
        CMPX  #SCREEN+SCNLEN
        BNE   SCROL2    UNTIL DONE
        BNE   SCROL2   ; UNTIL DONE
        CLR   ESCFLG
        CLR   ESCFLG
        RTS
        RTS
        ENDIF DG640OPT
        ENDIF DG640OPT
*
*
        IFD PRTOPT
        IFD PRTOPT
Line 1855... Line 1888...
*************************************
*************************************
*
*
** PINIZ - INITIATE PRINTER PORT
** PINIZ - INITIATE PRINTER PORT
*
*
PINIZ   PSHS B
PINIZ   PSHS B
        LDD #DIRMSK*256+$04 ACCA=DIRMSK ACCB=$04
        LDD #DIRMSK*256+$04 ; ACCA=DIRMSK ACCB=$04
        STD PADATA SET DDR AND SELECT DATA
        STD PADATA     ; SET DDR AND SELECT DATA
*
*
** RESET PRINTER
** RESET PRINTER
 
*
        LDB #PRESET
        LDB #PRESET
        STAB PADATA
        STB  PADATA
RESTLP  INCB DELAY FOR RESET
RESTLP  INCB           ; DELAY FOR RESET
        BNE RESTLP
        BNE RESTLP
        STAA PADATA ACCA=DIRMSK
        STA  PADATA    ; ACCA=DIRMSK
*
*
** INITALIZE PORT B (DATA PORT)
** INITALIZE PORT B (DATA PORT)
        LDAA #$2A
*
        STAA PBCTRL
        LDA  #$2A
        LDD #$FF2E ACCA=$FF ACCB =%00101110
        STA  PBCTRL
        STD PBDATA PBDREG   PBCTRL
        LDD  #$FF2E    ; ACCA=$FF ACCB =%00101110
 
        STD  PBDATA    ; PBDREG   PBCTRL
*
*
** SELECT 66 LINES/PAGE
** SELECT 66 LINES/PAGE
        LDAA #$1B
*
 
        LDA  #$1B
        BSR POUTCH
        BSR POUTCH
        LDAA #'C
        LDA  #'C
        BSR POUTCH
        BSR POUTCH
        LDAA #66
        LDA  #66
        PULS B
        PULS B
*************************************
*************************************
*
*
** OUTPUT A CHARACTER TO THE PRINTER
** OUTPUT A CHARACTER TO THE PRINTER
*
*
*************************************
*************************************
POUTCH  PSHS B
POUTCH  PSHS B
        LDAB PBDATA CLEAR INTERRUPT BIT
        LDB  PBDATA    ; CLEAR INTERRUPT BIT
*
*
** WAIT TILL NOT BUSY
** WAIT TILL NOT BUSY
BUSYLP  LDAB PADATA
*
 
BUSYLP  LDB  PADATA
        BITB #PERROR
        BITB #PERROR
        BEQ PEXIT
        BEQ PEXIT
        TSTB
        TSTB
        BMI BUSYLP
        BMI BUSYLP
*
*
** NOW OUTPUT CHARACTER
** NOW OUTPUT CHARACTER
        STAA PBDATA
*
 
        STA  PBDATA
PEXIT   PULS B,PC
PEXIT   PULS B,PC
*************************************
*************************************
*
*
** PCHK TEST IFD PRINTER READY
** PCHK TEST IFD PRINTER READY
*
*
*************************************
*************************************
PCHK    TST PBCTRL TEST STATE OF CRB7
PCHK    TST  PBCTRL    ; TEST STATE OF CRB7
        RTS SET ON ACKNOWLEDGE
        RTS            ; SET ON ACKNOWLEDGE
        ENDIF PRTOPT
        ENDIF PRTOPT
*************************************
*************************************
*
*
* MONITOR KEYBOARD COMMAND JUMP TABLE
* MONITOR KEYBOARD COMMAND JUMP TABLE
*
*
Line 1947... Line 1985...
 FCC 'S'
 FCC 'S'
 FDB DISSTK
 FDB DISSTK
 FCC 'X'
 FCC 'X'
 FDB XBKPNT
 FDB XBKPNT
 IFD MFDCOPT
 IFD MFDCOPT
 FCC 'D'      *** SWTPC USES 'U' FOR MINIBOOT
        FCC 'D'        ; *** SWTPC USES 'U' FOR MINIBOOT
 FDB MINBOOT
 FDB MINBOOT
 ENDIF MFDCOPT
 ENDIF MFDCOPT
 IFD CF8OPT
 IFD CF8OPT
 FCC 'D'      *** FPGA 8 BIT USES 'D' FOR CFBOOT
        FCC 'D'        ; *** FPGA 8 BIT USES 'D' FOR CFBOOT
 FDB CFBOOT
 FDB CFBOOT
 ENDIF CF8OPT
 ENDIF CF8OPT
 IFD IDEOPT
 IFD IDEOPT
 FCC 'D'      *** XESS FPGA 16 BIT IDE USES 'D' FOR IDEBOOT
        FCC 'D'        ; *** XESS FPGA 16 BIT IDE USES 'D' FOR IDEBOOT
 FDB IDEBOOT
 FDB IDEBOOT
 ENDIF IDEOPT
 ENDIF IDEOPT
 IFD DMAFOPT
 IFD DMAFOPT
 FCC 'U'      *** SWTPC USES 'D' FOR DMAF2 BOOT
        FCC 'U'        ; *** SWTPC USES 'D' FOR DMAF2 BOOT
 FDB DBOOT
 FDB DBOOT
 ENDIF DMAFOPT
 ENDIF DMAFOPT
 IFD EXTOPT
 IFD EXTOPT
 FCC 'U'      *** IF FPGA, 'U' IS FOR USER
        FCC 'U'        ; *** IF FPGA, 'U' IS FOR USER
 FDB USRCMD
 FDB USRCMD
 ENDIF EXTOPT
 ENDIF EXTOPT
 IFD RTCOPT
 IFD RTCOPT
 FCC 'T'
 FCC 'T'
 FDB TIMSET
 FDB TIMSET
Line 1986... Line 2024...
* ARE RELOCATED TO RAM FROM $DFC0 TO $DFCF. THEY ARE
* ARE RELOCATED TO RAM FROM $DFC0 TO $DFCF. THEY ARE
* RELOCATED TO RAM SO THAT THE USER MAY REVECTOR TO
* RELOCATED TO RAM SO THAT THE USER MAY REVECTOR TO
* HIS OWN ROUTINES IF HE SO DESIRES.
* HIS OWN ROUTINES IF HE SO DESIRES.
*
*
*
*
RAMVEC FDB SWIE  USER-V
RAMVEC  FDB SWIE       ; USER-V
 FDB RTI    SWI3-V
        FDB RTI        ; SWI3-V
 FDB RTI    SWI2-V
        FDB RTI        ; SWI2-V
 FDB RTI    FIRQ-V
        FDB RTI        ; FIRQ-V
 FDB RTI    IRQ-V
        FDB RTI        ; IRQ-V
 FDB SWIE   SWI-V
        FDB SWIE       ; SWI-V
 FDB $FFFF  SVC-VO
        FDB $FFFF      ; SVC-VO
 FDB $FFFF  SVC-VL
        FDB $FFFF      ; SVC-VL
*
*
* PRINTABLE MESSAGE STRINGS
* PRINTABLE MESSAGE STRINGS
*
*
MSG1  FCB $D,$A,$0,$0,$0 * 0, CR/LF, 0
MSG1  FCB $D,$A,$0,$0,$0 * 0, CR/LF, 0
      FCC 'SYS09BUG 1.4 FOR '
        FCC  'SYS09BUG 1.6 FOR '
      IFD S3EOPT
        IFD  SWTOPT`
      FCC 'S3E '
        FCC  'SWTPC '
      ENDIF S3EOPT
        ENDIF SWTOPT
 
        IFD  ADSOPT
 
        FCC  'ADS6809 '
 
        ENDIF ADSOPT
 
        IFD  B3SOPT
 
        FCC  'B3-S2+ '
 
        ENDIF B3SOPT
      IFD B5XOPT
      IFD B5XOPT
      FCC 'B5-X300 '
      FCC 'B5-X300 '
      ENDIF B5XOPT
      ENDIF B5XOPT
      IFD S3SOPT
      IFD S3SOPT
      FCC 'S3STARTER '
      FCC 'S3STARTER '
      ENDIF S3SOPT
      ENDIF S3SOPT
      IFD ADSOPT
        IFD  S3EOPT
      FCC 'ADS6809 '
        FCC  'S3E '
      ENDIF ADSOPT
        ENDIF S3EOPT
      IFD SWTOPT`
 
      FCC 'SWTPC '
 
      ENDIF SWTOPT
 
      IFD XESOPT`
      IFD XESOPT`
      FCC  'XESS '
      FCC  'XESS '
      ENDIF XESOPT
      ENDIF XESOPT
      FCC ' - '
      FCC ' - '
      FCB 4
      FCB 4
MSG2  FCB 'K,$D,$A,$00,$00,$00,$04 K, * CR/LF + 3 NULS
MSG2    FCB 'K,$0D,$0A,$00,$00,$00,$04 ; K,,,3 NULS,
MSG3  FCC '>'
MSG3  FCC '>'
      FCB 4
      FCB 4
MSG4  FCC 'WHAT?'
MSG4  FCC 'WHAT?'
      FCB 4
      FCB 4
MSG5  FCC ' - '
MSG5  FCC ' - '
Line 2054... Line 2095...
* POWER UP/ RESET/ NMI ENTRY POINT
* POWER UP/ RESET/ NMI ENTRY POINT
*
*
 ORG $FF00
 ORG $FF00
*
*
*
*
START LDX  #IC11  POINT TO DAT RAM IC11
START   LDX  #IC11    ; POINT TO DAT RAM IC11
        LDA  #$F GET COMPLIMENT OF ZERO
        LDA  #$0F     ; GET COMPLIMENT OF ZERO
*
*
*
*
* INITIALIZE DAT RAM --- LOADS $F-$0 IN LOCATIONS $0-$F
* INITIALIZE DAT RAM --- LOADS $F-$0 IN LOCATIONS $0-$F
* OF DAT RAM, THUS STORING COMPLEMENT OF MSB OF ADDRESS
* OF DAT RAM, THUS STORING COMPLEMENT OF MSB OF ADDRESS
* IN THE DAT RAM. THE COMPLEMENT IS REQUIRED BECAUSE THE
* IN THE DAT RAM. THE COMPLEMENT IS REQUIRED BECAUSE THE
* OUTPUT OF IC11, A 74S189, IS THE INVERSE OF THE DATA
* OUTPUT OF IC11, A 74S189, IS THE INVERSE OF THE DATA
* STORED IN IT.
* STORED IN IT.
*
*
*
*
DATLP STA  ,X+ STORE & POINT TO NEXT RAM LOCATION
DATLP   STA  ,X+       ; STORE & POINT TO NEXT RAM LOCATION
        DECA  GET COMP. VALUE FOR NEXT LOCATION
        DECA           ; GET COMP. VALUE FOR NEXT LOCATION
        BNE  DATLP ALL 16 LOCATIONS INITIALIZED ?
        BNE  DATLP     ; ALL 16 LOCATIONS INITIALIZED ?
*
*
* NOTE: IX NOW CONTAINS $0000, DAT RAM IS NO LONGER
* NOTE: IX NOW CONTAINS $0000, DAT RAM IS NO LONGER
*       ADDRESSED, AND LOGICAL ADDRESSES NOW EQUAL
*       ADDRESSED, AND LOGICAL ADDRESSES NOW EQUAL
*       PHYSICAL ADDRESSES.
*       PHYSICAL ADDRESSES.
*
*
        LDA  #$F0
        LDA  #$F0
        STA  ,X STORE $F0 AT $FFFF
        STA  ,X        ; STORE $F0 AT $FFFF
        LDX  #$D0A0 ASSUME RAM TO BE AT $D000-$DFFF
        LDX  #$D0A0    ; ASSUME RAM TO BE AT $D000-$DFFF
        LDY  #TSTPAT LOAD TEST DATA PATTERN INTO "Y"
        LDY  #TSTPAT   ; LOAD TEST DATA PATTERN INTO "Y"
TSTRAM LDU  ,X SAVE DATA FROM TEST LOCATION
TSTRAM  LDU  ,X        ; SAVE DATA FROM TEST LOCATION
        STY  ,X STORE TEST PATTERN AT $D0A0
        STY  ,X        ; STORE TEST PATTERN AT $D0A0
        CMPY ,X IS THERE RAM AT THIS LOCATION ?
        CMPY ,X        ; IS THERE RAM AT THIS LOCATION ?
        BEQ  CNVADR IF MATCH THERE'S RAM, SO SKIP
        BEQ  CNVADR    ; IF MATCH THERE'S RAM, SO SKIP
        LEAX -$1000,X ELSE POINT 4K LOWER
        LEAX -$1000,X  ; ELSE POINT 4K LOWER
        CMPX #$F0A0 DECREMENTED PAST ZER0 YET ?
        CMPX #$F0A0    ; DECREMENTED PAST ZER0 YET ?
        BNE  TSTRAM IF NOT CONTINUE TESTING FOR RAM
        BNE  TSTRAM    ; IF NOT CONTINUE TESTING FOR RAM
        BRA  START ELSE START ALL OVER AGAIN
        BRA  START     ; ELSE START ALL OVER AGAIN
*
*
*
*
* THE FOLLOWING CODE STORES THE COMPLEMENT OF
* THE FOLLOWING CODE STORES THE COMPLEMENT OF
* THE MS CHARACTER OF THE FOUR CHARACTER HEX
* THE MS CHARACTER OF THE FOUR CHARACTER HEX
* ADDRESS OF THE FIRST 4K BLOCK OF RAM LOCATED
* ADDRESS OF THE FIRST 4K BLOCK OF RAM LOCATED
Line 2109... Line 2150...
* IS AT $D--- SINCE THAT IS THE ADDRESS THE
* IS AT $D--- SINCE THAT IS THE ADDRESS THE
* 6809 WILL BE OUTPUTING WHEN THAT 4K BLOCK
* 6809 WILL BE OUTPUTING WHEN THAT 4K BLOCK
* OF RAM RESPONDS.
* OF RAM RESPONDS.
*
*
*
*
CNVADR  STU  ,X RESTORE DATA AT TEST LOCATION
CNVADR  STU  ,X        ; RESTORE DATA AT TEST LOCATION
        TFR  X,D PUT ADDR. OF PRESENT 4K BLOCK IN D
        TFR  X,D       ; PUT ADDR. OF PRESENT 4K BLOCK IN D
        COMA  COMPLEMENT MSB OF THAT ADDRESS
        COMA           ; COMPLEMENT MSB OF THAT ADDRESS
        LSRA  PUT MS 4 BITS OF ADDRESS IN
        LSRA           ; PUT MS 4 BITS OF ADDRESS IN
        LSRA  LOCATION D0-D3 TO ALLOW STORING
        LSRA           ; LOCATION D0-D3 TO ALLOW STORING
        LSRA  IT IN THE DYNAMIC ADDRESS
        LSRA           ; IT IN THE DYNAMIC ADDRESS
        LSRA  TRANSLATION RAM.
        LSRA           ; TRANSLATION RAM.
        STA  $FFFD STORE XLATION FACTOR IN DAT "D"
        STA  $FFFD     ; STORE XLATION FACTOR IN DAT "D"
*
*
        LDS  #STACK INITIALIZE STACK POINTER
        LDS  #STACK    ; INITIALIZE STACK POINTER
*
*
*
*
* THE FOLLOWING CHECKS TO FIND THE REAL PHYSICAL ADDRESSES
* THE FOLLOWING CHECKS TO FIND THE REAL PHYSICAL ADDRESSES
* OF ALL 4K BLKS OF RAM IN THE SYSTEM. WHEN EACH 4K BLK
* OF ALL 4K BLKS OF RAM IN THE SYSTEM. WHEN EACH 4K BLK
* OF RAM IS LOCATED, THE COMPLEMENT OF IT'S REAL ADDRESS
* OF RAM IS LOCATED, THE COMPLEMENT OF IT'S REAL ADDRESS
Line 2152... Line 2193...
*
*
*  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
*  0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
* 4K 4K 4K 4K 4K 4K 4K 4K 4K 4K -- -- 4K 4K -- --
* 4K 4K 4K 4K 4K 4K 4K 4K 4K 4K -- -- 4K 4K -- --
*
*
*
*
        LDY  #LRARAM POINT TO LOGICAL/REAL ADDR. TABLE
        LDY  #LRARAM   ; POINT TO LOGICAL/REAL ADDR. TABLE
        STA  13,Y STORE $D--- XLATION FACTOR AT $DFDD
        STA  13,Y      ; STORE $D--- XLATION FACTOR AT $DFDD
        CLR  14,Y CLEAR $DFDE
        CLR  14,Y      ; CLEAR $DFDE
        LDA  #$F0 DESTINED FOR IC8 AN MEM EXPANSION ?
        LDA  #$F0      ; DESTINED FOR IC8 AN MEM EXPANSION ?
        STA  15,Y STORE AT $DFDF
        STA  15,Y      ; STORE AT $DFDF
        LDA  #$0C PRESET NUMBER OF BYTES TO CLEAR
        LDA  #$0C      ; PRESET NUMBER OF BYTES TO CLEAR
CLRLRT CLR  A,Y CLEAR $DFDC THRU $DFD0
CLRLRT  CLR  A,Y       ; CLEAR $DFDC THRU $DFD0
        DECA SUB. 1 FROM BYTES LEFT TO CLEAR
        DECA           ; SUB. 1 FROM BYTES LEFT TO CLEAR
        BPL  CLRLRT CONTINUE IF NOT DONE CLEARING
        BPL  CLRLRT    ; CONTINUE IF NOT DONE CLEARING
FNDRAM LEAX -$1000,X POINT TO NEXT LOWER 4K OF RAM
FNDRAM  LEAX -$1000,X  ; POINT TO NEXT LOWER 4K OF RAM
        CMPX #$F0A0 TEST FOR DECREMENT PAST ZERO
        CMPX #$F0A0    ; TEST FOR DECREMENT PAST ZERO
        BEQ  FINTAB SKIP IF FINISHED
        BEQ  FINTAB    ; SKIP IF FINISHED
        LDU  ,X SAVE DATA AT CURRENT TEST LOCATION
        LDU  ,X        ; SAVE DATA AT CURRENT TEST LOCATION
        LDY  #TSTPAT LOAD TEST DATA PATTERN INTO Y REG.
        LDY  #TSTPAT   ; LOAD TEST DATA PATTERN INTO Y REG.
        STY  ,X STORE TEST PATT. INTO RAM TEST LOC.
        STY  ,X        ; STORE TEST PATT. INTO RAM TEST LOC.
        CMPY ,X VERIFY RAM AT TEST LOCATION
        CMPY ,X        ; VERIFY RAM AT TEST LOCATION
        BNE  FNDRAM IF NO RAM GO LOOK 4K LOWER
        BNE  FNDRAM    ; IF NO RAM GO LOOK 4K LOWER
        STU  ,X ELSE RESTORE DATA TO TEST LOCATION
        STU  ,X        ; ELSE RESTORE DATA TO TEST LOCATION
        LDY  #LRARAM POINT TO LOGICAL/REAL ADDR. TABLE
        LDY  #LRARAM   ; POINT TO LOGICAL/REAL ADDR. TABLE
        TFR  X,D PUT ADDR. OF PRESENT 4K BLOCK IN D
        TFR  X,D       ; PUT ADDR. OF PRESENT 4K BLOCK IN D
        LSRA  PUT MS 4 BITS OF ADDR. IN LOC. D0-D3
        LSRA           ; PUT MS 4 BITS OF ADDR. IN LOC. D0-D3
        LSRA  TO ALLOW STORING IT IN THE DAT RAM.
        LSRA           ; TO ALLOW STORING IT IN THE DAT RAM.
        LSRA
        LSRA
        LSRA
        LSRA
        TFR  A,B SAVE OFFSET INTO LRARAM TABLE
        TFR  A,B       ; SAVE OFFSET INTO LRARAM TABLE
        EORA #$0F INVERT MSB OF ADDR. OF CURRENT 4K BLK
        EORA #$0F      ; INVERT MSB OF ADDR. OF CURRENT 4K BLK
        STA  B,Y SAVE TRANSLATION FACTOR IN LRARAM TABLE
        STA  B,Y       ; SAVE TRANSLATION FACTOR IN LRARAM TABLE
        BRA  FNDRAM GO TRANSLATE ADDR. OF NEXT 4K BLK
        BRA  FNDRAM    ; GO TRANSLATE ADDR. OF NEXT 4K BLK
FINTAB LDA  #$F1 DESTINED FOR IC8 AND MEM EXPANSION ?
FINTAB  LDA  #$F1      ; DESTINED FOR IC8 AND MEM EXPANSION ?
        LDY  #LRARAM POINT TO LRARAM TABLE
        LDY  #LRARAM   ; POINT TO LRARAM TABLE
        STA  14,Y STORE $F1 AT $DFCE
        STA  14,Y      ; STORE $F1 AT $DFCE
*
*
* THE FOLLOWING CHECKS TO SEE IF THERE IS A 4K BLK OF
* THE FOLLOWING CHECKS TO SEE IF THERE IS A 4K BLK OF
* RAM LOCATED AT $C000-$CFFF. IF NONE THERE IT LOCATES
* RAM LOCATED AT $C000-$CFFF. IF NONE THERE IT LOCATES
* THE NEXT LOWER 4K BLK AN XLATES ITS ADDR SO IT
* THE NEXT LOWER 4K BLK AN XLATES ITS ADDR SO IT
* LOGICALLY RESPONDS TO THE ADDRESS $C---.
* LOGICALLY RESPONDS TO THE ADDRESS $C---.
*
*
*
*
        LDA  #$0C PRESET NUMBER HEX "C"
        LDA  #$0C      ; PRESET NUMBER HEX "C"
FINDC   LDB  A,Y GET ENTRY FROM LRARAM TABLE
FINDC   LDB  A,Y       ; GET ENTRY FROM LRARAM TABLE
        BNE  FOUNDC BRANCH IF RAM THIS PHYSICAL ADDR.
        BNE  FOUNDC    ; BRANCH IF RAM THIS PHYSICAL ADDR.
        DECA  ELSE POINT 4K LOWER
        DECA           ; ELSE POINT 4K LOWER
        BPL  FINDC GO TRY AGAIN
        BPL  FINDC     ; GO TRY AGAIN
        BRA  XFERTF
        BRA  XFERTF
FOUNDC  CLR  A,Y CLR XLATION FACTOR OF 4K BLOCK FOUND
FOUNDC  CLR  A,Y       ; CLR XLATION FACTOR OF 4K BLOCK FOUND
        STB  $C,Y GIVE IT XLATION FACTOR MOVING IT TO $C---
        STB  $0C,Y     ; GIVE IT XLATION FACTOR MOVING IT TO $C---
*
*
* THE FOLLOWING CODE ADJUSTS THE TRANSLATION
* THE FOLLOWING CODE ADJUSTS THE TRANSLATION
* FACTORS SUCH THAT ALL REMAINING RAM WILL
* FACTORS SUCH THAT ALL REMAINING RAM WILL
* RESPOND TO A CONTIGUOUS BLOCK OF LOGICAL
* RESPOND TO A CONTIGUOUS BLOCK OF LOGICAL
* ADDRESSES FROM $0000 AND UP....
* ADDRESSES FROM $0000 AND UP....
*
*
        CLRA  START AT ZERO
        CLRA           ; START AT ZERO
        TFR  Y,X START POINTER "X" START OF "LRARAM" TABLE.
        TFR  Y,X       ; START POINTER "X" START OF "LRARAM" TABLE.
COMPRS  LDB  A,Y GET ENTRY FROM "LRARAM" TABLE
COMPRS  LDB  A,Y       ; GET ENTRY FROM "LRARAM" TABLE
        BEQ  PNTNXT IF IT'S ZER0 SKIP
        BEQ  PNTNXT    ; IF IT'S ZER0 SKIP
        CLR  A,Y ELSE ERASE FROM TABLE
        CLR  A,Y       ; ELSE ERASE FROM TABLE
        STB  ,X+ AND ENTER ABOVE LAST ENTRY- BUMP
        STB  ,X+       ; AND ENTER ABOVE LAST ENTRY- BUMP
PNTNXT  INCA GET OFFSET TO NEXT ENTRY
PNTNXT  INCA           ; GET OFFSET TO NEXT ENTRY
        CMPA #$0C LAST ENTRY YET ?
        CMPA #$0C      ; LAST ENTRY YET ?
        BLT  COMPRS
        BLT  COMPRS
*
*
* THE FOLLOWING CODE TRANSFER THE TRANSLATION
* THE FOLLOWING CODE TRANSFER THE TRANSLATION
* FACTORS FROM THE LRARAM TABLE TO IC11 ON
* FACTORS FROM THE LRARAM TABLE TO IC11 ON
* THE MP-09 CPU CARD.
* THE MP-09 CPU CARD.
*
*
XFERTF  LDX  #IC11  POINT TO DAT RAM IC11
XFERTF  LDX  #IC11     ; POINT TO DAT RAM IC11
        LDB  #$10 GET NO. OF BYTES TO MOVE
        LDB  #$10      ; GET NO. OF BYTES TO MOVE
FETCH   LDA  ,Y+ GET BYTE AND POINT TO NEXT
FETCH   LDA  ,Y+       ; GET BYTE AND POINT TO NEXT
        STA  ,X+ POKE XLATION FACTOR IN IC11
        STA  ,X+       ; POKE XLATION FACTOR IN IC11
        DECB  SUB 1 FROM BYTES TO MOVE
        DECB           ; SUB 1 FROM BYTES TO MOVE
        BNE  FETCH CONTINUE UNTIL 16 MOVED
        BNE  FETCH     ; CONTINUE UNTIL 16 MOVED
*
*
        ELSE
        ELSE
LRA     RTS
LRA     RTS
START   LDS  #STACK INITIALIZE STACK POINTER
START   LDS  #STACK    ; INITIALIZE STACK POINTER
        CLRB
        CLRB
        ENDIF DATOPT
        ENDIF DATOPT
*
*
        COMB  SET "B" NON-ZERO
        COMB           ; SET "B" NON-ZERO
        STB  ECHO TURN ON ECHO FLAG
        STB  ECHO      ; TURN ON ECHO FLAG
        LBRA MONITOR INITIALIZATION IS COMPLETE
        LBRA MONITOR   ; INITIALIZATION IS COMPLETE
*
*
** INTERRUPT JUMP VECTORS
** INTERRUPT JUMP VECTORS
*
*
V1 JMP  [STACK]
V1 JMP  [STACK]
V2 JMP  [SWI2]
V2 JMP  [SWI2]

powered by: WebSVN 2.1.0

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