BBSD & ACOS INPUT, SHUTDOWN with args, bobbi's stuff

This commit is contained in:
burniouf 2021-07-05 21:15:15 +02:00
parent 7d1f7507a3
commit 1bdffefd00
10 changed files with 596 additions and 44 deletions

Binary file not shown.

View File

@ -42,13 +42,13 @@ A2osX.QC.Start1 sei
ldx $280 some /PATH/.SYSTEM file passed ?
beq A2osX.QC.Start2
.2 dex
.2 dex
lda $280,x
cmp #'/'
bne .2
stx A2osX.QC.BOOT get /PATH/ in QC.BOOT...
.3 lda $280,x
sta A2osX.QC.BOOT,x
dex
@ -56,28 +56,46 @@ A2osX.QC.Start1 sei
jsr A2osX.QC.SetPFX cd to QC.BOOT...
bcs A2osX.QC.Start2
jsr A2osX.QC.Load
bcs A2osX.QC.Start2
lda $2000
cmp #$4C
bne .8
lda #$EE
cmp $2003
bne .8
cmp $2004
bne .8
ldx $280
*--------------------------------------
* $2000 = JMP $xxxx
* $2003 = $EE
* $2004 = $EE
* $2005 = BufSize
* $2006 = PathLen
* $2007... Path
*--------------------------------------
lda $2000
cmp #$4C
bne .8
lda #$EE
cmp $2003
bne .8
cmp $2004
bne .8
ldy $280
iny
lda $280,y
beq .8
cmp $2005
bcs .8
sta $2006
ldx #0
.4 iny
lda $280,y
inx
sta $2006,x
cpx $2006
bne .4
.8 jmp $2000
A2osX.QC.Start2 sec
@ -110,7 +128,7 @@ A2osX.QC.Start2 sec
.5 lda A2osX.QC.BOOT,x
sta $280,x
sta $2C0-1,x BOOT sz for KERNEL
sta $2C0-1,x BOOT sz for KERNEL
dex
bpl .5
@ -132,7 +150,7 @@ A2osX.QC.Start2 sec
sta $280,x
cpy SYSKERNEL
bne .7
stx $280
jsr A2osX.QC.Load
@ -152,11 +170,11 @@ A2osX.QC.SetPFX jsr MLI
A2osX.QC.Load >LDYAI MSG.LOAD
clc
jsr A2osX.QC.PrintYA
>LDYAI $280
clc
jsr A2osX.QC.PrintYA
jsr MLI
.DA #MLIOPEN
.DA MLIOPEN03
@ -190,12 +208,12 @@ A2osX.QC.Load >LDYAI MSG.LOAD
sec
rts
.8 >LDYAI MSG.LOAD.OK
sec
jsr A2osX.QC.PrintYA
clc
rts
rts
*--------------------------------------
A2osX.QC.PrintYA
php

View File

@ -169,6 +169,13 @@ CODE.FPRINTINT ldx #0
rts
*--------------------------------------
CODE.JSRRT lda #$20 JSR
jsr CODE.EmitByte
lda J.RT,x
jsr CODE.EmitByte
lda J.RT+1,x
jmp CODE.EmitByte
*--------------------------------------
CODE.FPUCALL lda #$A2 LDX #imm
jsr CODE.EmitByte
txa

View File

@ -594,6 +594,7 @@ CORE.GetVarType jsr CORE.GetChar
inc ZPInputBufPtr
bne .1
inc ZPInputBufPtr+1 skip $
.1 tax NZ

View File

@ -181,7 +181,28 @@ KW.ELSE clc
rts
*--------------------------------------
KW.INFO
KW.INPUT
lda #E.CSYN
sec
rts
*--------------------------------------
KW.INPUT jsr CORE.GetNextCharNB
bcs .9
jsr CORE.CreateOrGetVar
bcs .99
ldx #0
jsr CODE.JSRRT
jsr CODE.STRSET
clc
rts
.9 lda #E.CSYN
sec
.99 rts
*--------------------------------------
KW.KILL
KW.LINK
KW.LOG

View File

