2019-11-06 13:14:42 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2020-02-24 13:33:28 +00:00
|
|
|
|
.TF bin/term
|
2019-11-06 13:14:42 +00:00
|
|
|
|
*--------------------------------------
|
2020-05-25 21:03:11 +00:00
|
|
|
|
.INB inc/macros.i
|
|
|
|
|
.INB inc/a2osx.i
|
2019-11-06 13:14:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
TIMEOUT.MAX .EQ 200 20 sec.
|
|
|
|
|
BUFSIZE .EQ 256
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ZPBufPtr .BS 2
|
2021-05-19 12:44:47 +00:00
|
|
|
|
ZPDataLen .BS 2
|
2019-11-06 13:14:42 +00:00
|
|
|
|
hBuf .BS 1
|
|
|
|
|
hDev .BS 1
|
|
|
|
|
TimeOut .BS 1
|
2021-03-11 21:40:55 +00:00
|
|
|
|
ZS.END .ED
|
2019-11-06 13:14:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA #S.PS.F.EVENT S.PS.F
|
|
|
|
|
.DA #0
|
|
|
|
|
.DA CS.END-CS.START Code Size (without Constants)
|
|
|
|
|
.DA DS.END-DS.START Data Segment Size
|
|
|
|
|
.DA #32 Stack Size
|
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
2021-02-11 22:08:22 +00:00
|
|
|
|
.DA CS.DOEVENT
|
2019-11-06 13:14:42 +00:00
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
|
L.MSG.DEVOK .DA MSG.DEVOK
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN lda #1
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
bcs .9
|
2021-02-11 22:08:22 +00:00
|
|
|
|
|
2020-02-24 13:33:28 +00:00
|
|
|
|
>PUSHYA
|
2019-11-06 13:14:42 +00:00
|
|
|
|
>PUSHBI O.RDWR
|
2020-02-24 13:33:28 +00:00
|
|
|
|
>PUSHBI 0 type
|
|
|
|
|
>PUSHWZ auxtype
|
2020-03-09 16:24:08 +00:00
|
|
|
|
>SYSCALL FOpen
|
2019-11-06 13:14:42 +00:00
|
|
|
|
bcs .99
|
2021-02-11 22:08:22 +00:00
|
|
|
|
|
|
|
|
|
sta hDev
|
2019-11-06 13:14:42 +00:00
|
|
|
|
>LDYA L.MSG.DEVOK
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PutS
|
2019-11-06 13:14:42 +00:00
|
|
|
|
|
|
|
|
|
>LDYAI BUFSIZE
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL GetMem
|
2019-11-06 13:14:42 +00:00
|
|
|
|
bcs .99
|
2021-02-11 22:08:22 +00:00
|
|
|
|
|
2019-11-06 13:14:42 +00:00
|
|
|
|
>STYA ZPBufPtr
|
|
|
|
|
stx hBuf
|
|
|
|
|
|
|
|
|
|
bra CS.RUN.LOOP
|
|
|
|
|
|
|
|
|
|
.9 >LDYA L.MSG.USAGE
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PutS
|
2019-11-06 13:14:42 +00:00
|
|
|
|
|
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
2021-02-11 22:08:22 +00:00
|
|
|
|
.99
|
|
|
|
|
CS.RUN.RTS rts
|
|
|
|
|
*--------------------------------------
|
2019-11-06 13:14:42 +00:00
|
|
|
|
CS.RUN.LOOP >SLEEP
|
|
|
|
|
|
|
|
|
|
lda hDev
|
2020-08-25 10:56:00 +00:00
|
|
|
|
>SYSCALL FEOF
|
2021-05-19 12:44:47 +00:00
|
|
|
|
bcs .9
|
2019-11-06 13:14:42 +00:00
|
|
|
|
tay
|
2021-02-11 22:08:22 +00:00
|
|
|
|
bne .1 EOF, no char
|
2019-11-06 13:14:42 +00:00
|
|
|
|
|
2021-05-19 12:44:47 +00:00
|
|
|
|
lda hDev
|
|
|
|
|
jsr CS.Read
|
2021-02-11 22:08:22 +00:00
|
|
|
|
bcs CS.RUN.RTS
|
|
|
|
|
|
2021-05-19 12:44:47 +00:00
|
|
|
|
>STYA ZPDataLen
|
2021-05-14 20:58:20 +00:00
|
|
|
|
|
2019-11-06 13:14:42 +00:00
|
|
|
|
ldy #S.PS.hStdOut
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2021-05-19 12:44:47 +00:00
|
|
|
|
jsr CS.Write
|
2019-11-06 13:14:42 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2021-02-11 22:08:22 +00:00
|
|
|
|
.1 ldy #S.PS.hStdIn
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2019-11-06 13:14:42 +00:00
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
>SYSCALL FEOF
|
2019-11-06 13:14:42 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
tay
|
|
|
|
|
bne CS.RUN.LOOP EOF = true, no char from STDIN
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hStdIn
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2021-05-19 12:44:47 +00:00
|
|
|
|
jsr CS.Read
|
2021-02-11 22:08:22 +00:00
|
|
|
|
bcs .9
|
2019-11-06 13:14:42 +00:00
|
|
|
|
|
2021-05-19 12:44:47 +00:00
|
|
|
|
>STYA ZPDataLen
|
|
|
|
|
|
2019-11-06 13:14:42 +00:00
|
|
|
|
lda (ZPBufPtr)
|
2021-02-11 22:08:22 +00:00
|
|
|
|
eor #$14 Ctrl-T
|
2021-05-19 12:44:47 +00:00
|
|
|
|
clc
|
|
|
|
|
beq .9 exit with A=0,CC
|
2021-05-14 20:58:20 +00:00
|
|
|
|
|
2021-05-19 12:44:47 +00:00
|
|
|
|
lda hDev
|
|
|
|
|
jsr CS.Write
|
|
|
|
|
bcc CS.RUN.LOOP
|
2021-02-11 22:08:22 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2019-11-06 13:14:42 +00:00
|
|
|
|
*--------------------------------------
|
2021-05-19 12:44:47 +00:00
|
|
|
|
CS.Read >PUSHA
|
|
|
|
|
>PUSHW ZPBufPtr
|
|
|
|
|
>PUSHWI BUFSIZE
|
|
|
|
|
>SYSCALL FRead
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.Write >PUSHA
|
|
|
|
|
>PUSHW ZPBufPtr
|
|
|
|
|
>PUSHW ZPDataLen
|
|
|
|
|
>SYSCALL FWrite
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-11-06 13:14:42 +00:00
|
|
|
|
CS.DOEVENT lda (pEvent)
|
|
|
|
|
bpl .9 is it a TIMER event?
|
2020-05-25 21:03:11 +00:00
|
|
|
|
|
2019-11-06 13:14:42 +00:00
|
|
|
|
lda TimeOut
|
|
|
|
|
beq .9
|
2020-05-25 21:03:11 +00:00
|
|
|
|
|
2019-11-06 13:14:42 +00:00
|
|
|
|
dec TimeOut
|
|
|
|
|
.9 sec do not discard TIMER event
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT lda hDev
|
|
|
|
|
beq .1
|
|
|
|
|
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL FClose
|
2019-11-06 13:14:42 +00:00
|
|
|
|
|
|
|
|
|
.1 lda hBuf
|
|
|
|
|
beq .2
|
|
|
|
|
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2019-11-06 13:14:42 +00:00
|
|
|
|
|
|
|
|
|
.2 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
MSG.USAGE .AZ "Usage : TERM device "
|
|
|
|
|
MSG.DEVOK .AZ "Connected (Exit key is Ctrl-T)"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2021-05-19 12:44:47 +00:00
|
|
|
|
DS.END .ED
|
2019-11-06 13:14:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2020-05-25 21:03:11 +00:00
|
|
|
|
SAVE usr/src/bin/term.s
|
2019-11-06 13:14:42 +00:00
|
|
|
|
ASM
|