2018-11-05 16:28:40 +00:00
|
|
|
|
NEW
|
2018-11-17 17:17:13 +00:00
|
|
|
|
PREFIX
|
2018-11-05 16:28:40 +00:00
|
|
|
|
AUTO 4,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
|
|
|
|
.TF BIN/MORE
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB INC/MACROS.I
|
|
|
|
|
.INB INC/A2OSX.I
|
|
|
|
|
.INB INC/MLI.I
|
|
|
|
|
.INB INC/MLI.E.I
|
|
|
|
|
*--------------------------------------
|
2019-01-16 14:37:21 +00:00
|
|
|
|
PG.SIZE .EQ 23
|
2018-11-21 16:01:38 +00:00
|
|
|
|
*--------------------------------------
|
2018-12-20 20:59:48 +00:00
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ZPPTR1 .BS 2
|
|
|
|
|
ZPBufPtr .BS 2
|
|
|
|
|
ZS.END
|
|
|
|
|
.ED
|
2018-11-05 16:28:40 +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-12-20 20:59:48 +00:00
|
|
|
|
.DA #0 S.PS.F.EVENT
|
2018-11-05 16:28:40 +00:00
|
|
|
|
.DA #0
|
2018-12-20 20:59:48 +00:00
|
|
|
|
.DA CS.END-CS.START Code Size (without Constants)
|
|
|
|
|
.DA DS.END-DS.START Data SegmentSize
|
|
|
|
|
.DA #16 Stack Size
|
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
2018-11-05 16:28:40 +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
|
2018-11-28 11:39:33 +00:00
|
|
|
|
L.MSG.NUMLINE .DA MSG.NUMLINE
|
|
|
|
|
L.MSG.CRLF .DA MSG.CRLF
|
2018-11-06 16:31:13 +00:00
|
|
|
|
L.MSG.Pause .DA MSG.Pause
|
2018-11-21 16:01:38 +00:00
|
|
|
|
L.MSG.PauseErase .DA MSG.PauseErase
|
2018-11-05 16:28:40 +00:00
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN
|
|
|
|
|
.1 >INC.G ArgCount
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
bcs .7
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
|
|
|
|
|
ldx OptionList
|
|
|
|
|
|
|
|
|
|
.2 cmp OptionList,x
|
|
|
|
|
beq .3
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
.99 >PUSHBI 0
|
|
|
|
|
>LDYA L.MSG.USAGE
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.3 ldy OptionVars-1,x
|
|
|
|
|
lda #$80
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.4 >LDA.G hFile
|
|
|
|
|
bne .99
|
|
|
|
|
|
2018-11-06 16:31:13 +00:00
|
|
|
|
>LDYA ZPPtr1
|
2018-11-05 16:28:40 +00:00
|
|
|
|
jsr CS.RUN.OPEN
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
bra .1 scan for any other args
|
|
|
|
|
|
|
|
|
|
.7 >LDA.G bHelp
|
|
|
|
|
beq .8
|
|
|
|
|
jsr .99
|
|
|
|
|
lda #0
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 >LDYAI 256
|
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPBufPtr
|
|
|
|
|
txa
|
|
|
|
|
>STA.G hBuf
|
|
|
|
|
|
|
|
|
|
CS.RUN.LOOP >SLEEP
|
|
|
|
|
|
2018-11-21 16:01:38 +00:00
|
|
|
|
jsr CS.RUN.GETLINE
|
2018-11-05 16:28:40 +00:00
|
|
|
|
bcs .13
|
|
|
|
|
|
2018-11-12 21:34:55 +00:00
|
|
|
|
>INCW.G LineNum
|
|
|
|
|
|
2018-11-06 16:31:13 +00:00
|
|
|
|
>LDA.G LineCount
|
|
|
|
|
bne .22
|
|
|
|
|
>LDA.G bPage
|
|
|
|
|
beq .22
|
|
|
|
|
|
|
|
|
|
lda #C.FF
|
|
|
|
|
>SYSCALL putchar
|
|
|
|
|
|
2018-11-12 21:34:55 +00:00
|
|
|
|
.22 jsr CS.RUN.PRINT
|
|
|
|
|
|
2018-11-05 16:28:40 +00:00
|
|
|
|
>INC.G LineCount
|
2018-11-21 16:01:38 +00:00
|
|
|
|
cmp #PG.SIZE
|
2018-11-05 16:28:40 +00:00
|
|
|
|
bne .8
|
|
|
|
|
lda #0
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2018-11-21 16:01:38 +00:00
|
|
|
|
jsr CS.RUN.PAUSE
|
|
|
|
|
bcs .9
|
2018-11-05 16:28:40 +00:00
|
|
|
|
|
|
|
|
|
.8 jmp CS.RUN.LOOP
|
|
|
|
|
|
|
|
|
|
.13 cmp #MLI.E.EOF
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
lda #0 Exit with no Error
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-11-07 16:11:02 +00:00
|
|
|
|
CS.RUN.OPEN pha
|
2018-11-05 16:28:40 +00:00
|
|
|
|
|
|
|
|
|
>PUSHWI 0 Aux type
|
|
|
|
|
>PUSHBI S.FI.T.TXT
|
|
|
|
|
>PUSHBI O.RDONLY+O.TEXT
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
>SYSCALL FOpen
|
2018-11-06 16:31:13 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
>STA.G hFile
|
2018-11-05 16:28:40 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2018-11-21 16:01:38 +00:00
|
|
|
|
CS.RUN.PAUSE >PUSHBI 0
|
|
|
|
|
>PUSHW L.MSG.Pause
|
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fprintf
|
|
|
|
|
|
|
|
|
|
.10 >SLEEP
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.GETC
|
|
|
|
|
bcs .10 no char
|
|
|
|
|
|
|
|
|
|
cmp #'Q'
|
|
|
|
|
beq .9
|
2018-11-28 11:39:33 +00:00
|
|
|
|
cmp #'q'
|
|
|
|
|
beq .9
|
2018-11-21 16:01:38 +00:00
|
|
|
|
|
|
|
|
|
.3 cmp #C.SPACE
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
jmp CS.RUN.ERASE
|
|
|
|
|
|
|
|
|
|
.4 cmp #C.CR
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.ERASE
|
|
|
|
|
jsr CS.RUN.GETLINE
|
2019-01-16 14:37:21 +00:00
|
|
|
|
bcc .5
|
|
|
|
|
cmp #MLI.E.EOF
|
|
|
|
|
bne .99
|
|
|
|
|
|
|
|
|
|
bra .90
|
|
|
|
|
|
|
|
|
|
.5 >INCW.G LineNum
|
|
|
|
|
|
2018-11-21 16:01:38 +00:00
|
|
|
|
jsr CS.RUN.PRINT
|
|
|
|
|
|
|
|
|
|
bra CS.RUN.PAUSE
|
|
|
|
|
|
|
|
|
|
.9 jsr CS.RUN.ERASE
|
2019-01-16 14:37:21 +00:00
|
|
|
|
.90 lda #0
|
2018-11-21 16:01:38 +00:00
|
|
|
|
.99 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.ERASE >PUSHBI 0
|
|
|
|
|
>PUSHW L.MSG.PauseErase
|
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL fprintf
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.GETC >LDA.G hFILE
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>SYSCALL GetC
|
|
|
|
|
bra .2
|
|
|
|
|
|
|
|
|
|
.1 >SYSCALL GetChar
|
|
|
|
|
.2 rts
|
|
|
|
|
*--------------------------------------
|
2018-12-20 20:59:48 +00:00
|
|
|
|
CS.RUN.GETLINE >PUSHWI 256
|
|
|
|
|
>PUSHW ZPBufPtr
|
|
|
|
|
>LDA.G hFile
|
2018-11-21 16:01:38 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hStdIn
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
|
2018-12-20 20:59:48 +00:00
|
|
|
|
.1 >SYSCALL fgets
|
|
|
|
|
|
2018-11-21 16:01:38 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-11-27 20:16:32 +00:00
|
|
|
|
lda (ZPBufPtr)
|
|
|
|
|
cmp #C.LF
|
|
|
|
|
bne .11
|
|
|
|
|
|
|
|
|
|
lda #C.CR
|
|
|
|
|
sta (ZPBufPtr)
|
|
|
|
|
|
|
|
|
|
.11 ldy #$ff
|
2018-11-21 16:01:38 +00:00
|
|
|
|
|
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPBufPtr),y
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
.3 tya
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
lda (ZPBufPtr),y
|
|
|
|
|
cmp #C.LF
|
|
|
|
|
beq .3
|
|
|
|
|
cmp #C.CR
|
|
|
|
|
beq .3
|
|
|
|
|
lda #0
|
|
|
|
|
iny
|
|
|
|
|
.8 sta (ZPBufPtr),y
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2018-11-28 11:39:33 +00:00
|
|
|
|
CS.RUN.PRINT >LDA.G bLineNum
|
2018-11-12 21:34:55 +00:00
|
|
|
|
bpl .1
|
2018-11-05 16:28:40 +00:00
|
|
|
|
|
|
|
|
|
>PUSHW.G LineNum
|
2018-11-21 16:01:38 +00:00
|
|
|
|
>PUSHBI 2
|
2018-11-28 11:39:33 +00:00
|
|
|
|
>LDYA L.MSG.NUMLINE
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2019-01-16 14:37:21 +00:00
|
|
|
|
.1 >LDA.G bEscCodes
|
|
|
|
|
bmi .2
|
|
|
|
|
|
|
|
|
|
>LDYA ZPBufPtr
|
|
|
|
|
>SYSCALL puts
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 >PUSHBI 0
|
2018-11-28 11:39:33 +00:00
|
|
|
|
>LDYA ZPBufPtr
|
|
|
|
|
>SYSCALL printf
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>LDYA L.MSG.CRLF
|
2018-11-12 21:34:55 +00:00
|
|
|
|
>SYSCALL printf
|
|
|
|
|
.9 rts
|
2018-11-05 16:28:40 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT >LDA.G hBuf
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
|
|
|
|
|
.1 >LDA.G hFILE
|
2018-11-06 16:31:13 +00:00
|
|
|
|
beq .2
|
2018-11-05 16:28:40 +00:00
|
|
|
|
|
|
|
|
|
>SYSCALL FClose
|
|
|
|
|
|
2018-11-07 16:11:02 +00:00
|
|
|
|
.2
|
2018-11-05 16:28:40 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
2019-01-16 14:37:21 +00:00
|
|
|
|
OptionList >PSTR "NnHhPpSs"
|
|
|
|
|
OptionVars .DA #bLineNum,#bLineNum,#bHelp,#bHelp,#bPage,#bPage,#bEscCodes
|
2018-11-05 16:28:40 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MSG.USAGE .AS "Usage : MORE <File>\r\n"
|
2018-11-06 16:31:13 +00:00
|
|
|
|
.AS " -H : This help screen\r\n"
|
|
|
|
|
.AS " -N : Number all output lines\r\n"
|
2018-11-27 20:16:32 +00:00
|
|
|
|
.AZ " -P : Page mode, no scroll\r\n"
|
2019-01-16 14:37:21 +00:00
|
|
|
|
.AZ " -S : Process ESC codes\r\n"
|
2018-11-28 11:39:33 +00:00
|
|
|
|
MSG.NUMLINE .AZ "%5D:"
|
|
|
|
|
MSG.CRLF .AZ "\r\n"
|
|
|
|
|
MSG.Pause .AZ "\r\e[7m --- 'SPACE' for more, 'CR' one line, 'Q/q' to quit --- \e[0m"
|
2018-11-21 16:01:38 +00:00
|
|
|
|
MSG.PauseErase .AZ "\r\e[2K"
|
2018-11-05 16:28:40 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
|
|
|
|
ArgCount .BS 1
|
|
|
|
|
hFile .BS 1
|
|
|
|
|
LineCount .BS 1
|
|
|
|
|
LineNum .BS 2
|
2019-01-16 14:37:21 +00:00
|
|
|
|
bHelp .BS 1
|
2018-11-05 16:28:40 +00:00
|
|
|
|
bLineNum .BS 1
|
2018-11-06 16:31:13 +00:00
|
|
|
|
bPage .BS 1
|
2019-01-16 14:37:21 +00:00
|
|
|
|
bEscCodes .BS 1
|
2018-11-05 16:28:40 +00:00
|
|
|
|
ArgIndex .BS 1
|
|
|
|
|
hBuf .BS 1
|
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2018-11-21 16:01:38 +00:00
|
|
|
|
SAVE USR/SRC/BIN/MORE.S
|
2018-11-05 16:28:40 +00:00
|
|
|
|
ASM
|