A2osX/BIN/PPPTEST.S.txt
2021-03-11 22:40:55 +01:00

447 lines
10 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF root/ppptest
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
*--------------------------------------
TIMEOUT.MAX .EQ 200 20 sec.
BUFSIZE .EQ 256
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPBufPtr .BS 2
ZPBufLen .BS 2
ZPPtr1 .BS 2
ZPPtr2 .BS 2
FCS .BS 2
hBuf .BS 1
hDev .BS 1
TimeOut .BS 1
ZS.END
.ED
*--------------------------------------
* 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
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.DEVOK .DA MSG.DEVOK
L.MSG.AT .DA MSG.AT
L.MSG.BUFLEN .DA MSG.BUFLEN
L.MSG.HEXDUMP .DA MSG.HEXDUMP
L.PPP.1 .DA PPP.1
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
CS.RUN lda #1
>SYSCALL ArgV
bcs .9
>PUSHYA
>PUSHBI O.RDWR
>PUSHBI 0 type
>PUSHWZ auxtype
>SYSCALL FOpen
bcs .99
sta hDev
>LDYA L.MSG.DEVOK
>SYSCALL PutS
>LDYAI BUFSIZE
>SYSCALL GetMem
bcs .99
>STYA ZPBufPtr
stx hBuf
bra CS.RUN.TEST
* jmp CS.RUN.LOOP
.9 >LDYA L.MSG.USAGE
>SYSCALL PutS
lda #E.SYN
sec
.99 rts
*--------------------------------------
CS.RUN.TEST
* jsr ATInit
* bcs .9
>LDYAI PPP.1.LEN
>STYA ZPBufLen
>LDYA L.PPP.1
jsr PPPFCS16
>LDYA L.PPP.1
jsr DumpBuf
>PUSHWI PPP.1.LEN
>PUSHW L.PPP.1
lda hDev
>SYSCALL FWrite
bcs .9
>SLEEP
>PUSHWI BUFSIZE
>PUSHW ZPBufPtr
lda hDev
>SYSCALL FRead
bcs .9
>STYA ZPBufLen
>LDYA ZPBufPtr
jsr DumpBuf
lda #0
sec
.9
CS.RUN.RTS rts
*--------------------------------------
CS.RUN.LOOP >SLEEP
lda hDev
>SYSCALL FEOF
bcs CS.RUN.RTS
tay
bne .1 EOF, no char
>PUSHWI BUFSIZE
>PUSHW ZPBufPtr
lda hDev
>SYSCALL FRead
bcs CS.RUN.RTS
>PUSHYA len
>PUSHW ZPBufPtr
ldy #S.PS.hStdOut
lda (pPS),y
>SYSCALL FWrite
bcs .9
.1 ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL FEOF
bcs .9
tay
bne CS.RUN.LOOP EOF = true, no char from STDIN
>PUSHWI BUFSIZE
>PUSHW ZPBufPtr
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL FRead
bcs .9
tax
lda (ZPBufPtr)
cmp #$14 Ctrl-T
beq .9
txa
>PUSHYA len
>PUSHW ZPBufPtr
lda hDev
>SYSCALL FWrite
bcs .9
jmp CS.RUN.LOOP
.9 rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
lda TimeOut
beq .9
dec TimeOut
.9 sec do not discard TIMER event
rts
*--------------------------------------
CS.QUIT lda hDev
beq .1
>SYSCALL FClose
.1 lda hBuf
beq .2
>SYSCALL FreeMem
.2 clc
rts
*--------------------------------------
ATInit lda #250
sta TimeOut
>PUSHWI MSG.AT.LEN
>PUSHW L.MSG.AT
lda hDev
>SYSCALL FWrite
bcs .9
.1 lda hDev
>SYSCALL FEOF
bcs .9
tay
beq .2
>SLEEP
dec TimeOut
bne .1
rts
.2 >PUSHWI BUFSIZE
>PUSHW ZPBufPtr
lda hDev
>SYSCALL FRead
bcs .9
>PUSHYA len
>PUSHW ZPBufPtr
ldy #S.PS.hStdOut
lda (pPS),y
bcc .1
.9 rts
*--------------------------------------
* U16 fcs = 0xFFFF;
*
* while (len--)
* {
* fcs=(fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
* }
* return (~fcs);
*--------------------------------------
PPPFCS16 >STYA ZPPtr1
lda #$ff
sta FCS
sta FCS+1
lda ZPBufLen
sec
sbc #4 minus 7E .... FCS FCS 7E
eor #$ff
sta ZPPtr2
lda ZPBufLen+1
sbc #0
eor #$ff
sta ZPPtr2+1
.1 inc ZPPtr2
bne .2
inc ZPPtr2+1
beq .8
.2 inc ZPPtr1
bne .3
inc ZPPtr1+1
.3 lda (ZPPtr1)
eor FCS
tax
lda FCS.LO,x
eor FCS+1
sta FCS
lda FCS.HI,x
sta FCS+1
bra .1
.8 lda FCS+1
eor #$ff
ldy #1
sta (ZPPtr1),y
lda FCS
eor #$ff
iny
sta (ZPPtr1),y
rts
*--------------------------------------
DumpBuf >STYA ZPPtr1
>PUSHW L.MSG.BUFLEN
>PUSHW ZPBufLen
>PUSHBI 2
>SYSCALL PrintF
bcs .9
.1 >PUSHW L.MSG.HEXDUMP
ldy #0
.2 >PUSHB (ZPPtr1),y
iny
cpy #16
bne .2
>PUSHBI 16
>SYSCALL PrintF
bcs .9
lda ZPPtr1
adc #16
sta ZPPtr1
lda ZPPtr1+1
adc #0
sta ZPPtr1+1
lda ZPBufLen
sec
sbc #16
sta ZPBufLen
lda ZPBufLen+1
sbc #0
sta ZPBufLen+1
bcc .9
ora ZPBufLen
bne .1
clc
.9 rts
*--------------------------------------
CS.END
MSG.USAGE .AZ "Usage : TERM device "
MSG.DEVOK .AZ "Opening Device..."
MSG.AT .AS "ATI0"
.HS 0D0A
MSG.AT.LEN .EQ *-MSG.AT
MSG.BUFLEN .AZ "BufLen:%H\r\n"
MSG.HEXDUMP .AZ "%h:%h:%h:%h:%h:%h:%h:%h:%h:%h:%h:%h:%h:%h:%h:%h\r\n"
*--------------------------------------
FCS.LO .DA #$0000,#$1189,#$2312,#$329b,#$4624,#$57ad,#$6536,#$74bf
.DA #$8c48,#$9dc1,#$af5a,#$bed3,#$ca6c,#$dbe5,#$e97e,#$f8f7
.DA #$1081,#$0108,#$3393,#$221a,#$56a5,#$472c,#$75b7,#$643e
.DA #$9cc9,#$8d40,#$bfdb,#$ae52,#$daed,#$cb64,#$f9ff,#$e876
.DA #$2102,#$308b,#$0210,#$1399,#$6726,#$76af,#$4434,#$55bd
.DA #$ad4a,#$bcc3,#$8e58,#$9fd1,#$eb6e,#$fae7,#$c87c,#$d9f5
.DA #$3183,#$200a,#$1291,#$0318,#$77a7,#$662e,#$54b5,#$453c
.DA #$bdcb,#$ac42,#$9ed9,#$8f50,#$fbef,#$ea66,#$d8fd,#$c974
.DA #$4204,#$538d,#$6116,#$709f,#$0420,#$15a9,#$2732,#$36bb
.DA #$ce4c,#$dfc5,#$ed5e,#$fcd7,#$8868,#$99e1,#$ab7a,#$baf3
.DA #$5285,#$430c,#$7197,#$601e,#$14a1,#$0528,#$37b3,#$263a
.DA #$decd,#$cf44,#$fddf,#$ec56,#$98e9,#$8960,#$bbfb,#$aa72
.DA #$6306,#$728f,#$4014,#$519d,#$2522,#$34ab,#$0630,#$17b9
.DA #$ef4e,#$fec7,#$cc5c,#$ddd5,#$a96a,#$b8e3,#$8a78,#$9bf1
.DA #$7387,#$620e,#$5095,#$411c,#$35a3,#$242a,#$16b1,#$0738
.DA #$ffcf,#$ee46,#$dcdd,#$cd54,#$b9eb,#$a862,#$9af9,#$8b70
.DA #$8408,#$9581,#$a71a,#$b693,#$c22c,#$d3a5,#$e13e,#$f0b7
.DA #$0840,#$19c9,#$2b52,#$3adb,#$4e64,#$5fed,#$6d76,#$7cff
.DA #$9489,#$8500,#$b79b,#$a612,#$d2ad,#$c324,#$f1bf,#$e036
.DA #$18c1,#$0948,#$3bd3,#$2a5a,#$5ee5,#$4f6c,#$7df7,#$6c7e
.DA #$a50a,#$b483,#$8618,#$9791,#$e32e,#$f2a7,#$c03c,#$d1b5
.DA #$2942,#$38cb,#$0a50,#$1bd9,#$6f66,#$7eef,#$4c74,#$5dfd
.DA #$b58b,#$a402,#$9699,#$8710,#$f3af,#$e226,#$d0bd,#$c134
.DA #$39c3,#$284a,#$1ad1,#$0b58,#$7fe7,#$6e6e,#$5cf5,#$4d7c
.DA #$c60c,#$d785,#$e51e,#$f497,#$8028,#$91a1,#$a33a,#$b2b3
.DA #$4a44,#$5bcd,#$6956,#$78df,#$0c60,#$1de9,#$2f72,#$3efb
.DA #$d68d,#$c704,#$f59f,#$e416,#$90a9,#$8120,#$b3bb,#$a232
.DA #$5ac5,#$4b4c,#$79d7,#$685e,#$1ce1,#$0d68,#$3ff3,#$2e7a
.DA #$e70e,#$f687,#$c41c,#$d595,#$a12a,#$b0a3,#$8238,#$93b1
.DA #$6b46,#$7acf,#$4854,#$59dd,#$2d62,#$3ceb,#$0e70,#$1ff9
.DA #$f78f,#$e606,#$d49d,#$c514,#$b1ab,#$a022,#$92b9,#$8330
.DA #$7bc7,#$6a4e,#$58d5,#$495c,#$3de3,#$2c6a,#$1ef1,#$0f78
*--------------------------------------
FCS.HI .DA /$0000,/$1189,/$2312,/$329b,/$4624,/$57ad,/$6536,/$74bf
.DA /$8c48,/$9dc1,/$af5a,/$bed3,/$ca6c,/$dbe5,/$e97e,/$f8f7
.DA /$1081,/$0108,/$3393,/$221a,/$56a5,/$472c,/$75b7,/$643e
.DA /$9cc9,/$8d40,/$bfdb,/$ae52,/$daed,/$cb64,/$f9ff,/$e876
.DA /$2102,/$308b,/$0210,/$1399,/$6726,/$76af,/$4434,/$55bd
.DA /$ad4a,/$bcc3,/$8e58,/$9fd1,/$eb6e,/$fae7,/$c87c,/$d9f5
.DA /$3183,/$200a,/$1291,/$0318,/$77a7,/$662e,/$54b5,/$453c
.DA /$bdcb,/$ac42,/$9ed9,/$8f50,/$fbef,/$ea66,/$d8fd,/$c974
.DA /$4204,/$538d,/$6116,/$709f,/$0420,/$15a9,/$2732,/$36bb
.DA /$ce4c,/$dfc5,/$ed5e,/$fcd7,/$8868,/$99e1,/$ab7a,/$baf3
.DA /$5285,/$430c,/$7197,/$601e,/$14a1,/$0528,/$37b3,/$263a
.DA /$decd,/$cf44,/$fddf,/$ec56,/$98e9,/$8960,/$bbfb,/$aa72
.DA /$6306,/$728f,/$4014,/$519d,/$2522,/$34ab,/$0630,/$17b9
.DA /$ef4e,/$fec7,/$cc5c,/$ddd5,/$a96a,/$b8e3,/$8a78,/$9bf1
.DA /$7387,/$620e,/$5095,/$411c,/$35a3,/$242a,/$16b1,/$0738
.DA /$ffcf,/$ee46,/$dcdd,/$cd54,/$b9eb,/$a862,/$9af9,/$8b70
.DA /$8408,/$9581,/$a71a,/$b693,/$c22c,/$d3a5,/$e13e,/$f0b7
.DA /$0840,/$19c9,/$2b52,/$3adb,/$4e64,/$5fed,/$6d76,/$7cff
.DA /$9489,/$8500,/$b79b,/$a612,/$d2ad,/$c324,/$f1bf,/$e036
.DA /$18c1,/$0948,/$3bd3,/$2a5a,/$5ee5,/$4f6c,/$7df7,/$6c7e
.DA /$a50a,/$b483,/$8618,/$9791,/$e32e,/$f2a7,/$c03c,/$d1b5
.DA /$2942,/$38cb,/$0a50,/$1bd9,/$6f66,/$7eef,/$4c74,/$5dfd
.DA /$b58b,/$a402,/$9699,/$8710,/$f3af,/$e226,/$d0bd,/$c134
.DA /$39c3,/$284a,/$1ad1,/$0b58,/$7fe7,/$6e6e,/$5cf5,/$4d7c
.DA /$c60c,/$d785,/$e51e,/$f497,/$8028,/$91a1,/$a33a,/$b2b3
.DA /$4a44,/$5bcd,/$6956,/$78df,/$0c60,/$1de9,/$2f72,/$3efb
.DA /$d68d,/$c704,/$f59f,/$e416,/$90a9,/$8120,/$b3bb,/$a232
.DA /$5ac5,/$4b4c,/$79d7,/$685e,/$1ce1,/$0d68,/$3ff3,/$2e7a
.DA /$e70e,/$f687,/$c41c,/$d595,/$a12a,/$b0a3,/$8238,/$93b1
.DA /$6b46,/$7acf,/$4854,/$59dd,/$2d62,/$3ceb,/$0e70,/$1ff9
.DA /$f78f,/$e606,/$d49d,/$c514,/$b1ab,/$a022,/$92b9,/$8330
.DA /$7bc7,/$6a4e,/$58d5,/$495c,/$3de3,/$2c6a,/$1ef1,/$0f78
*--------------------------------------
PPP.1 .HS 7E
* .HS ff.03.C0.21.01.01.00.17.02.06.00.0a.00.00.05.06
* .HS 00.2a.2b.78.07.02.08.02.0d.03.06
* .HS A5.F8
PPP.1.START .HS FF03
.HS C021 LCP
PPP.1.LCP .HS 01 Configure-Request
.HS 01 ID
.DA /PPP.1.LCP.LEN,#PPP.1.LCP.LEN
.HS 01.04.05DC MRU
.HS 02.06.000A0000 ACCM
.HS 05.06.2A2B7807 MAGIC
PPP.1.LCP.LEN .EQ *-PPP.1.LCP
.BS 2 FCS
.HS 7E
PPP.1.LEN .EQ *-PPP.1
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END
.ED
*--------------------------------------
MAN
SAVE root/ppptest.s
ASM