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

Subversion Repositories System09

[/] [System09/] [trunk/] [src/] [Flex9/] [f9-cli.asm] - Rev 141

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

*********************************************
*
* FLEX COMMAND LINE INTERPRETER & SUBROUTINES
*
*********************************************
 ORG $CD00
*
** FLEX JUMPS
*
COLDS JMP >COLD1
WARMS JMP >WARM1
RENTER JMP >RENT1
INCH JMP >INCH
INCH2 JMP >INCH2
OUTCH JMP >OUTCH
OUTCH2 JMP >OUTCH2
GETCHR JMP >GETCH1
PUTCHR JMP >PUTCH1
INBUFF JMP >INBUF1
PSTRNG JMP >PSTRG1
CLASS JMP >CLASS1
PCRLF JMP >PCRLF1
NXTCH JMP >NXTCH1
RSTRIO JMP >RSTIO1
GETFIL JMP >GETFL1
LOAD JMP >LOAD1
SETEXT JMP >SETEX1
ADDBX JMP >ADDBX1
OUTDEC JMP >OUTDC1
OUTHEX JMP >OUTHX1
RPTERR JMP >RPTER1
GETHEX JMP >GETHX1
OUTADR JMP >OUTAD1
INDEC JMP >INDEC1
DOCMND JMP >DOCMD1
ZCD4E JMP >ZCD4E
 JMP >ZCE05
 JMP >ZCE05
*
** COLD START ENTRY
*
COLD1 LDS #ZC07F
ZCD5B CLR >LASTRM
 JSR >ZD400
 CLR >CMDFLG
 JSR >ZD3FD
*
** WARM START ENTRY
*
WARM1 LDS #ZC07F
 JSR >WARMDR
 LDX #WARMS
 STX >ESCVEC
 LDX #PRSPL1
 STX [SWIVVC]
 LDX >IHNDVC
 STX [IRQVVC]
 LDX #ZCCF8
 STX >ZCC31
 CLR >ZCC34
 CLR >ZCC4C
 BSR RSTIO1
 LDA >LASTRM
 CMPA >EOLCHR
 BNE ZCD9D
 INC >LINPTR+1
 BRA RENT1

ZCD9D TST >CMDFLG
 LBNE ZD33B
 JSR >FMSCLS
 BNE ZCD5B
 LDX #PMTSTR
 JSR >PSTRG1
 BSR INBUF1
*
** MAIN CONTROL LOOP
*
RENT1 J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R
 JSR >RPTER1
 JMP >WARMS
*
** OUTPUT CHARACTER HONOURING TTYSET
*
PUTCH1 TST >SIOFLG
 BNE ZCF66
 CMPA #$1F
 BHI ZCF4F
 CLR >CURCOL
 BRA ZCF66

ZCF4F INC >CURCOL
 PSHS A
 LDA >WIDCNT
 BEQ ZCF64
 CMPA >CURCOL
 BCC ZCF64
 JSR >PCRLF1
 INC >CURCOL
ZCF64 PULS A
ZCF66 PSHS A
 TST >OUTSWT
 BNE ZCF80
 TST >FOPADR
 BEQ ZCF76
 BSR ZCF29
 BRA ZCF83

ZCF76 TST >FIPADR
 BNE ZCF83
 JSR >OUTCH
 BRA ZCF83
ZCF80 JSR >OUTCH2
ZCF83 PULS A
 RTS 

OUTDC1 CLR >ZCC4A
 STB >TRNFLG
 LDA #$04
 STA >ZCC4D
 LDD ,X
 LDX #DECTBL
ZCF96 BSR ZCFA3
 LEAX $02,X
 DEC >ZCC4D
 BNE ZCF96
 TFR B,A
 BRA OUTHXR

ZCFA3 CLR >ZCC4B
ZCFA6 CMPD ,X
 BCS ZCFB2
 SUBD ,X
 INC >ZCC4B
 BRA ZCFA6

