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

Subversion Repositories System09

[/] [System09/] [rev_86/] [src/] [dump/] [dump_cf8.asm] - Diff between revs 66 and 112

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 66 Rev 112
*
*
* Sector Dump Utility
* Sector Dump Utility
* For Compact Flash Driver
* For Compact Flash Driver
* for the 6809
* for the 6809
* Configured in 8 bit mode
* Configured in 8 bit mode
*
*
* John Kent
* John Kent
* 21 May 2007
* 21 May 2007
*
*
* Register Equates
* Register Equates
*
*
CF_BASE    EQU $E040
CF_BASE    EQU $E040
CF_DATA    EQU CF_BASE+0
CF_DATA    EQU CF_BASE+0
CF_ERROR   EQU CF_BASE+1 ; read error
CF_ERROR   EQU CF_BASE+1 ; read error
CF_FEATURE EQU CF_BASE+1 ; write feature
CF_FEATURE EQU CF_BASE+1 ; write feature
CF_SECCNT  EQU CF_BASE+2
CF_SECCNT  EQU CF_BASE+2
CF_SECNUM  EQU CF_BASE+3
CF_SECNUM  EQU CF_BASE+3
CF_CYLLO   EQU CF_BASE+4
CF_CYLLO   EQU CF_BASE+4
CF_CYLHI   EQU CF_BASE+5
CF_CYLHI   EQU CF_BASE+5
CF_HEAD    EQU CF_BASE+6
CF_HEAD    EQU CF_BASE+6
CF_STATUS  EQU CF_BASE+7 ; read status
CF_STATUS  EQU CF_BASE+7 ; read status
CF_COMAND  EQU CF_BASE+7 ; write command
CF_COMAND  EQU CF_BASE+7 ; write command
*
*
* Command Equates
* Command Equates
*
*
CMDREAD    EQU $20 ; Read Single sector
CMDREAD    EQU $20 ; Read Single sector
CMDWRITE   EQU $30 ; Write Single sector
CMDWRITE   EQU $30 ; Write Single sector
CMDFEATURE EQU $EF
CMDFEATURE EQU $EF
FEAT8BIT   EQU $01 ; enable 8 bit transfers
FEAT8BIT   EQU $01 ; enable 8 bit transfers
HEADLBA    EQU $E0
HEADLBA    EQU $E0
*
*
* Status bit equates
* Status bit equates
*
*
BUSY       EQU $80
BUSY       EQU $80
DRDY       EQU $40
DRDY       EQU $40
DRQ        EQU $08
DRQ        EQU $08
ERR        EQU $01
ERR        EQU $01
*
*
* Start of Program
* Start of Program
*
*
         ORG $0100
         ORG $0100
START    LBRA START1
START    LBRA START1
*
*
* DATA STORAGE
* DATA STORAGE
*
*
SECNUM   FCB $00,$00,$00
SECNUM   FCB $00,$00,$00
CPORT    FDB $E000
CPORT    FDB $E000
ECHO     FCB $FF
ECHO     FCB $FF
*
*
* SECTOR BUFFER
* SECTOR BUFFER
*
*
SECBUF   RMB 512
SECBUF   RMB 512
*
*
* PROGRAM STACK
* PROGRAM STACK
*
*
         RMB 64
         RMB 64
STACK    EQU *
STACK    EQU *
*
*
* Initialization
* Initialization
*
*
START1 LDS #STACK
START1 LDS #STACK
*
*
* Clear sector buffer
* Clear sector buffer
*
*
       LDX #SECBUF
       LDX #SECBUF
       LDY #512
       LDY #512
ZEROLP CLR ,X+
ZEROLP CLR ,X+
       LEAY -1,Y
       LEAY -1,Y
       BNE ZEROLP
       BNE ZEROLP
*
*
* INITIALIZE CF CARD FOR 8 BIT LBA MODE
* INITIALIZE CF CARD FOR 8 BIT LBA MODE
*
*
       JSR WAITRDY
       JSR WAITRDY
       LDA #HEADLBA
       LDA #HEADLBA
       STA CF_HEAD
       STA CF_HEAD
       JSR WAITRDY
       JSR WAITRDY
       LDA #FEAT8BIT
       LDA #FEAT8BIT
       STA CF_FEATURE
       STA CF_FEATURE
       LDA #CMDFEATURE
       LDA #CMDFEATURE
       STA CF_COMAND
       STA CF_COMAND
       JSR WAITRDY
       JSR WAITRDY
