A2osX/SBIN/GETTY.S.txt

347 lines
6.7 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
NEW
2019-05-02 09:52:32 +00:00
AUTO 3,1
2015-03-14 21:48:35 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2020-08-18 19:56:50 +00:00
.TF sbin/getty
2015-03-14 21:48:35 +00:00
*--------------------------------------
2020-08-18 19:56:50 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/net.telnet.i
2015-03-14 21:48:35 +00:00
*--------------------------------------
2019-06-11 05:52:24 +00:00
TIMEOUT.MAX .EQ 40 4 sec.
2019-05-16 15:51:19 +00:00
IAC.BUF.MAX .EQ 32
*--------------------------------------
2018-12-18 14:37:07 +00:00
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
2019-05-06 05:40:12 +00:00
TimeOut .BS 1
2019-05-16 15:51:19 +00:00
hErr .BS 1
ArgIndex .BS 1
ArgDev .BS 1
ArgProg .BS 1
hFILE .BS 1
bExitOnClose .BS 1
IAC.CMD .BS 1
IAC.SUBCMD .BS 1
IAC.SB.CMD .BS 1
IAC.SB.LEN .BS 1
2019-01-21 21:45:47 +00:00
ZS.END .ED
2018-11-20 15:54:49 +00:00
*--------------------------------------
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
2018-09-19 15:25:42 +00:00
.DA #S.PS.F.EVENT S.PS.F
.DA #0
2018-12-18 14:37:07 +00:00
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
2019-10-18 11:41:27 +00:00
.DA #32 Stack Size
2018-12-18 14:37:07 +00:00
.DA #ZS.END-ZS.START Zero Page Size
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
L.MSG.GREETINGS .DA MSG.GREETINGS
2018-09-12 15:27:00 +00:00
L.TELNETOPTS .DA TELNETOPTS
2018-09-13 15:29:02 +00:00
L.TELNETOPT.TTYPE .DA TELNETOPT.TTYPE
2018-09-14 13:08:30 +00:00
L.TELNETOPT.LMODE .DA TELNETOPT.LMODE
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
*--------------------------------------
2018-09-19 15:25:42 +00:00
CS.INIT clc
rts
*--------------------------------------
CS.RUN ldy #S.PS.ARGC
2020-02-28 07:21:46 +00:00
lda (pPS),y
2018-11-23 16:20:19 +00:00
cmp #2
2018-10-18 15:32:57 +00:00
2019-10-03 06:25:27 +00:00
bcc .9
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
.1 inc ArgIndex
lda ArgIndex
2018-11-20 15:54:49 +00:00
>SYSCALL ArgV
bcs .8
>STYA ZPPtr1
2018-10-18 15:32:57 +00:00
2018-11-20 15:54:49 +00:00
jsr CkeckOption
bcs .9
2019-10-18 11:41:27 +00:00
2018-11-20 15:54:49 +00:00
beq .1 valid option, check next arg
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
lda ArgDev
2018-11-20 15:54:49 +00:00
bne .2
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
lda ArgIndex
sta ArgDev
2018-11-20 15:54:49 +00:00
bra .1
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
.2 lda ArgProg
2018-11-20 15:54:49 +00:00
bne .9
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
lda ArgIndex
sta ArgProg
2018-11-20 15:54:49 +00:00
bra .1
2019-10-03 06:25:27 +00:00
2020-02-14 07:21:56 +00:00
.9 >PUSHW L.MSG.USAGE
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2018-11-20 15:54:49 +00:00
lda #E.SYN
sec
.99 rts
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
.8 lda ArgDev
2018-11-20 15:54:49 +00:00
beq .9
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
lda ArgProg
2018-11-20 15:54:49 +00:00
beq .9
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
ldy #S.PS.hStdErr
2020-02-28 07:21:46 +00:00
lda (pPS),y
2019-05-16 15:51:19 +00:00
sta hErr
2020-02-14 07:21:56 +00:00
2019-05-16 15:51:19 +00:00
lda ArgDev
2018-11-20 15:54:49 +00:00
>SYSCALL ArgV
2020-02-14 07:21:56 +00:00
>PUSHYA
>PUSHBI O.RDWR
>PUSHBI 0 type
>PUSHWZ auxtype
2020-03-09 16:24:08 +00:00
>SYSCALL FOpen
2018-11-20 15:54:49 +00:00
bcs .99
2017-01-12 17:43:45 +00:00
ldy #S.PS.hStdIn
2020-02-28 07:21:46 +00:00
sta (pPS),y
iny #S.PS.hStdOut
2020-02-28 07:21:46 +00:00
sta (pPS),y
iny #S.PS.hStdErr
2020-02-28 07:21:46 +00:00
sta (pPS),y
2019-05-16 15:51:19 +00:00
sta hFILE
2018-09-19 15:25:42 +00:00
2019-05-05 17:15:37 +00:00
CS.RUN.LOOP0 >SLEEP
2020-01-17 11:23:11 +00:00
>PUSHW L.ENV.TERM
2020-08-20 13:20:33 +00:00
>SYSCALL UnsetEnv
2018-09-14 13:08:30 +00:00
2018-09-19 15:25:42 +00:00
.1 >PUSHWI TELNETOPTS.LEN
2018-09-12 15:27:00 +00:00
>PUSHW L.TELNETOPTS
ldy #S.PS.hStdOut
2020-02-28 07:21:46 +00:00
lda (pPS),y
2020-08-20 13:20:33 +00:00
>SYSCALL FWrite
2019-03-02 20:47:58 +00:00
bcs CS.RUN.EXIT I/O error
2019-05-06 05:40:12 +00:00
lda #TIMEOUT.MAX
sta TimeOut
2018-09-12 15:27:00 +00:00
2019-02-21 11:34:28 +00:00
CS.RUN.LOOP1 >SLEEP
ldy #S.PS.hStdIn
2019-02-20 16:07:43 +00:00
lda (pPS),y
2020-08-20 13:20:33 +00:00
>SYSCALL FEOF
2019-05-01 13:35:41 +00:00
bcs CS.RUN.9 I/O error
2019-02-20 16:07:43 +00:00
tay
2019-05-02 09:52:32 +00:00
bne .1 no char
2019-02-20 16:07:43 +00:00
2018-09-14 13:08:30 +00:00
>SYSCALL GetChar
2019-02-20 16:07:43 +00:00
bcs CS.RUN.9
2019-10-18 11:41:27 +00:00
2018-09-12 20:48:12 +00:00
cmp #IAC
beq CS.RUN.IACMODE
2019-05-01 19:16:15 +00:00
>SYSCALL PutChar
2019-03-02 20:47:58 +00:00
bcs CS.RUN.EXIT
2018-09-19 15:25:42 +00:00
bra CS.RUN.LOOP1
2019-10-18 11:41:27 +00:00
2019-05-06 05:40:12 +00:00
.1 lda TimeOut
bne CS.RUN.LOOP1
2019-03-02 20:47:58 +00:00
2020-02-14 07:21:56 +00:00
jsr CS.RUN.GREETINGS
2019-03-02 20:47:58 +00:00
bcs CS.RUN.EXIT unable to send greetings...
2019-10-18 11:41:27 +00:00
2020-02-14 07:21:56 +00:00
.2 lda ArgProg
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
2020-02-14 07:21:56 +00:00
>PUSHYA
>PUSHBI S.PS.F.HOLD
2018-10-25 15:31:41 +00:00
>SYSCALL ExecV
2018-09-19 15:25:42 +00:00
>SLEEP
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
CS.RUN.EXIT lda bExitOnClose
2018-11-20 15:54:49 +00:00
bmi .8
2019-05-16 15:51:19 +00:00
2020-09-22 15:34:51 +00:00
ldy #S.PS.S
lda (ZPPtr1),y
cmp #S.PS.S.QUIT
beq .8
2018-09-19 15:25:42 +00:00
jmp CS.RUN.LOOP0
2017-10-05 15:39:17 +00:00
2018-11-20 15:54:49 +00:00
.8 lda #0
sec
2018-09-19 15:25:42 +00:00
CS.RUN.9 rts
2017-10-05 15:39:17 +00:00
*--------------------------------------
2019-02-20 16:07:43 +00:00
CS.RUN.IACMODE >SYSCALL GetChar Wait for IAC CMD (or SB)
bcs CS.RUN.9
2019-10-18 11:41:27 +00:00
2019-05-16 15:51:19 +00:00
sta IAC.CMD
2019-02-20 16:07:43 +00:00
>SYSCALL GetChar Wait for IAC SUBCMD
bcs CS.RUN.9
2019-10-18 11:41:27 +00:00
2019-05-18 15:38:31 +00:00
sta IAC.SUBCMD
tax
2019-05-16 15:51:19 +00:00
lda IAC.CMD
cmp #SB
2018-09-14 13:08:30 +00:00
beq CS.RUN.IAC.SB
2017-10-05 15:39:17 +00:00
*--------------------------------------
2018-09-14 13:08:30 +00:00
CS.RUN.IAC.CMD cmp #WILL
2018-09-13 15:29:02 +00:00
bne .8
2019-10-18 11:41:27 +00:00
2020-08-18 19:56:50 +00:00
cpx #TN.O.TTYPE
2018-09-13 15:29:02 +00:00
bne .2
2019-10-18 11:41:27 +00:00
2018-09-13 15:29:02 +00:00
>PUSHWI TELNETOPT.TTYPE.LEN
>PUSHW L.TELNETOPT.TTYPE
bra .7
2020-08-18 19:56:50 +00:00
.2 cpx #TN.O.LINEMODE
2018-09-13 15:29:02 +00:00
bne .8
2019-10-18 11:41:27 +00:00
2018-09-14 13:08:30 +00:00
>PUSHWI TELNETOPT.LMODE.LEN
>PUSHW L.TELNETOPT.LMODE
2019-10-18 11:41:27 +00:00
2018-09-13 15:29:02 +00:00
.7 ldy #S.PS.hStdOut
2020-02-28 07:21:46 +00:00
lda (pPS),y
2020-08-20 13:20:33 +00:00
>SYSCALL FWrite
2018-09-19 15:25:42 +00:00
.8 jmp CS.RUN.LOOP1
2017-10-05 15:39:17 +00:00
*--------------------------------------
2019-02-20 16:07:43 +00:00
CS.RUN.IAC.SB >SYSCALL GetChar Wait for IAC SB.IS or SEND
bcs .9
2019-05-16 15:51:19 +00:00
sta IAC.SB.CMD
stz IAC.SB.LEN
2019-02-20 16:07:43 +00:00
.2 >SYSCALL GetChar
bcs .9
2017-10-05 15:39:17 +00:00
cmp #IAC
2017-10-05 15:39:17 +00:00
beq .4 end of DATA, go wait SE
2019-05-16 15:51:19 +00:00
ldy IAC.SB.LEN
2017-10-05 15:39:17 +00:00
sta (pData),y
iny
lda #0
sta (pData),y
2019-05-16 15:51:19 +00:00
sty IAC.SB.LEN
cpy #IAC.BUF.MAX
bne .2
bra .8
2019-02-20 16:07:43 +00:00
.4 >SYSCALL GetChar
bcs .9
cmp #SE
2017-10-05 15:39:17 +00:00
bne .8
2019-05-16 15:51:19 +00:00
lda IAC.SUBCMD
2020-08-18 19:56:50 +00:00
cmp #TN.O.TTYPE
2017-10-05 15:39:17 +00:00
bne .8
2019-05-16 15:51:19 +00:00
lda IAC.SB.CMD
2017-10-05 15:39:17 +00:00
cmp #SB.IS
bne .8
2020-01-17 07:31:00 +00:00
>PUSHW L.ENV.TERM
2019-05-16 15:51:19 +00:00
>PUSHW pData IAC.SB.DATA
2017-10-05 15:39:17 +00:00
>SYSCALL SetEnv
2018-09-19 15:25:42 +00:00
.8 jmp CS.RUN.LOOP1
2019-02-20 16:07:43 +00:00
.9 rts
2020-02-14 07:21:56 +00:00
*--------------------------------------
CS.RUN.GREETINGS
>PUSHW L.MSG.GREETINGS
>PUSHB #K.VER
>PUSHB /K.VER
lda ArgDev
>SYSCALL ArgV
>PUSHYA
>PUSHBI 4
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-02-14 07:21:56 +00:00
rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
2019-05-06 05:40:12 +00:00
lda TimeOut
beq .9
2019-05-06 05:40:12 +00:00
dec TimeOut
.9 sec do not discard TIMER event
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2019-05-16 15:51:19 +00:00
CS.QUIT lda hFILE
beq .8
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
.8 clc
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
2018-11-20 15:54:49 +00:00
CkeckOption lda (ZPPtr1)
cmp #'-'
bne .8
2019-10-18 11:41:27 +00:00
2018-11-20 15:54:49 +00:00
ldy #2
lda (ZPPtr1),y
bne .8
2019-10-18 11:41:27 +00:00
2018-11-20 15:54:49 +00:00
dey
lda (ZPPtr1),y
2019-10-18 11:41:27 +00:00
ldx #OptionVars-OptionList-1
2018-11-20 15:54:49 +00:00
.2 cmp OptionList,x
beq .3
2019-10-18 11:41:27 +00:00
2018-11-20 15:54:49 +00:00
dex
2019-10-18 11:41:27 +00:00
bpl .2
2018-11-20 15:54:49 +00:00
sec invalid option
rts
2019-10-18 11:41:27 +00:00
.3 ldy OptionVars,x
2018-11-20 15:54:49 +00:00
eor #$80 toggle option
2019-05-23 15:38:32 +00:00
sta $0,y
2018-11-20 15:54:49 +00:00
lda #0 exit with 0
2019-10-18 11:41:27 +00:00
2019-05-23 15:38:32 +00:00
.8 clc !0 if not an option
2018-11-20 15:54:49 +00:00
rts
*--------------------------------------
2015-03-14 21:48:35 +00:00
CS.END
2019-10-18 11:41:27 +00:00
OptionList .AS "Ee"
2018-11-20 15:54:49 +00:00
OptionVars .DA #bExitOnClose,#bExitOnClose
2020-02-14 07:21:56 +00:00
MSG.GREETINGS .AZ "\r\nA2osX-GeTTY %d.%d on %s\r\n"
2018-11-20 15:54:49 +00:00
MSG.USAGE .AS "Usage : GETTY <DEV> <PROGRAM>\r\n"
.AZ " -E : Exit on disconnect\r\n"
2018-09-12 15:27:00 +00:00
*--------------------------------------
2020-08-18 19:56:50 +00:00
TELNETOPTS .DA #IAC,#WILL,#TN.O.BINARY
.DA #IAC,#WILL,#TN.O.ECHO
.DA #IAC,#WILL,#TN.O.SGA
.DA #IAC,#DO,#TN.O.SGA
* .DA #IAC,#DO,#TN.O.NAWS
.DA #IAC,#DO,#TN.O.TTYPE
.DA #IAC,#DO,#TN.O.LINEMODE
2018-09-12 15:27:00 +00:00
TELNETOPTS.LEN .EQ *-TELNETOPTS
2018-09-14 13:08:30 +00:00
*--------------------------------------
2020-08-18 19:56:50 +00:00
TELNETOPT.TTYPE .DA #IAC,#SB,#TN.O.TTYPE,#SB.SEND,#IAC,#SE
2018-09-13 15:29:02 +00:00
TELNETOPT.TTYPE.LEN .EQ *-TELNETOPT.TTYPE
2018-09-14 13:08:30 +00:00
*--------------------------------------
2020-08-18 19:56:50 +00:00
TELNETOPT.LMODE .DA #IAC,#SB,#TN.O.LINEMODE,#SB.SEND,#0,#IAC,#SE
2018-09-14 13:08:30 +00:00
TELNETOPT.LMODE.LEN .EQ *-TELNETOPT.LMODE
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
2019-05-16 15:51:19 +00:00
IAC.SB.DATA .BS IAC.BUF.MAX
2015-06-03 18:30:57 +00:00
DS.END .ED
2015-03-14 21:48:35 +00:00
MAN
2020-08-18 19:56:50 +00:00
SAVE usr/src/sbin/getty.s
2015-03-14 21:48:35 +00:00
ASM