@ -18,6 +18,49 @@ RT.StrLeft
*--------------------------------------
RT.FileOpen
*--------------------------------------
RT.Input lda #0
sta (ZPStrBuf)
stz ZPPtr1
.1 >SYSCALL GetChar
bcs .9
ldy ZPPtr1
cmp #C.SPACE
bcs .7
cmp #C.CR
beq .8
cmp #C.BS
bne .1
cpy #0
beq .1
>SYSCALL PutChar
lda #C.SPACE
>SYSCALL PutChar
lda #C.BS
>SYSCALL PutChar
dec ZPPtr1
bra .1
.7 sta (ZPStrBuf),y
>SYSCALL PutChar
inc ZPPtr1
bne .1
.8 lda #0
sta (ZPStrBuf),y
>PUSHW ZPStrBuf
clc
.9 rts
*--------------------------------------
MAN
SAVE usr/src/bin/acos.s.rt
LOAD usr/src/bin/acos.s

View File

@ -169,6 +169,7 @@ J.ACOS.FN .DA FN.BYTE
.DA FN.VAL
.DA FN.WHENd
.DA FN.WIDTH
J.RT .DA RT.INPUT
.DA 0
*--------------------------------------
* Called once at process creation
@ -399,7 +400,7 @@ PrintErrorMsg >LDA.G bTrace
>SYSCALL FPrintF
rts
*--------------------------------------
* Precompiled code
* Pre-compiled code
*--------------------------------------
CCODE.PULLWS >PULLA
pha

View File

@ -1,3 +1,5 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
@ -379,3 +381,6 @@ MSG.CRLF .AZ "\r\n"
DS.START
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/bin/od.s
ASM

View File

@ -15,9 +15,12 @@ DEFAULT.TIMEOUT .EQ 60
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
CmdPtr .BS 2
ArgPtr .BS 2
Count .BS 1
Index .BS 1
Timeout .BS 4
bSec .BS 1
bTimeout .BS 1
@ -66,18 +69,9 @@ CS.RUN lda #DEFAULT.TIMEOUT
lda (ZPPtr1)
cmp #'-'
beq .2
bne .5
lda ArgPtr+1
bne .9
>LDYA ZPPtr1
>STYA ArgPtr
lda #3
sta Timeout
bra .1
.2 ldy #2
ldy #2
lda (ZPPtr1),y
bne .9
@ -113,6 +107,21 @@ CS.RUN lda #DEFAULT.TIMEOUT
sec
ror bRestart
bra .1
.5 >LDYA ZPPtr1
ldx CmdPtr+1
bne .6
>STYA CmdPtr
lda #3
sta Timeout
bra .1
.6 ldx ArgPtr+1
bne .1
>STYA ArgPtr
bra .1
.8 jsr CS.RUN.WAIT
bcs .99
@ -272,7 +281,6 @@ CS.RUN.DEV ldx #1
>PUSHBI 3
>SYSCALL PrintF
.7 inc Index
inc Index
@ -284,13 +292,13 @@ CS.RUN.DEV ldx #1
*--------------------------------------
CS.RUN.SYS stz $280
>LDYA ArgPtr
beq .9
>LDYA CmdPtr
beq .8
>PUSHYA
>PUSHWI $281
>SYSCALL RealPath
bcs .9
bcs .8
ldx #$ff
@ -299,8 +307,35 @@ CS.RUN.SYS stz $280
bne .1
stx $280
>LDYA ArgPtr
beq .8
>PUSHYA
>PUSHBI 2
txa Arg0 len
ora #$80 $280
inc +1 byte len
pha
inc skip arg1 len byte
>PUSHA
>SYSCALL RealPath
ply
ldy $280
ldx #$ff
.2 iny
inx
lda $281,y
bne .2
txa
ldy $280
iny
sta $280,y
.9 rts
.8 rts
*--------------------------------------
CS.GetPSByID ldx #0

421
SBIN/BBSD.S.txt Normal file
View File