*
*
* DISPLAY TITTLE BANNER
* DISPLAY TITTLE BANNER
*
*
       LDX #TTLMSG
       LDX #TTLMSG
       JSR PDATA
       JSR PDATA
*
*
* COMMAND LOOP
* COMMAND LOOP
* R - READ
* R - READ
* W - WRITE
* W - WRITE
* N - NEXT
* N - NEXT
* P - PREV
* P - PREV
* M - MODIFY
* M - MODIFY
* Q - QUIT
* Q - QUIT
*
*
CMDLP  LDX #CMDMSG
CMDLP  LDX #CMDMSG
       JSR PDATA
       JSR PDATA
       JSR ECHON
       JSR ECHON
       CMPA #'R'
       CMPA #'R'
       BEQ READ
       BEQ READ
       CMPA #'N'
       CMPA #'N'
       BEQ NEXT
       BEQ NEXT
       CMPA #'P'
       CMPA #'P'
       BEQ PREV
       BEQ PREV
       CMPA #'W'
       CMPA #'W'
       LBEQ WRITE
       LBEQ WRITE
       CMPA #'M'
       CMPA #'M'
       BEQ MODIFY
       BEQ MODIFY
       CMPA #'Q'
       CMPA #'Q'
       BEQ QUIT
       BEQ QUIT
       LDX #WOTMSG
       LDX #WOTMSG
       JSR PSTRNG
       JSR PSTRNG
       BRA CMDLP
       BRA CMDLP
*
*
* QUIT
* QUIT
*
*
QUIT   JMP [$F800]
QUIT   JMP [$F800]
*
*
* MODIFY SECTOR
* MODIFY SECTOR
*
*
MODIFY JSR MEMCHG
MODIFY JSR MEMCHG
       BRA CMDLP
       BRA CMDLP
*
*
* NEXT SECTOR (READ)
* NEXT SECTOR (READ)
* INCREMENT SECTOR NUMBER
* INCREMENT SECTOR NUMBER
* WRAPS AROUND TO ZERO ON $FFFFFF
* WRAPS AROUND TO ZERO ON $FFFFFF
*
*
NEXT   LDX SECNUM+1
NEXT   LDX SECNUM+1
       LEAX 1,X
       LEAX 1,X
       STX SECNUM+1
       STX SECNUM+1
       BNE READS
       BNE READS
       INC SECNUM
       INC SECNUM
       BRA READS
       BRA READS
*
*
* PREVIOUS SECTOR (READ)
* PREVIOUS SECTOR (READ)
* DECREMENT SECTOR NUMBER
* DECREMENT SECTOR NUMBER
* DON'T DECREMENT PAST $000000
* DON'T DECREMENT PAST $000000
*
*
PREV   LDX SECNUM+1
PREV   LDX SECNUM+1
       BNE PREV1
       BNE PREV1
       TST SECNUM
       TST SECNUM
       BEQ READS
       BEQ READS
       DEC SECNUM
       DEC SECNUM
PREV1  LEAX -1,X
PREV1  LEAX -1,X
       STX SECNUM+1
       STX SECNUM+1
       BRA READS
       BRA READS
*
*
* READ SECTORS FROM CF
* READ SECTORS FROM CF
*
*
READ   LDX #SECPMT
READ   LDX #SECPMT
       JSR PSTRNG
       JSR PSTRNG
       JSR IN6HEX
       JSR IN6HEX
       BVS RDEXIT
       BVS RDEXIT
       STB SECNUM
       STB SECNUM
       STX SECNUM+1
       STX SECNUM+1
*
*
READS  LDA #$01
READS  LDA #$01
       STA CF_SECCNT
       STA CF_SECCNT
       LDA SECNUM+2
       LDA SECNUM+2
       STA CF_SECNUM
       STA CF_SECNUM
       LDA SECNUM+1
       LDA SECNUM+1
       STA CF_CYLLO
       STA CF_CYLLO
       LDA SECNUM+0
       LDA SECNUM+0
       STA CF_CYLHI
       STA CF_CYLHI