ZCFB2 PSHS A
 LDA >ZCC4B
 BNE ZCFC9
 TST >ZCC4A
 BNE ZCFC9
 TST >TRNFLG
 BEQ ZCFCE
 LDA #$20
 BSR ZCFEA
 BRA ZCFCE

ZCFC9 INC >ZCC4A
 BSR OUTHXR
ZCFCE PULS PC,A
*
** DISPLAY HEX ADDRESS
*
OUTAD1 BSR OUTHX1
 LEAX $01,X
*
** OUPUT HEX BYTE
*
OUTHX1 LDA ,X
 BSR OUTHXL
 LDA ,X
 BRA OUTHXR

OUTHXL LSRA
 LSRA 
 LSRA 
 LSRA 
OUTHXR ANDA #$0F
 ADDA #$30
 CMPA #$39
 BLS ZCFEA
 ADDA #$07
ZCFEA JMP >PUTCH1
*
** CLASSIFY CHARACTER ALHA/NUMERIC
*
CLASS1 CMPA #'0
 BCS ZD005
 CMPA #'9
 BLS ZD00B
 CMPA #'A
 BCS ZD005
 CMPA #'Z
 BLS ZD00B
 CMPA #'a $61
 BCS ZD005
 CMPA #'z $7A
 BLS ZD00B
ZD005 ORCC #$01
 STA >LASTRM
 RTS 
ZD00B ANDCC #$FE
 RTS 
*
** GET NEXT CHARACTER FROM FILE
*
NXTCH1 PSHS X
 LDX >LINPTR
 LDA >CURCHR
 STA >PRVCHR
ZD019 LDA ,X+
 STA >CURCHR
 CMPA #$0D
 BEQ ZD032
 CMPA >EOLCHR
 BEQ ZD032
 STX >LINPTR
 CMPA #$20
 BNE ZD032
 CMPA ,X
 BEQ ZD019
ZD032 BSR CLASS1
 PULS PC,X
*
** PARSE FILE SPEC. IN LINE BUFFER
*
GETFL1 LDA #$15
 STA $01,X
 LDA #$FF
 STA $03,X
 CLR $04,X
 CLR $0C,X
 JSR >ZD0D4
 LDA #$08
 STA >ZCC4B
 BSR ZD080
 BCS ZD07C
 BNE ZD05F
 BSR ZD080
 BCS ZD07C
 BNE ZD05F
 CMPX >ZCC3F
 BEQ ZD0C7
 BSR ZD080
 BLS ZD0C7
ZD05F LDX >ZCC3F
 TST $04,X
 BEQ ZD0C7
 TST $03,X
 BPL ZD079
 TST >ZCC0D
 BEQ ZD074
 LDA >SYSDRV
 BRA ZD077

ZD074 LDA >WRKDRV
ZD077 STA $03,X
ZD079 CLR >ZCC0D
ZD07C LDX >ZCC3F
 RTS 

ZD080 BSR NXTCH1
 BCS ZD0C7
 CMPA #$39
 BHI ZD09D
 LDX >ZCC3F
 TST $03,X
 BPL ZD0C7
 ANDA #$03
 STA $03,X
 JSR >NXTCH1
 BCC ZD0C7
ZD098 CMPA #$2E
 ANDCC #$FE
 RTS 

ZD09D LDB >ZCC4B
 BMI ZD0C7
 PSHS B
 SUBB #$05
 STB >ZCC4B
 PULS B
ZD0AB CMPA >MAPUP
 BCS ZD0B2
 SUBA #$20
ZD0B2 STA $04,X
 LEAX $01,X
 DECB 
 JSR >NXTCH1
 BCC ZD0C4
 CMPA #$2D
 BEQ ZD0C4
 CMPA #$5F
 BNE ZD0CA
ZD0C4 TSTB 
 BNE ZD0AB
ZD0C7 ORCC #$01
 RTS 

ZD0CA TSTB 
 BEQ ZD098
 CLR $04,X
 LEAX $01,X
 DECB 
 BRA ZD0CA