@ -0,0 +1,421 @@
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF sbin/bbsd
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
.INB inc/eth.i
.INB inc/libtcpip.i
.INB inc/net.telnet.i
*--------------------------------------
TIMEOUT.MAX .EQ 200 20 sec.
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPIPCfgPtr .BS 2
ZPSktPtr .BS 2
ZPMsgFile .BS 2
ZPStartupFile .BS 2
hFile .BS 1
hLineBuf .BS 1
ZPLinePtr .BS 2
ZPPtr1 .BS 2
hMsgFile .BS 1
hStartupFile .BS 1
TimeOut .BS 1
hSrvSocket .BS 1
hClientSocket .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 CS
.DA DS.END-DS.START DS
.DA #32 SS
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.ETCBBSDCONF .DA ETCBBSDCONF
L.KEYWORDS.CONF .DA KEYWORDS.CONF
J.KEYWORDS.CONF .DA CS.RUN.CONF.TCPLISTEN
.DA CS.RUN.CONF.COMLISTEN
.DA CS.RUN.CONF.MSGFILE
.DA CS.RUN.CONF.STARTUPFILE
L.SA.LOCAL .DA SA.LOCAL
L.MSG.TCPWAIT .DA MSG.TCPWAIT
L.MSG.INITOK .DA MSG.INITOK
L.MSG.TCPIPERR .DA MSG.TCPIPERR
L.MSG.SKTERR .DA MSG.SKTERR
L.MSG.INCOMING .DA MSG.INCOMING
L.NOD.Template .DA NOD.Template
L.CMD.Template .DA CMD.Template
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
.9 rts
*--------------------------------------
CS.RUN lda #TIMEOUT.MAX
sta TimeOut
>LDYA L.MSG.TCPWAIT
>SYSCALL PutS
.1 >SLEEP
>LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
bcs .99
>STYA ZPIPCfgPtr
lda (ZPIPCfgPtr) Configured ?
bmi CS.RUN.INIT
lda TimeOut
beq .99
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL FEOF
bcs .9 I/O err
tay
bne .1
>SYSCALL GetChar
bcs .9
cmp #$03
bne .1
* sec
rts
.99 pha
>LDYA L.MSG.TCPIPERR
>SYSCALL PutS
pla
sec
.9 rts
CS.RUN.INIT ldx #3
ldy #S.IPCFG.IP+3
.1 lda (ZPIPCfgPtr),y
sta SA.LOCAL+S.SOCKADDR.ADDR,x
dey
dex
bpl .1
jsr CS.RUN.CONF
bcs .99
>PUSHBI S.SOCKET.T.STREAM
>PUSHBI 0 no protocol
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
bcs .9
sta hSrvSocket
>PUSHA
>PUSHW L.SA.LOCAL
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcs .9
lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Listen
bcs .9
>LDYA L.MSG.INITOK
>SYSCALL PutS
.2 >SLEEP
lda hSrvSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Accept
bcs .2
pha
jsr CS.RUN.CLIENT
pla
bcc .2
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
bra .2
.9 pha
>LDYA L.MSG.SKTERR
>SYSCALL PutS
pla
sec
.99 rts
*--------------------------------------
CS.RUN.CLIENT >SLEEP give some time for TCPIP SYN/ACK
sta hClientSocket
>SYSCALL GetMemPtr
>STYA ZPSktPtr
>PUSHW L.MSG.INCOMING
>PUSHB hClientSocket
ldx #3
ldy #S.SOCKET.REM.ADDR
.1 >PUSHB (ZPSktPtr),y
iny
dex
bpl .1
>PUSHBI 5
>SYSCALL PrintF
>PUSHEA.G NodBuf
>PUSHW L.NOD.Template
>PUSHB hClientSocket
>PUSHBI 1
>SYSCALL SPrintF
CS.RUN.CLIENT1 >PUSHEA.G NodBuf+5
>PUSHW 0
>PUSHB hClientSocket
>SYSCALL MKNod
bcs .9
>PUSHEA.G CmdBuf
>PUSHW L.CMD.Template
>PUSHEA.G NodBuf
>PUSHW ZPStartupFile
>PUSHBI 4
>SYSCALL SPrintF
>PUSHEA.G CmdBuf
>PUSHBI 0
>SYSCALL ExecL
* clc
.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 hSrvSocket
beq .3
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
.3 lda hLIBTCPIP
beq .8
>SYSCALL UnloadLib
.8 clc
CS.QUIT.RTS rts
*--------------------------------------
CS.RUN.CONF >PUSHW L.ETCBBSDCONF
>PUSHBI O.RDONLY+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ
>SYSCALL FOpen
bcs CS.QUIT.RTS
sta hFile
>LDYAI 256
>SYSCALL GetMem
bcs .97
>STYA ZPLinePtr
stx hLineBuf
.1 >PUSHB hFile
>PUSHW ZPLinePtr
>PUSHWI 256
>SYSCALL FGetS
bcs .8
tya
beq .1
lda (ZPLinePtr)
cmp #'#'
beq .1
>LDYA L.KEYWORDS.CONF
>STYA ZPPtr1
ldx #0
.2 ldy #0
.3 lda (ZPPtr1),y
cmp (ZPLinePtr),y
bne .4
iny
cmp #C.SPACE
bne .3
jsr CS.RUN.CONF.JMP
bcc .1
bra .97
.4 inx
inx
ldy #0
.5 iny
lda (ZPPtr1),y
cmp #C.SPACE
bne .5
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .6
inc ZPPtr1+1
.6 lda (ZPPtr1)
bne .2
.96 lda #E.SYN
sec
.HS 90 BCC
.8 clc
.97 php
pha
lda hLineBuf
beq .98
>SYSCALL FreeMem
.98 lda hFile
beq .99
>SYSCALL FClose
.99 pla
plp
rts
*--------------------------------------
CS.RUN.CONF.JMP tya
clc
adc ZPLinePtr
sta ZPPtr1
tay
lda #0
adc ZPLinePtr+1
sta ZPPtr1+1
jmp (J.KEYWORDS.CONF,x)
CS.RUN.CONF.TCPLISTEN
>SYSCALL AToI
bcs .9
>STYA SA.LOCAL+S.SOCKADDR.PORT
.9 rts
CS.RUN.CONF.COMLISTEN
.9 clc
rts
CS.RUN.CONF.MSGFILE
>PUSHYA
>PUSHWI 0 Allocate
>SYSCALL RealPath
bcs .9
>STYA ZPMsgFile
stx hMsgFile
.9 rts
CS.RUN.CONF.STARTUPFILE
>PUSHYA
>PUSHWI 0 Allocate
>SYSCALL RealPath
bcs .9
>STYA ZPStartupFile
stx hStartupFile
.9 rts
*--------------------------------------
CS.END
*--------------------------------------
hLIBTCPIP .BS 1
LIBTCPIP .AZ "libtcpip"
ETCBBSDCONF .AZ "${BOOT}etc/bbsd.conf"
*--------------------------------------
KEYWORDS.CONF .AS "tcplisten "
.AS "comlisten "
.AS "msgfile "
.AS "startupfile "
.DA #0
*--------------------------------------
MSG.TCPWAIT .AZ "BBSD:Waiting for TCP/IP initializing..."
MSG.INITOK .AZ "BBSD:Init Ok, Listening."
MSG.TCPIPERR .AZ "BBSD:TCP/IP Not initialized properly."
MSG.SKTERR .AZ "BBSD:Listen Error."
MSG.INCOMING .AZ "BBSD:Incoming Connection [SKT=%h] From : %d.%d.%d.%d\r\n"
*--------------------------------------
NOD.Template .AZ "/dev/tty%h"
CMD.Template .AZ "${ROOT}sbin/getty -E %s %s"
*--------------------------------------
SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
.BS 1
.BS 4 S.SOCKADDR.ADDR
.DA TCP.PORT.TELNET
*--------------------------------------
.DUMMY
.OR 0
DS.START
NodBuf .BS 11
CmdBuf .BS 65
DS.END .ED
*--------------------------------------
MAN
SAVE usr/src/sbin/bbsd.s
ASM