*
*
       LDA #CMDREAD ; IDE READ MULTIPLE
       LDA #CMDREAD ; IDE READ MULTIPLE
       STA CF_COMAND
       STA CF_COMAND
       JSR WAITRDY
       JSR WAITRDY
*
*
       LDX #SECBUF
       LDX #SECBUF
       LDY #512
       LDY #512
*
*
* READ LOOP
* READ LOOP
*
*
RDLOOP JSR WAITDRQ
RDLOOP JSR WAITDRQ
       LDA CF_DATA
       LDA CF_DATA
       STA ,X+
       STA ,X+
       LEAY -1,Y
       LEAY -1,Y
       BNE RDLOOP
       BNE RDLOOP
*
*
       JSR WAITRDY
       JSR WAITRDY
       JSR MEMDUMP
       JSR MEMDUMP
RDEXIT JMP CMDLP
RDEXIT JMP CMDLP
*
*
* WRITE SECTOR TO CF
* WRITE SECTOR TO CF
*
*
WRITE  LDX #SECPMT
WRITE  LDX #SECPMT
       JSR PSTRNG
       JSR PSTRNG
       JSR IN6HEX
       JSR IN6HEX
       BVS WREXIT
       BVS WREXIT
       STB SECNUM
       STB SECNUM
       STX SECNUM+1
       STX SECNUM+1
*
*
       LDA #$01
       LDA #$01
       STA CF_SECCNT
       STA CF_SECCNT
       LDA SECNUM+2
       LDA SECNUM+2
       STA CF_SECNUM
       STA CF_SECNUM
       LDA SECNUM+1
       LDA SECNUM+1
       STA CF_CYLLO
       STA CF_CYLLO
       LDA SECNUM+0
       LDA SECNUM+0
       STA CF_CYLHI
       STA CF_CYLHI
*
*
       LDA #CMDWRITE; IDE WRITE MULTIPLE
       LDA #CMDWRITE; IDE WRITE MULTIPLE
       STA CF_COMAND
       STA CF_COMAND
       JSR WAITRDY
       JSR WAITRDY
*
*
       LDX #SECBUF
       LDX #SECBUF
       LDY #512
       LDY #512
*
*
* WRITE LOOP
* WRITE LOOP
*
*
WRLOOP JSR WAITDRQ
WRLOOP JSR WAITDRQ
       LDA ,X+
       LDA ,X+
       STA CF_DATA
       STA CF_DATA
       LEAY -1,Y
       LEAY -1,Y
       BNE WRLOOP
       BNE WRLOOP
*
*
       JSR WAITRDY
       JSR WAITRDY
WREXIT JMP CMDLP
WREXIT JMP CMDLP
*
*
* WAIT UNTIL READY
* WAIT UNTIL READY
*
*
WAITRDY LDA CF_STATUS
WAITRDY LDA CF_STATUS
        BITA #BUSY
        BITA #BUSY
        BNE WAITRDY
        BNE WAITRDY
        LDA CF_STATUS
        LDA CF_STATUS
        BITA #DRDY
        BITA #DRDY
        BEQ WAITRDY
        BEQ WAITRDY
        RTS
        RTS
*
*
* WAIT FOR DATA REQUEST
* WAIT FOR DATA REQUEST
*
*
WAITDRQ LDA CF_STATUS
WAITDRQ LDA CF_STATUS
        BITA #DRQ
        BITA #DRQ
        BEQ WAITDRQ
        BEQ WAITDRQ
        RTS
        RTS
*
*
* DUMP SECTOR IN MEMORY
* DUMP SECTOR IN MEMORY
*
*
MEMDUMP LDX  #SECMSG
MEMDUMP LDX  #SECMSG
        JSR  PSTRNG
        JSR  PSTRNG
        LDA  SECNUM
        LDA  SECNUM
        JSR  OUT2H
        JSR  OUT2H
        LDX  SECNUM+1
        LDX  SECNUM+1
        JSR  OUT4H
        JSR  OUT4H
        JSR  PCRLF
        JSR  PCRLF
        LDY  #$0000
        LDY  #$0000
        LEAX #$1FF,Y
        LEAX #$1FF,Y