ZD0D4 STX >ZCC3F
 LDX >LINPTR
ZD0DA LDA ,X
 CMPA #$20
 BNE ZD0E4
 LEAX $01,X
 BRA ZD0DA
ZD0E4 STX >LINPTR
 LDX >ZCC3F
 RTS 
*
** DEFAULT FILE EXTENSION
*
SETEX1 PSHS Y,X
 LDB $0C,X
 BNE ZD109
 LDY #EXTTBL
 CMPA #$0B
 BHI ZD109
 LDB #$03
 MUL 
 LEAY B,Y
 LDB #$03
ZD100 LDA ,Y+
 STA $0C,X
 LEAX $01,X
 DECB 
 BNE ZD100
ZD109 PULS PC,Y,X
*
** STANDARD FILE NAME EXTTENSIONS
*
EXTTBL FCC "BIN"
 FCC "TXT"
 FCC "CMD"
 FCC "BAS"
 FCC "SYS"
 FCC "BAK"
 FCC "SCR"
 FCC "DAT"
 FCC "BAC"
 FCC "DIR"
 FCC "PRT"
 FCC "OUT"
*
** READ A HEX ADDRESS FROM THE LINE BUFFER
*
GETHX1 JSR >ZD21E
ZD132 JSR >NXTCH1
 BCS ZD159
 BSR ZD15F
 BCS ZD153
 PSHS B
 LDB #$04
ZD13F ASL >LODOFF+1
 ROL >LODOFF
 DECB 
 BNE ZD13F
 PULS B
 ADDA >LODOFF+1
 STA >LODOFF+1
 INCB 
 BRA ZD132

ZD153 JSR >NXTCH1
 BCC ZD153
 RTS 

ZD159 LDX >LODOFF
 ANDCC #$FE
 RTS 

ZD15F SUBA #$47
 BPL ZD172
 ADDA #$06
 BPL ZD16B
 ADDA #$07
 BPL ZD172
ZD16B ADDA #$0A
 BMI ZD172
 ANDCC #$FE
 RTS 

ZD172 ORCC #$01
 RTS 

INDEC1 JSR >ZD21E
ZD178 JSR >NXTCH1
 BCS ZD159
 CMPA #$39
 BHI ZD153
 ANDA #$0F
 PSHS B
 PSHS A
 LDD >LODOFF
 ASLB 
 ROLA 
 ASLB 
 ROLA 
 ASLB 
 ROLA 
 ADDD >LODOFF
 ADDD >LODOFF
 ADDB ,S+
 ADCA #$00
 STD >LODOFF
 PULS B
 INCB 
 BRA ZD178
*
** LOAD BINARY FILE
*
LOAD1 CLR >TRNFLG
ZD1A5 BSR ZD1E4
 CMPA #$02
 BEQ ZD1C0
 CMPA #$16
 BNE ZD1A5
 BSR ZD1E4
 STA >TRNVEC
 BSR ZD1E4
 STA >TRNVEC+1
 LDA #$01
 STA >TRNFLG
 BRA ZD1A5

ZD1C0 BSR ZD1E4
 TFR A,B
 BSR ZD1E4
 EXG A,B
 ADDD >LODOFF
 STD >ZCC3D
 BSR ZD1E4
 TFR A,B
 TSTA 
 BEQ ZD1A5
ZD1D5 BSR ZD1E4
 LDX >ZCC3D
 STA ,X+
 STX >ZCC3D
 DECB 
 BNE ZD1D5
 BRA ZD1A5

ZD1E4 LDX #FCB
 JSR >FMS
 BEQ ZD1FD
 LDA $01,X
 CMPA #$08
 BNE ZD200
 LEAS $02,S
ZD1F4 LDA #$04
 STA ,X
 JSR >FMS
 BNE ZD20A
ZD1FD ANDCC #$FE
 RTS 

ZD200 STA >ERRTYP
 CMPA #$04
 BNE ZD20A
 ORCC #$01
 RTS 

ZD20A BSR RPTER1
 JMP >ZCDE4
