2016-11-01 14:36:32 +00:00
|
|
|
|
NEW
|
2018-11-17 17:17:13 +00:00
|
|
|
|
PREFIX
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2016-11-01 14:36:32 +00:00
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2018-07-23 15:28:42 +00:00
|
|
|
|
.TF BIN/CAT
|
2016-11-01 14:36:32 +00:00
|
|
|
|
*--------------------------------------
|
2018-07-23 15:28:42 +00:00
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
2018-10-02 15:52:30 +00:00
|
|
|
|
.INB INC/MLI.I
|
|
|
|
|
.INB INC/MLI.E.I
|
2016-11-01 14:36:32 +00:00
|
|
|
|
*--------------------------------------
|
2019-02-27 16:44:11 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ZPPTR1 .BS 2
|
|
|
|
|
ZPBufPtr .BS 2
|
|
|
|
|
ByteIndex .BS 1
|
|
|
|
|
ZS.END .ED
|
2016-11-01 14:36:32 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
2018-10-02 15:52:30 +00:00
|
|
|
|
.DA #S.PS.F.EVENT S.PS.F
|
|
|
|
|
.DA #0
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #16 SS
|
2019-02-27 16:44:11 +00:00
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
2016-11-01 14:36:32 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
2019-02-27 22:02:56 +00:00
|
|
|
|
L.MSG.CRLF .DA MSG.CRLF
|
2016-11-01 14:36:32 +00:00
|
|
|
|
L.MSG.LINENUM .DA MSG.LINENUM
|
|
|
|
|
L.MSG.CTRLCHAR .DA MSG.CTRLCHAR
|
|
|
|
|
L.ASCII .DA ASCII
|
2019-02-27 15:00:56 +00:00
|
|
|
|
L.MSG.STACK .DA MSG.STACK
|
2016-11-01 14:36:32 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
2019-02-27 22:02:56 +00:00
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN
|
2017-10-23 15:39:19 +00:00
|
|
|
|
.1 >INC.G ArgCount
|
2018-10-16 15:48:03 +00:00
|
|
|
|
>SYSCALL ArgV
|
2017-10-23 15:39:19 +00:00
|
|
|
|
bcs .7
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2017-10-23 15:39:19 +00:00
|
|
|
|
>STYA ZPPtr1
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-01-25 12:43:50 +00:00
|
|
|
|
|
2016-11-01 14:36:32 +00:00
|
|
|
|
lda (ZPPtr1)
|
2017-10-23 15:39:19 +00:00
|
|
|
|
cmp #'-'
|
2016-11-01 14:36:32 +00:00
|
|
|
|
bne .4
|
|
|
|
|
|
2017-10-23 15:39:19 +00:00
|
|
|
|
ldy #1
|
2016-11-01 14:36:32 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
|
|
|
|
|
ldx OptionList
|
|
|
|
|
|
|
|
|
|
.2 cmp OptionList,x
|
|
|
|
|
beq .3
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
2018-08-22 15:23:27 +00:00
|
|
|
|
.99 >PUSHBI 0
|
|
|
|
|
>LDYA L.MSG.USAGE
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2018-10-21 20:54:07 +00:00
|
|
|
|
lda #E.SYN
|
2016-11-01 14:36:32 +00:00
|
|
|
|
sec
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.9 rts
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
|
|
|
|
.3 ldy OptionVars-1,x
|
|
|
|
|
lda #$80
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .1
|
|
|
|
|
|
2017-10-23 15:39:19 +00:00
|
|
|
|
.4 >INC.G FileCount
|
2016-11-01 14:36:32 +00:00
|
|
|
|
bra .1 scan for any other args
|
|
|
|
|
|
2017-10-23 15:39:19 +00:00
|
|
|
|
.7 >LDA.G FileCount
|
2016-11-01 14:36:32 +00:00
|
|
|
|
beq .99
|
|
|
|
|
|
2017-09-19 06:39:27 +00:00
|
|
|
|
>LDYAI 256
|
2018-07-19 15:33:55 +00:00
|
|
|
|
>SYSCALL GetMem
|
2017-09-19 06:39:27 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPBufPtr
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hBuf
|
2016-11-01 14:36:32 +00:00
|
|
|
|
*--------------------------------------
|
2019-02-27 22:02:56 +00:00
|
|
|
|
CS.RUN.LOOP ldy #S.PS.hStdIn
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL feof
|
|
|
|
|
bcs .90 IO error
|
|
|
|
|
tay
|
|
|
|
|
beq .10 bo char
|
2019-02-20 16:07:43 +00:00
|
|
|
|
|
|
|
|
|
>SYSCALL GetChar
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bcs .9 IO error
|
2017-01-15 20:51:20 +00:00
|
|
|
|
|
|
|
|
|
cmp #$03 Ctrl-C
|
2019-02-27 22:02:56 +00:00
|
|
|
|
beq .9 Abort....
|
2017-01-15 20:51:20 +00:00
|
|
|
|
|
|
|
|
|
cmp #$13 Ctrl-S
|
|
|
|
|
bne .10
|
|
|
|
|
|
2017-09-19 06:39:27 +00:00
|
|
|
|
>LDA.G bPause
|
2017-01-15 20:51:20 +00:00
|
|
|
|
eor #$ff
|
|
|
|
|
sta (pData),y
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bne CS.RUN.LOOP
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2017-09-19 06:39:27 +00:00
|
|
|
|
.10 >LDA.G bPause
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bne CS.RUN.LOOP Pause...
|
2019-01-25 12:43:50 +00:00
|
|
|
|
|
2019-02-20 16:07:43 +00:00
|
|
|
|
.11 >LDA.G hFILE
|
2016-11-01 14:36:32 +00:00
|
|
|
|
bne .2
|
|
|
|
|
|
2017-10-23 15:39:19 +00:00
|
|
|
|
.1 >INC.G ArgIndex
|
2018-10-16 15:48:03 +00:00
|
|
|
|
>SYSCALL ArgV
|
2016-11-01 14:36:32 +00:00
|
|
|
|
bcs .99 No more arg...the end!
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2017-10-23 15:39:19 +00:00
|
|
|
|
lda (ZPPtr1)
|
2016-11-01 14:36:32 +00:00
|
|
|
|
cmp #'-'
|
|
|
|
|
beq .1 An option, skip...
|
|
|
|
|
|
|
|
|
|
>LDYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.OPEN
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.90 bcs .9
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2017-09-19 06:39:27 +00:00
|
|
|
|
>STA.G hFILE
|
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.2 >PUSHWI 256
|
2018-07-25 15:26:14 +00:00
|
|
|
|
>PUSHW ZPBufPtr
|
2019-02-27 22:02:56 +00:00
|
|
|
|
>LDA.G hFILE
|
|
|
|
|
|
|
|
|
|
>SYSCALL fgets
|
|
|
|
|
bcs .7
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.PRINT
|
|
|
|
|
bcc CS.RUN.LOOP
|
2019-02-28 21:41:05 +00:00
|
|
|
|
rts
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.7 cmp #MLI.E.EOF
|
2016-11-01 14:36:32 +00:00
|
|
|
|
bne .9
|
|
|
|
|
|
2017-01-15 20:51:20 +00:00
|
|
|
|
jsr CS.RUN.CLOSE
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
jmp CS.RUN.LOOP
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
|
|
|
|
.99 lda #0 Exit with no Error
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-02-27 22:02:56 +00:00
|
|
|
|
CS.RUN.OPEN phy
|
|
|
|
|
pha
|
2019-02-27 15:00:56 +00:00
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
lda #0
|
|
|
|
|
>STA.G bPrintedBlankLine Reset this flag for the new file
|
|
|
|
|
|
|
|
|
|
>PUSHWI 0 Aux type
|
|
|
|
|
>PUSHBI S.FI.T.TXT
|
|
|
|
|
>PUSHBI O.RDONLY+O.TEXT
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
ply
|
|
|
|
|
>SYSCALL FOpen
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.PRINT >INCW.G LineNum
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2017-09-19 06:39:27 +00:00
|
|
|
|
>LDA.G bSuppressBlankLine
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bpl .2
|
2017-08-22 06:37:03 +00:00
|
|
|
|
|
2017-09-19 06:39:27 +00:00
|
|
|
|
lda (ZPBufPtr)
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bne .1 Empty line ?
|
|
|
|
|
|
|
|
|
|
>LDA.G bPrintedBlankLine
|
2017-08-22 06:37:03 +00:00
|
|
|
|
bmi .8
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2017-08-22 06:37:03 +00:00
|
|
|
|
lda #$ff
|
2016-11-01 14:36:32 +00:00
|
|
|
|
sta (pData),y
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bra .2
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-28 21:41:05 +00:00
|
|
|
|
.1 >STZ.G bPrintedBlankLine
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.2 jsr CS.RUN.PRINTNUM
|
2019-02-28 18:48:38 +00:00
|
|
|
|
bcs .99
|
2016-11-03 11:00:00 +00:00
|
|
|
|
|
2017-09-19 06:39:27 +00:00
|
|
|
|
>LDA.G bPrintAll
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bmi .3
|
|
|
|
|
|
|
|
|
|
>LDYA ZPBufPtr
|
|
|
|
|
>SYSCALL puts
|
|
|
|
|
rts
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-28 18:48:38 +00:00
|
|
|
|
.3 stz ByteIndex
|
2019-02-27 22:02:56 +00:00
|
|
|
|
|
|
|
|
|
.4 ldy ByteIndex
|
2017-09-19 06:39:27 +00:00
|
|
|
|
lda (ZPBufPtr),y
|
2019-02-28 18:48:38 +00:00
|
|
|
|
beq .7
|
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
cmp #C.SPACE
|
|
|
|
|
bcc .5
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
>SYSCALL putchar
|
2019-02-28 18:48:38 +00:00
|
|
|
|
.99 bcs .9
|
|
|
|
|
bra .62
|
2019-02-27 22:02:56 +00:00
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.5 tax
|
2019-02-28 18:48:38 +00:00
|
|
|
|
|
|
|
|
|
>LDYA L.ASCII
|
2019-02-27 22:02:56 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
.6 dex
|
|
|
|
|
bmi .61
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
|
|
|
|
lda ZPPtr1
|
|
|
|
|
sec
|
|
|
|
|
adc (ZPPtr1)
|
|
|
|
|
sta ZPPtr1
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bcc .6
|
2016-11-01 14:36:32 +00:00
|
|
|
|
inc ZPPtr1+1
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bra .6
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.61 >PUSHW ZPPtr1
|
2018-08-22 15:23:27 +00:00
|
|
|
|
|
|
|
|
|
>PUSHBI 2
|
2019-02-27 16:44:11 +00:00
|
|
|
|
>LDYA L.MSG.CTRLCHAR
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2016-11-01 14:36:32 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2019-02-28 18:48:38 +00:00
|
|
|
|
.62 inc ByteIndex
|
2019-02-27 22:02:56 +00:00
|
|
|
|
bne .4
|
2016-11-01 14:36:32 +00:00
|
|
|
|
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.7 >PUSHBI 2
|
|
|
|
|
>LDYA L.MSG.CRLF
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
|
2016-11-01 14:36:32 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2016-11-03 11:00:00 +00:00
|
|
|
|
CS.RUN.PRINTNUM clc
|
2017-09-19 06:39:27 +00:00
|
|
|
|
>LDA.G bLineNum
|
2016-11-03 11:00:00 +00:00
|
|
|
|
bpl .8
|
|
|
|
|
|
2018-08-22 15:23:27 +00:00
|
|
|
|
>PUSHW.G LineNum
|
2017-09-19 06:39:27 +00:00
|
|
|
|
|
2018-08-22 15:23:27 +00:00
|
|
|
|
>PUSHBI 2
|
2016-11-03 11:00:00 +00:00
|
|
|
|
>LDYA L.MSG.LINENUM
|
2018-06-21 15:12:10 +00:00
|
|
|
|
>SYSCALL printf
|
2016-11-03 11:00:00 +00:00
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2017-09-19 06:39:27 +00:00
|
|
|
|
CS.QUIT >LDA.G hBuf
|
|
|
|
|
beq CS.RUN.CLOSE
|
2018-07-18 15:30:42 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2017-09-19 06:39:27 +00:00
|
|
|
|
|
2019-02-27 16:44:11 +00:00
|
|
|
|
CS.RUN.CLOSE >LDA.G hFILE
|
2017-01-15 20:51:20 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
lda #0
|
2016-11-01 14:36:32 +00:00
|
|
|
|
sta (pData),y
|
2017-01-15 20:51:20 +00:00
|
|
|
|
pla
|
2018-07-19 15:33:55 +00:00
|
|
|
|
>SYSCALL FClose
|
2017-01-15 20:51:20 +00:00
|
|
|
|
|
2016-11-01 14:36:32 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
2017-01-15 20:51:20 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
2016-11-01 14:36:32 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-02-27 15:00:56 +00:00
|
|
|
|
PrintStack >PUSHW pStack
|
|
|
|
|
>PUSHBI 2
|
|
|
|
|
>LDYA L.MSG.STACK
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-11-01 14:36:32 +00:00
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
2019-02-27 15:00:56 +00:00
|
|
|
|
MSG.STACK .AZ ">%H:"
|
2017-06-25 12:04:33 +00:00
|
|
|
|
OptionList >PSTR "ANSans"
|
2017-08-22 06:37:03 +00:00
|
|
|
|
OptionVars .DA #bPrintAll,#bLineNum,#bSuppressBlankLine,#bPrintAll,#bLineNum,#bSuppressBlankLine
|
2016-11-01 14:36:32 +00:00
|
|
|
|
*--------------------------------------
|
2018-11-19 07:43:00 +00:00
|
|
|
|
MSG.USAGE .AS "Usage : CAT File1 [File2...]\r\n"
|
|
|
|
|
.AS " -A : Show All non printable caracters\r\n"
|
|
|
|
|
.AS " -N : Number all output lines\r\n"
|
2019-02-27 22:02:56 +00:00
|
|
|
|
.AS " -S : Suppress repeated empty output lines"
|
|
|
|
|
MSG.CRLF .AZ "\r\n"
|
2018-04-11 15:35:51 +00:00
|
|
|
|
MSG.LINENUM .AZ "%5D:"
|
|
|
|
|
MSG.CTRLCHAR .AZ "[%S]"
|
2016-11-01 14:36:32 +00:00
|
|
|
|
*--------------------------------------
|
2019-02-28 18:48:38 +00:00
|
|
|
|
ASCII >PSTR "NUL"
|
2016-11-01 14:36:32 +00:00
|
|
|
|
>PSTR "SOH"
|
|
|
|
|
>PSTR "STX"
|
|
|
|
|
>PSTR "ETX"
|
|
|
|
|
>PSTR "EOT"
|
|
|
|
|
>PSTR "ENQ"
|
|
|
|
|
>PSTR "ACK"
|
|
|
|
|
>PSTR "BEL"
|
|
|
|
|
>PSTR "BS"
|
|
|
|
|
>PSTR "TAB"
|
|
|
|
|
>PSTR "LF"
|
|
|
|
|
>PSTR "VT"
|
|
|
|
|
>PSTR "FF"
|
|
|
|
|
>PSTR "CR"
|
|
|
|
|
>PSTR "SO"
|
|
|
|
|
>PSTR "SI"
|
|
|
|
|
>PSTR "DLE"
|
|
|
|
|
>PSTR "DC1"
|
|
|
|
|
>PSTR "DC2"
|
|
|
|
|
>PSTR "DC3"
|
|
|
|
|
>PSTR "DC4"
|
|
|
|
|
>PSTR "NAK"
|
|
|
|
|
>PSTR "SYN"
|
|
|
|
|
>PSTR "ETB"
|
|
|
|
|
>PSTR "CAN"
|
|
|
|
|
>PSTR "EM"
|
|
|
|
|
>PSTR "SUB"
|
|
|
|
|
>PSTR "ESC"
|
|
|
|
|
>PSTR "FS"
|
|
|
|
|
>PSTR "GS"
|
|
|
|
|
>PSTR "RS"
|
|
|
|
|
>PSTR "US"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2017-09-19 06:39:27 +00:00
|
|
|
|
ArgCount .BS 1
|
|
|
|
|
FileCount .BS 1
|
2017-01-15 20:51:20 +00:00
|
|
|
|
bPause .BS 1
|
2016-11-01 14:36:32 +00:00
|
|
|
|
bPrintAll .BS 1
|
|
|
|
|
bLineNum .BS 1
|
2017-08-22 06:37:03 +00:00
|
|
|
|
bSuppressBlankLine .BS 1
|
2016-11-01 14:36:32 +00:00
|
|
|
|
ArgIndex .BS 1
|
2017-09-19 06:39:27 +00:00
|
|
|
|
hBuf .BS 1
|
|
|
|
|
hFile .BS 1
|
2016-11-01 14:36:32 +00:00
|
|
|
|
LineNum .BS 2
|
|
|
|
|
bPrintedBlankLine .BS 1
|
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2018-11-19 07:43:00 +00:00
|
|
|
|
SAVE USR/SRC/BIN/CAT.S
|
2016-11-01 14:36:32 +00:00
|
|
|
|
ASM
|