*
*
* ADJUST LOWER AND UPPER ADDRESS LIMITS
* ADJUST LOWER AND UPPER ADDRESS LIMITS
* TO EVEN 16 BYTE BOUNDRIES.
* TO EVEN 16 BYTE BOUNDRIES.
*
*
* IF LOWER ADDR = $4532
* IF LOWER ADDR = $4532
* LOWER BOUNDS WILL BE ADJUSTED TO = $4530.
* LOWER BOUNDS WILL BE ADJUSTED TO = $4530.
*
*
* IF UPPER ADDR = $4567
* IF UPPER ADDR = $4567
* 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  SECBUF,X     GET FROM MEMORY HEX BYTE TO PRINT
ELOOP   LDA  SECBUF,X     GET FROM MEMORY HEX BYTE TO PRINT
        LEAX 1,X
        LEAX 1,X
        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  SECBUF,X     GET CHARACTER FROM MEMORY
EDPASC  LDA  SECBUF,X     GET CHARACTER FROM MEMORY
        LEAX 1,X
        LEAX 1,X
        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
*
*
*
*
***** "M" MEMORY EXAMINE AND CHANGE *****
***** "M" MEMORY EXAMINE AND CHANGE *****
*
*
* RESTRICT ADDRESSING RANGE TO 512 BYTES ($000 - $1FF)
* RESTRICT ADDRESSING RANGE TO 512 BYTES ($000 - $1FF)
*
*
MEMCHG  LDX  #MEMMSG
MEMCHG  LDX  #MEMMSG
        JSR  PSTRNG
        JSR  PSTRNG
        LBSR IN3HEX  INPUT ADDRESS
        LBSR IN3HEX  INPUT ADDRESS
        BVS  CHRTN   IF NOT HEX, RETURN
        BVS  CHRTN   IF NOT HEX, RETURN
        CMPX #$0200
        CMPX #$0200
        BHS  CHRTN
        BHS  CHRTN
        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  SECBUF,Y GET CONTENTS OF CURRENT ADDR.
        LDA  SECBUF,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  SECBUF,Y      CHANGE BYTE IN MEMORY
CHANGE  STA  SECBUF,Y      CHANGE BYTE IN MEMORY
        CMPA SECBUF,Y      DID MEMORY BYTE CHANGE?
        CMPA SECBUF,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  CMPY #$01FF
FORWRD  CMPY #$01FF
        BEQ  MEMC2
        BEQ  MEMC2
        LEAY 1,Y     POINT TO NEXT HIGHER MEM LOCATION
        LEAY 1,Y     POINT TO NEXT HIGHER MEM LOCATION
        BRA  MEMC2   PRINT LOCATION & CONTENTS
        BRA  MEMC2   PRINT LOCATION & CONTENTS
BACK    CMPY #$0000
BACK    CMPY #$0000
        BEQ  MEMC2
        BEQ  MEMC2
        LEAY -1,Y    POINT TO LAST MEM LOCATION
        LEAY -1,Y    POINT TO LAST MEM LOCATION
        BRA  MEMC2   PRINT LOCATION & CONTENTS
        BRA  MEMC2   PRINT LOCATION & CONTENTS
*
*
* 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.
*
*
* IN6HEX - MS BYTE IN ACCB
* IN6HEX - MS BYTE IN ACCB
*          LS WORD IN X REG
*          LS WORD IN X REG
*
*
IN6HEX LEAS -3,S
IN6HEX LEAS -3,S
       BSR  BYTE
       BSR  BYTE
       BVS  NOTHEX
       BVS  NOTHEX
       STA  0,S
       STA  0,S
       BSR  BYTE
       BSR  BYTE
       BVS  NOTHEX
       BVS  NOTHEX
       STA  1,S
       STA  1,S
       BSR  BYTE
       BSR  BYTE
       BVS  NOTHEX
       BVS  NOTHEX
       STA  2,S
       STA  2,S
       CLRA
       CLRA
       PULS B,X,PC
       PULS B,X,PC