*
** 'GET' - LOAD BINARY FILE
*
GETCMD LDA #$00
 BSR ZD248
 BCS ZD224
 BSR ZD21E
 INC >ZCC4C
 BSR LOAD1
 BRA GETCMD

ZD21E CLRA 
 CLRB 
 STD >LODOFF
 RTS 

ZD224 LDB >ZCC4C
 LBEQ ZCDD9
 JMP >WARMS

ZD22E LDA #$02
 BSR ZD254
 BSR ZD21E
 JSR >LOAD1
 LDB >TRNFLG
 BEQ ZD240
 JMP [TRNVEC]

ZD240 LDX #NTRMSG
 LDA #$81
 JMP >ZCDDE

ZD248 PSHS A
 LDX #FCB
 JSR >GETFL1
 PULS A
 BCS ZD26E
ZD254 LDX #FCB
 JSR >SETEX1
 LDX #FCB
 LDA #$01
 STA ,X
 JSR >ZD1E4
 LBCS ZD323
 LDA #$FF
 STA $3B,X
 RTS 

ZD26E LDA >LASTRM
 CMPA #$0D
 BEQ ZD27C
 CMPA >EOLCHR
 LBNE ZCDD9
ZD27C ORCC #$01
 RTS 

RPTER1 PSHS Y,X
 LDA $01,X
 STA >ERRTYP
 BEQ ZD2EB
 JSR >RSTIO1
 LDY >ERRVEC
 BNE ZD299
 CMPA #$10
 BEQ ZD2ED
 LDY #ZD361
ZD299 LDX #FCB
 TST $02,X
 BEQ ZD2A9
 LDA #$04
 STA ,X
 JSR >FMS
 BNE ZD2D7
ZD2A9 LDX #ZC838
 LDB #$0B
 BSR ZD31E
 LDX #FCB
 LDA >SYSDRV
 STA $03,X
 LDA #$01
 STA ,X
 JSR >FMS
 BNE ZD2D7
 LDA >ERRTYP
 DECA 
 ASRA 
 ASRA 
 INCA 
 CLR $20,X
 STA $21,X
 LDA #$15
 STA ,X
 JSR >FMS
 BEQ ZD2F5
ZD2D7 LDX #DERMSG
 JSR >PSTRG1
 LDX >ZCC3F
 LDA >ERRTYP
 STA $01,X
 CLR ,X
 CLRB 
 JSR >OUTDC1
ZD2EB PULS PC,Y,X

ZD2ED LDX #DNRMSG
 JSR >PSTRG1
 BRA ZD2EB

ZD2F5 JSR >PCRLF1
 LDX #FCB
 LDA >ERRTYP
 DECA 
 ANDA #$03
 LDB #$3F
 MUL 
 ADDB #$04
 STB $22,X
ZD309 JSR >FMS
 BNE ZD2D7
 JSR >PUTCH1
 CMPA #$0D
 BNE ZD309
 LDA #$04
 STA ,X
 JSR >FMS
 BRA ZD2EB
ZD31E PSHS Y,X
 JMP >ZD100

ZD323 LDX #NFDMSG NOT FOUND
 JMP >ZCDE1
*
** CALL FLEX AS A SUBROUTINE
*
DOCMD1 PULS B,A
 STD >ZCC43
ZD32E STS >ZCC45
 CLR >ERRTYP
 INC >CMDFLG
 JMP >ZCDB8
ZD33B CLR >CMDFLG
 LDS >ZCC45
 LDB >ERRTYP
 JMP [ZCC43]
*
** ADD ACCB TO IX
*
ADDBX1 ABX
 RTS

ZD34B TST >ZCCFC
 BNE ZD354
 JMP [MONVEC]

ZD354 LDX #FCB
 LDA #$1B
 STA $01,X
 JSR >RPTER1
 JMP >WARM1

ZD361 FCC /ERRORS/
 FCB $00,$00
 FCC /SYS/
 END

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

powered by: WebSVN 2.1.0

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