A2osX/SBIN/GETTY.S.txt

276 lines
5.0 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
NEW
2017-12-22 21:24:30 +00:00
PREFIX /A2OSX.BUILD
AUTO 4,1
2015-03-14 21:48:35 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2018-07-23 15:28:42 +00:00
.TF SBIN/GETTY
2015-03-14 21:48:35 +00:00
*--------------------------------------
2018-07-23 15:28:42 +00:00
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/NET.TELNET.I
2015-03-14 21:48:35 +00:00
*--------------------------------------
2017-10-05 15:39:17 +00:00
TIMEOUT.MAX .EQ 100 1 sec.
*--------------------------------------
2015-06-03 18:30:57 +00:00
* File Header (16 Bytes)
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.START cld
jmp (.1,x)
2015-06-03 18:30:57 +00:00
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
2017-10-05 15:39:17 +00:00
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #64 SS
.DA #0 ZP
2015-06-03 18:30:57 +00:00
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
2015-03-14 21:48:35 +00:00
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
2017-10-05 15:39:17 +00:00
L.MSG.TELNETOPT .DA MSG.TELNETOPT
L.MSG.GREETINGS .DA MSG.GREETINGS
2017-10-05 15:39:17 +00:00
L.ENV.TERM .DA ENV.TERM
2015-06-03 18:30:57 +00:00
.DA 0 End Of Reloc Table
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.INIT ldy #S.PS.ARGC
lda (pPs),y
cmp #2
bne .90
2018-07-17 15:45:59 +00:00
>PUSHBI 0
2016-06-07 06:10:18 +00:00
2018-07-17 15:45:59 +00:00
lda #1
>SYSCALL GetArg get /dev/xxx
>SYSCALL open
2017-01-12 17:43:45 +00:00
bcs .9
ldy #S.PS.hStdIn
2015-06-03 18:30:57 +00:00
sta (pPs),y
iny #S.PS.hStdOut
2015-06-03 18:30:57 +00:00
sta (pPs),y
iny #S.PS.hStdErr
2015-06-03 18:30:57 +00:00
sta (pPs),y
2015-10-19 20:35:00 +00:00
2018-07-17 15:45:59 +00:00
>STA.G hDEV
2016-08-17 06:25:58 +00:00
lda #2
2018-07-16 15:29:18 +00:00
>SYSCALL GetArg
2017-01-12 17:43:45 +00:00
bcs .9
2015-03-14 21:48:35 +00:00
2018-07-16 15:29:18 +00:00
>SYSCALL ExpandStr
2017-01-12 17:43:45 +00:00
bcs .9
2016-08-17 06:25:58 +00:00
txa
>STA.G hBinName
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
2016-06-07 06:10:18 +00:00
clc
rts
.90 >LDYA L.MSG.USAGE
2018-08-22 15:23:27 +00:00
>SYSCALL puts
lda #0
sec
2017-01-12 17:43:45 +00:00
.9 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.RUN >SLEEP
2018-07-18 15:30:42 +00:00
2017-10-05 15:39:17 +00:00
>SYSCALL GetChar
bcs CS.RUN
.11 >SLEEP
>SYSCALL GetChar
2017-10-05 15:39:17 +00:00
bcc .11
jsr Init.Timeout
2017-10-05 15:39:17 +00:00
ldy #0
2017-10-05 15:39:17 +00:00
.1 lda MSG.TELNETOPT,y
phy
2018-07-16 15:29:18 +00:00
>SYSCALL PutChar
2017-10-05 15:39:17 +00:00
ply
iny
cpy #MSG.TELNETOPT.LEN
bne .1
CS.RUN.LOOP
.1 >SLEEP
>SYSCALL GetChar
2017-10-05 15:39:17 +00:00
bcs .4
2017-10-05 15:39:17 +00:00
cmp #IAC
beq CS.RUN.IACMODE
2017-10-05 15:39:17 +00:00
.4 jsr Wait.Timeout
bcc .1
2018-08-25 11:23:59 +00:00
>PUSHWI K.VER
2018-08-22 15:23:27 +00:00
>PUSHBI 2
2017-10-05 15:39:17 +00:00
>LDYA L.MSG.GREETINGS
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2017-10-05 15:39:17 +00:00
bcs .8 unable to send greetings...reset..
>LDA.G hBinName
2018-07-16 15:29:18 +00:00
>SYSCALL GetMemPtr
>SYSCALL ExecPS
2017-10-05 15:39:17 +00:00
.9 rts
.8 clc
rts
*--------------------------------------
CS.RUN.IACMODE >SLEEP Wait for IAC VERB (or SB)
>SYSCALL GetChar
2017-10-05 15:39:17 +00:00
bcs CS.RUN.IACMODE
2017-10-05 15:39:17 +00:00
>STA.G IAC.VERB
.1 >SLEEP Wait for IAC OPT
>SYSCALL GetChar
2017-10-05 15:39:17 +00:00
bcs .1
2017-10-05 15:39:17 +00:00
>STA.G IAC.OPT
2017-10-05 15:39:17 +00:00
>LDA.G IAC.VERB
cmp #SB
2017-10-05 15:39:17 +00:00
beq CS.RUN.IACSB
*--------------------------------------
CS.RUN.IACVERB
2017-10-05 15:39:17 +00:00
jmp CS.RUN.LOOP
*--------------------------------------
CS.RUN.IACSB
.1 >SLEEP
>SYSCALL GetChar
2017-10-05 15:39:17 +00:00
bcs .1
>STA.G IAC.SB
lda #0
2017-10-05 15:39:17 +00:00
sta (pData) reset IAC.SB.DATA
.2 >SLEEP
>SYSCALL GetChar
2017-10-05 15:39:17 +00:00
bcs .2
cmp #IAC
2017-10-05 15:39:17 +00:00
beq .4 end of DATA, go wait SE
pha
2017-10-05 15:39:17 +00:00
ldy #IAC.SB.DATA-1
2017-10-05 15:39:17 +00:00
.3 iny
lda (pData),y
bne .3
2017-10-05 15:39:17 +00:00
pla
sta (pData),y
iny
lda #0
sta (pData),y
bra .2
.4 >SLEEP
>SYSCALL GetChar
2017-10-05 15:39:17 +00:00
bcs .4
cmp #SE
2017-10-05 15:39:17 +00:00
bne .8
2017-10-05 15:39:17 +00:00
>LDA.G IAC.OPT
cmp #TELOPT.TTYPE
bne .8
2015-06-03 18:30:57 +00:00
2017-10-05 15:39:17 +00:00
>LDA.G IAC.SB
cmp #SB.IS
bne .8
2017-10-05 15:39:17 +00:00
>PUSHEA.G IAC.SB.DATA
>PUSHW L.ENV.TERM
>SYSCALL SetEnv
.8 jmp CS.RUN.LOOP
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
ldy #TimeOut
lda (pData),y
beq .9
dec
sta (pData),y
.9 sec do not discard TIMER event
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
CS.QUIT >LDA.G hBinName
beq .1
2018-08-11 10:57:57 +00:00
* >SYSCALL FreeMem
2015-06-03 18:30:57 +00:00
2018-07-17 15:45:59 +00:00
.1 >LDA.G hDEV
beq .8
2018-07-19 15:33:55 +00:00
>SYSCALL close
.8 clc
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
Init.Timeout ldy #TimeOut
lda #TIMEOUT.MAX
sta (pData),y
rts
*--------------------------------------
Wait.TimeOut sec
ldy #TimeOut
lda (pData),y
beq .9
clc
.9 rts
*--------------------------------------
2015-03-14 21:48:35 +00:00
CS.END
2018-08-22 15:23:27 +00:00
MSG.USAGE .AZ "Usage : GETTY <DEV> <PROGRAM>"
2017-10-05 15:39:17 +00:00
MSG.TELNETOPT .DA #IAC,#WILL,#TELOPT.BINARY
.DA #IAC,#DO,#TELOPT.LINEMODE
.DA #IAC,#SB,#TELOPT.LINEMODE,#SB.SEND,#0,#IAC,#SE
.DA #IAC,#DONT,#TELOPT.ECHO
.DA #IAC,#WILL,#TELOPT.ECHO
.DA #IAC,#WILL,#TELOPT.SGA
.DA #IAC,#DO,#TELOPT.SGA
* .DA #IAC,#DO,#TELOPT.NAWS
.DA #IAC,#DO,#TELOPT.TTYPE
.DA #IAC,#SB,#TELOPT.TTYPE,#SB.SEND,#IAC,#SE
2017-10-05 15:39:17 +00:00
MSG.TELNETOPT.LEN .EQ *-MSG.TELNETOPT
2018-06-14 15:31:36 +00:00
MSG.GREETINGS .AZ "\r\nA2osX-GeTTY %d.%d\r\n"
ENV.TERM .AZ "TERM"
2015-03-14 21:48:35 +00:00
*--------------------------------------
2015-06-03 18:30:57 +00:00
.DUMMY
.OR 0
DS.START
2017-10-05 15:39:17 +00:00
IAC.SB.DATA .BS 64
IAC.VERB .BS 1
IAC.OPT .BS 1
2017-10-05 15:39:17 +00:00
IAC.SB .BS 1
2018-07-17 15:45:59 +00:00
hDEV .BS 1
hBinName .BS 1
TimeOut .BS 1
2015-06-03 18:30:57 +00:00
DS.END .ED
2015-03-14 21:48:35 +00:00
MAN
SAVE /A2OSX.SRC/SBIN/GETTY.S
2015-03-14 21:48:35 +00:00
ASM