*
*
* INPUT 3 HEX DIGITS
* INPUT 3 HEX DIGITS
* RESULT RETURNED IN X
* RESULT RETURNED IN X
*
*
IN3HEX BSR INHEX INPUT HEX (1 HEX CHAR)
IN3HEX BSR INHEX INPUT HEX (1 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 #$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 #$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
*
*
* 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
       BSR PDATA  PRINT MSG
       BSR PDATA  PRINT MSG
       PULS X,PC RESTORE IX
       PULS X,PC RESTORE IX
PRINT  BSR OUTCH
PRINT  BSR OUTCH
*
*
* PDATA
* PDATA
*
*
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  ;
*
*
*
*
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
GETSTA  LDX  CPORT POINT TO TERMINAL PORT
        LDA  ,X  FETCH PORT STATUS
        LDA  ,X  FETCH PORT STATUS
        BITA #1 TEST READY BIT, RDRF ?
        BITA #1 TEST READY BIT, RDRF ?
        BEQ  GETSTA IF NOT RDY, THEN TRY AGAIN
        BEQ  GETSTA IF NOT RDY, THEN TRY AGAIN
GETST1  LDA  1,X FETCH CHAR
GETST1  LDA  1,X FETCH CHAR
        PULS X,PC RESTORE IX
        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
        LDA  [CPORT] FETCH PORT STATUS
        BITA #1 TEST READY BIT, RDRF ?
        BITA #1 TEST READY BIT, RDRF ?
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.
* THE CHAR. TO BE OUTPUT IS
* THE CHAR. TO BE OUTPUT IS
* PASSED IN THE A REGISTER.
* PASSED IN THE A REGISTER.
* ALL REGISTERS ARE PRESERVED.
* ALL REGISTERS ARE PRESERVED.
*
*
OUTCH   PSHS A,X    SAVE A ACCUM AND IX
OUTCH   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
        PULS A      GET CHAR. FOR XMIT
        STA  1,X    XMIT CHAR.
        STA  1,X    XMIT CHAR.
        PULS X,PC   RESTORE IX
        PULS X,PC   RESTORE IX
*
*
*
*
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  #$11   SET 8 DATA, 2 STOP AN 0 PARITY
        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
*
*
* MESSAGE STRINGS
* MESSAGE STRINGS
*
*
TTLMSG FCB $0A,$0D
TTLMSG FCB $0A,$0D
       FCC "COMPACT FLASH SECTOR READ/WRITE UTILITY"
       FCC "COMPACT FLASH SECTOR READ/WRITE UTILITY"
       FCB $04
       FCB $04
CMDMSG FCB $0A,$0D
CMDMSG FCB $0A,$0D
       FCC "(R) READ SECTOR"
       FCC "(R) READ SECTOR"
       FCB $0A,$0D
       FCB $0A,$0D
       FCC "(W) WRITE SECTOR"
       FCC "(W) WRITE SECTOR"
       FCB $0A,$0D
       FCB $0A,$0D
       FCC "(N) NEXT SECTOR"
       FCC "(N) NEXT SECTOR"
       FCB $0A,$0D
       FCB $0A,$0D
       FCC "(P) PREV SECTOR"
       FCC "(P) PREV SECTOR"
       FCB $0A,$0D
       FCB $0A,$0D
       FCC "(M) MODIFY SECTOR"
       FCC "(M) MODIFY SECTOR"
       FCB $0A,$0D
       FCB $0A,$0D
       FCC "(Q) QUIT"
       FCC "(Q) QUIT"
       FCB $0A,$0D
       FCB $0A,$0D
       FCC ": "
       FCC ": "
       FCB $04
       FCB $04
SECPMT FCC "SECTOR NUMBER (6 HEX) : "
SECPMT FCC "SECTOR NUMBER (6 HEX) : "
       FCB $04
       FCB $04
SECMSG FCC "SECTOR NUMBER - $"
SECMSG FCC "SECTOR NUMBER - $"
       FCB $04
       FCB $04
MEMMSG FCB $0D,$0A
MEMMSG FCB $0D,$0A
       FCC "MEMORY ADDRESS (3 HEX): "
       FCC "MEMORY ADDRESS (3 HEX): "
       FCB $04
       FCB $04
MSG5   FCC " - "
MSG5   FCC " - "
       FCB $04
       FCB $04
MSG2   FCB $00,$00,$0A,$0D,$00,$00,$00,$04
MSG2   FCB $00,$00,$0A,$0D,$00,$00,$00,$04
WOTMSG FCC "What ?"
WOTMSG FCC "What ?"
       FCB $0D,$0A,$04
       FCB $0D,$0A,$04
*
*
       END START
       END START
 
 

powered by: WebSVN 2.1.0

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