Kernel 0.92+

This commit is contained in:
Rémy GIBERT 2019-02-20 16:07:43 +00:00
parent 1dfc2bf03e
commit 4efc6c0860
17 changed files with 248 additions and 200 deletions

View File

@ -303,7 +303,7 @@ REG File created on ProDOS : T=TXT,X=$0000
`lda fd`
`>SYSCALL close`
# read
# read (BLOCKING)
## C
`int read(hFD fd, void *buf, int count);`
@ -319,7 +319,7 @@ REG File created on ProDOS : T=TXT,X=$0000
CC: Y,A = bytes read
CS: A = EC
# write
# write (BLOCKING)
## C
`int write(hFD fd, const void *buf, int count);`
@ -665,12 +665,10 @@ A = hFILE
return a hFILE to a new FIFO
## C
`hFILE mkfifo(const char *pathname, int mode);`
`hFILE mkfifo();`
## ASM
**In:**
`>PUSHW mode`
`>LDYA pathname`
`>SYSCALL mkfifo`
## RETURN VALUE
@ -689,7 +687,7 @@ A = hFILE
CC = OK, CS = ERROR
A = hFD
# PutChar
# putchar (BLOCKING)
Print A (char) to StdOut
## C
@ -703,7 +701,7 @@ Print A (char) to StdOut
## RETURN VALUE
CC = success
# FPutC
# fputc (BLOCKING)
Print A (char) to hFILE
## C
@ -718,7 +716,7 @@ Print A (char) to hFILE
## RETURN VALUE
CC = success
# PutS
# puts (BLOCKING)
Write Str to StdOut, appends '\r\n'
## C
@ -732,7 +730,7 @@ Write Str to StdOut, appends '\r\n'
## RETURN VALUE
CC = success
# FPutS
# fputs (BLOCKING)
Write Str to FILE
## C
@ -747,7 +745,11 @@ Write Str to FILE
## RETURN VALUE
CC = success
# PrintF/SPrintF/FPrintF
# PrintF (BLOCKING)
# FPrintF (BLOCKING)
# SPrintF
Prints C-Style String
## C
@ -818,7 +820,7 @@ Modifiers for len and padding :
+ %2f : '3.14'
# FGetS
# fgets (BLOCKING)
read bytes from stream into the array
pointed to by s, until n-1 bytes are read, or a <newline> is read and
transferred to s, or an end-of-file condition is encountered. The
@ -838,7 +840,7 @@ string is then terminated with a null byte.
Y,A: s
CC = success
# GetChar
# getchar (BLOCKING)
Get char from StdIn
## C
@ -852,7 +854,7 @@ Get char from StdIn
CC = success
A = char
# GetC
# getc (BLOCKING)
Get char from Node
## C
@ -941,7 +943,7 @@ int fclose ( hFILE stream );
## RETURN VALUE
# FRead
# FRead (BLOCKING)
Read bytes from file
## C
@ -957,7 +959,7 @@ int fread (hFILE stream, void * ptr, int count );
## RETURN VALUE
Y,A = Bytes Read
# FWrite
# FWrite (BLOCKING)
Write bytes to file
## C

View File

@ -97,7 +97,9 @@ CS.INIT
clc
.9 rts
*--------------------------------------
CS.RUN >SYSCALL GetChar
CS.RUN bra .11
>SYSCALL GetChar
bcs .10 no char
cmp #$03 Ctrl-C
@ -114,7 +116,7 @@ CS.RUN >SYSCALL GetChar
.10 >LDA.G bPause
bne .8 Pause...
>LDA.G hFILE
.11 >LDA.G hFILE
bne .2
.1 >INC.G ArgIndex

View File

@ -108,9 +108,8 @@ CS.RUN >PUSHBI 0
>SYSCALL printf Send Query for term W & H
bcs CS.RUN.RTS
.1 >SLEEP
>SYSCALL GetChar
bcs .1
.1 >SYSCALL GetChar
bcs CS.RUN.RTS
jsr CharIn
@ -139,15 +138,10 @@ CS.RUN >PUSHBI 0
>STA.G bSaved
jsr SCRN.Init
bcs CS.RUN.RTS
.9 bcs CS.RUN.RTS
CS.RUN.LOOP >SLEEP
>SYSCALL GetChar
bcc .1
tay
beq CS.RUN.LOOP no char
bra .9 I/O eror
CS.RUN.LOOP >SYSCALL GetChar
bcs CS.RUN.RTS I/O eror
.1 jsr CharIn
@ -159,7 +153,7 @@ CS.RUN.LOOP >SLEEP
>SYSCALL printf
lda #0
.9 sec
sec
CS.RUN.RTS rts
*--------------------------------------
CS.DOEVENT sec

View File

@ -102,7 +102,7 @@ CS.RUN
jsr InitSrcDirYA
bcs .9
*--------------------------------------
CS.RUN.LOOP >SLEEP
CS.RUN.LOOP bra .2
>SYSCALL GetChar
bcs .2 no char

View File

@ -63,33 +63,18 @@ CS.RUN >LEA.G MemStat
>LDYAI Mem.Table+S.MEM
>STYA ZPPTR1
CS.RUN.LOOP >SLEEP
>SYSCALL GetChar
bcs .13
cmp #3 Ctrl-C ?
beq .9
cmp #19 Ctrl-S ?
bne .12
>LDA.G bSTOP
eor #$ff
sta (pData),y
bra .13
.12 >STZ.G bSTOP
.13 >LDA.G bSTOP
bne CS.RUN.LOOP
>LDA.G LINE.COUNT
bne .1
>LDYA L.MSG0
>SYSCALL puts
CS.RUN.LOOP >LDA.G bSTOP
beq .1
>SYSCALL GetChar
cmp #3 Ctrl-C ?
beq CS.RUN.LOOP.RTS
>STZ.G bSTOP
.1 lda (ZPPTR1)
bpl .2
@ -111,11 +96,11 @@ CS.RUN.LOOP >SLEEP
bra CS.RUN.LOOP
.9 sec
rts
sec
CS.RUN.LOOP.RTS rts
CS.RUN.FOOTER >SYSCALL GetChar
bcs CS.RUN.FOOTER
bcs CS.RUN.LOOP.RTS
>PUSHB.G MEM.COUNT
>PUSHB.G USED.COUNT

View File

@ -229,7 +229,7 @@ CS.RUN.GETC >LDA.G hFILE
rts
.1 >SYSCALL GetChar
.2 rts
rts
*--------------------------------------
CS.RUN.GETLINE >PUSHWI 256
>PUSHW ZPBufPtr
@ -269,10 +269,7 @@ CS.RUN.GETLINE >PUSHWI 256
.8 sta (ZPBufPtr),y
clc
rts
.9 >DEBUG
rts
.9 rts
*--------------------------------------
CS.RUN.PRINT >LDA.G bLineNum
bpl .1

View File

@ -389,6 +389,14 @@ CMD.ECHO stz ZPPtr1 echo -N
CMD.GETKEY lda (ZPArgVBufPtr)
beq .99
ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL feof
bcs .9
tay
beq .1
>SYSCALL getchar
bcs .9

View File

@ -223,21 +223,22 @@ CS.RUN jsr CL.Init
*--------------------------------------
CS.RUN.LOOP
.1 jsr CheckSleep
beq .3
.1
* jsr CheckSleep
* beq .3
>SYSCALL GetChar
bcs .9 I/O err
* >SYSCALL GetChar
* bcs .9 I/O err
cmp #3 Ctrl-C
bne .1
* cmp #3 Ctrl-C
* bne .1
>LDA.G bBatchMode batch mode ?
beq .1
* >LDA.G bBatchMode batch mode ?
* beq .1
>LDA.G bSET.C
beq .8
bra .1
* >LDA.G bSET.C
* beq .8
* bra .1
.3 >LDA.G bPause
bpl .6
@ -359,22 +360,23 @@ CS.RUN.READ jsr CL.RESET
.8 jmp CS.RUN.LOOP.END
.9 rts
*--------------------------------------
CS.RUN.BATCH >SYSCALL GetChar
bcs .2
CS.RUN.BATCH
* >SYSCALL GetChar
* bcs .2
cmp #3 test Ctrl-c
bne .1
* cmp #3 test Ctrl-c
* bne .1
* sec
.9 rts
*.9 rts
.1 cmp #19 test Ctrl-s
bne .2
*.1 cmp #19 test Ctrl-s
* bne .2
lda #$80
>STA.G bPause
clc
jmp CS.RUN.LOOP.END
* lda #$80
* >STA.G bPause
* clc
* jmp CS.RUN.LOOP.END
.2 >LDA.G bSET.X
beq .5
@ -393,7 +395,7 @@ CS.RUN.BATCH >SYSCALL GetChar
>PUSHBI 2
>LDYA L.MSG.TRACE
>SYSCALL printf
bcs .9
bcs CS.RUN.LOOP.RTS
.5 jsr CORE.Run
bcc CS.RUN.LOOP.END

View File

@ -354,6 +354,8 @@ S.IOCTL.STATCODE.STATUS .EQ 0
S.IOCTL.STATCODE.GETDCB .EQ 1
S.IOCTL.STATCODE.GETNL .EQ 2
S.IOCTL.STATCODE.GETDIB .EQ 3
S.IOCTL.STATCODE.GETRC .EQ 4
S.IOCTL.STATCODE.GETWC .EQ 5
S.IOCTL.CTRLCODE .EQ 4 1 BYTE
S.IOCTL.CTRLCODE.RESET .EQ 0
S.IOCTL.CTRLCODE.SETDCB .EQ 1

View File

@ -117,14 +117,7 @@ CS.RUN.LOOP0 >LDYA L.ENV.TERM
ldy #S.PS.hStdOut
lda (pPs),y
>SYSCALL fwrite
bcc .2 sent!
tay
bne CS.RUN.9 error ?
>SLEEP
bra .1 no data sent, loop
bcs .9 I/O error
.2 >LDA.G ArgDev
>SYSCALL ArgV
@ -134,14 +127,21 @@ CS.RUN.LOOP0 >LDYA L.ENV.TERM
>LDYA L.MSG.GREETINGS
>SYSCALL printf
bcs CS.RUN.9 unable to send greetings...reset..
.9 bcs CS.RUN.9 unable to send greetings...reset..
jsr Init.Timeout
CS.RUN.LOOP1 >SLEEP
CS.RUN.LOOP1 ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL feof
bcs CS.RUN.9
tay
beq .1
>SYSCALL GetChar
bcs .1
bcs CS.RUN.9
cmp #IAC
beq CS.RUN.IACMODE
@ -171,16 +171,14 @@ CS.RUN.LOOP1 >SLEEP
sec
CS.RUN.9 rts
*--------------------------------------
CS.RUN.IACMODE >SLEEP Wait for IAC CMD (or SB)
>SYSCALL GetChar
bcs CS.RUN.IACMODE
CS.RUN.IACMODE >SYSCALL GetChar Wait for IAC CMD (or SB)
bcs CS.RUN.9
>STA.G IAC.CMD
.1 >SLEEP Wait for IAC SUBCMD
>SYSCALL GetChar
bcs .1
>SYSCALL GetChar Wait for IAC SUBCMD
bcs CS.RUN.9
>STA.G IAC.SUBCMD
tax
@ -210,18 +208,15 @@ CS.RUN.IAC.CMD cmp #WILL
.8 jmp CS.RUN.LOOP1
*--------------------------------------
CS.RUN.IAC.SB
.1 >SLEEP Wait for IAC SB.IS or SEND
>SYSCALL GetChar
bcs .1
CS.RUN.IAC.SB >SYSCALL GetChar Wait for IAC SB.IS or SEND
bcs .9
>STA.G IAC.SB.CMD
>STZ.G IAC.SB.LEN
.2 >SLEEP
>SYSCALL GetChar
bcs .2
.2 >SYSCALL GetChar
bcs .9
cmp #IAC
beq .4 end of DATA, go wait SE
@ -242,9 +237,8 @@ CS.RUN.IAC.SB
>INC.G IAC.SB.LEN
bra .2
.4 >SLEEP
>SYSCALL GetChar
bcs .4
.4 >SYSCALL GetChar
bcs .9
cmp #SE
bne .8
@ -262,6 +256,7 @@ CS.RUN.IAC.SB
>SYSCALL SetEnv
.8 jmp CS.RUN.LOOP1
.9 rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?

View File

@ -97,9 +97,8 @@ CS.RUN.REPaint >PUSHBI 0
>LDYA ZPCfgPtr
jsr CS.RUN.DumpConfYA
CS.RUN.Loop >SLEEP
>SYSCALL GetChar
bcs CS.RUN.Loop
CS.RUN.Loop >SYSCALL GetChar
bcs .99
cmp #17 Ctrl-Q
beq .8
@ -114,6 +113,7 @@ CS.RUN.Loop >SLEEP
>LDYA L.MSG.QUIT.ERR
bra .9
.99 rts
.1 cmp #20 Ctrl-T
bne .2

View File

@ -16,7 +16,7 @@ ZPPTR1 .BS 2
ZS.END
.ED
*--------------------------------------
INPUT.BufPtr.SIZE .EQ 16
INPUT.BUF.SIZE .EQ 16
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
@ -64,14 +64,10 @@ CS.RUN >STZ.G hUSERNAME
lda #0 Echo all caracters
jsr INPUT.RESET
.1 >SLEEP
>SYSCALL GetChar
bcc .11
tax
beq .1 no char
bra .9
.1 >SYSCALL GetChar
bcs .9
.11 jsr INPUT.CHARIN
jsr INPUT.CHARIN
jsr INPUT.LINEIN
bcc .1
@ -83,14 +79,10 @@ CS.RUN >STZ.G hUSERNAME
lda #'*'
jsr INPUT.RESET
.2 >SLEEP
>SYSCALL GetChar
bcc .22
tax
beq .2 no char
.9 rts
.2 >SYSCALL GetChar
bcs .9
.22 jsr INPUT.CHARIN
jsr INPUT.CHARIN
jsr INPUT.LINEIN
bcc .2
@ -105,7 +97,7 @@ CS.RUN >STZ.G hUSERNAME
>PUSHBI S.PS.F.HOLD+S.PS.F.DUPENV
>LDYA L.SHELL
>SYSCALL ExecL
rts
.9 rts
*--------------------------------------
CS.RUN.SETENV >PUSHW L.HOME
>LDYA L.ENV.HOME
@ -157,7 +149,7 @@ INPUT.CHARIN tax save char...
lda (ZPPTR1)
cmp #INPUT.BufPtr.SIZE Buffer full?
cmp #INPUT.BUF.SIZE Buffer full?
beq .9
inc
@ -231,7 +223,7 @@ HOME .AZ "${ROOT}ROOT/"
.DUMMY
.OR 0
DS.START
INPUT.BufPtr .BS INPUT.BufPtr.SIZE+1
INPUT.BUF .BS INPUT.BUF.SIZE+1
INPUT.Status .BS 1
INPUT.PassChar .BS 1
INPUT.PrevCR .BS 1

View File

@ -89,14 +89,14 @@ IO.Open.I ldx #5 $/DEV/
.DA IO.OPEN.DSOCK
.DA IO.OPEN.SSOCK
.DA IO.OPEN.PIPE
IO.OPEN.9 sec
IO.OPEN.RTS rts
*--------------------------------------
IO.OPEN.REG >MLICALL MLIGETFILEINFO
bcc IO.OPEN.REG.E Already Exists
bit K.Open.FLAGS Create if not exists ?
bpl IO.OPEN.9 No, return MLI error
bpl IO.OPEN.RTS No, return MLI error
ldx #2 Yes, Create...
@ -275,7 +275,7 @@ IO.CLOSE.NOD ldx #0
bne .1
rts
*/--------------------------------------
* # read
* # read (BLOCKING)
* ## C
* `int read(hFD fd, void *buf, int count);`
* ## ASM
@ -305,7 +305,7 @@ IO.Read.I lda (pFD) #S.FD.T
.DA IO.READ.SSOCK
.DA IO.READ.PIPE
*/--------------------------------------
* # write
* # write (BLOCKING)
* ## C
* `int write(hFD fd, const void *buf, int count);`
* ## ASM
@ -560,6 +560,40 @@ IO.MLIOPEN >LDYAI 1024 get a ProDOS IOBUF
* clc
.9 rts
*--------------------------------------
IO.EOF tax
jmp (.1,x)
.1 .DA STDIO.IOERR REG
.DA STDIO.IOERR DIR
.DA IO.EOF.CDEV
.DA STDIO.IOERR BDEV
.DA STDIO.IOERR LNK
.DA STDIO.IOERR DSOCK
.DA IO.EOF.SSOCK
.DA IO.EOF.PIPE
*--------------------------------------
IO.EOF.CDEV >LDYAI K.IOBuf
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
jsr K.IOCTL.GetPDrv
lda #S.IOCTL.STATCODE.GETRC
jsr K.GetDevStatus.I
bcs .9
lda K.IOBuf
ora K.IOBuf+1
.9 rts
*--------------------------------------
IO.EOF.SSOCK
*--------------------------------------
IO.EOF.PIPE
lda #MLI.E.IO
sec
rts
*--------------------------------------
IO.DEVDIR >PSTR "/DEV/"
*--------------------------------------
MAN

View File

@ -13,7 +13,7 @@ K.PrintF.PadC .EQ FAC+5
BCDBUF .EQ ARG
HEXBUF.Signed .EQ ARG.SIGN
*/--------------------------------------
* # PutChar
* # putchar (BLOCKING)
* Print A (char) to StdOut
* ## C
* `int putchar ( int character );`
@ -29,7 +29,7 @@ K.PutChar >PUSHA
ldy #S.PS.hStdOut
lda (pPs),y
*/--------------------------------------
* # FPutC
* # fputc (BLOCKING)
* Print A (char) to hFILE
* ## C
* `int fputc ( hFILE stream , int character );`
@ -55,7 +55,7 @@ K.FPutC.Y lda #0
jmp IO.Write.I
K.FPutC.9 >RET 1
*/--------------------------------------
* # PutS
* # puts (BLOCKING)
* Write Str to StdOut, appends '\r\n'
* ## C
* `int puts ( const char * str );`
@ -84,7 +84,7 @@ K.PutS >PUSHYA
K.PutS.RTS rts
*/--------------------------------------
* # FPutS
* # fputs (BLOCKING)
* Write Str to FILE
* ## C
* `int fputs (hFILE stream, const char * str );`
@ -107,7 +107,9 @@ K.FPutS jsr PFT.CheckNodeA set IO.hFD
jmp IO.Write.I
.9 >RET 2
*/--------------------------------------
* # PrintF/SPrintF/FPrintF
* # PrintF (BLOCKING)
* # FPrintF (BLOCKING)
* # SPrintF
* Prints C-Style String
* ## C
* `int printf ( const char * format, ... );`
@ -709,7 +711,7 @@ PrintF.Flush.hFILE
lda #$ff SELF MODIFIED
jmp K.FWrite
*/--------------------------------------
* # FGetS
* # fgets (BLOCKING)
* read bytes from stream into the array
* pointed to by s, until n-1 bytes are read, or a <newline> is read and
* transferred to s, or an end-of-file condition is encountered. The
@ -765,7 +767,7 @@ K.FGetS jsr PFT.CheckNodeA
.99 rts
K.FGetS.RET4 >RET 4
*/--------------------------------------
* # GetChar
* # getchar (BLOCKING)
* Get char from StdIn
* ## C
* `int getchar ();`
@ -779,7 +781,7 @@ K.FGetS.RET4 >RET 4
K.GetChar ldy #S.PS.hStdIn
lda (pPs),y
*/--------------------------------------
* # GetC
* # getc (BLOCKING)
* Get char from Node
* ## C
* `int getc ( hFILE stream );`
@ -1048,7 +1050,7 @@ K.FClose jsr PFT.CheckNodeA
.9 rts
*/--------------------------------------
* # FRead
* # FRead (BLOCKING)
* Read bytes from file
* ## C
* int fread (hFILE stream, void * ptr, int count );
@ -1066,7 +1068,7 @@ K.FRead jsr PFT.CheckNodeA
jmp IO.Read.I
*/--------------------------------------
* # FWrite
* # FWrite (BLOCKING)
* Write bytes to file
* ## C
* `int fwrite (hFILE stream, const void * ptr, int count );`
@ -1192,7 +1194,12 @@ K.FEOF.MARK .BS 3
K.FEOF jsr PFT.CheckNodeA
bcs .9
>MLICALL MLIGETMARK
lda (pFD)
beq .10
jmp IO.EOF
.10 >MLICALL MLIGETMARK
bcs .9
ldy #2

View File

@ -43,7 +43,7 @@ DRV.TERM.STATUS jsr DRV.TERM.GetIOCTLBufCntDCB
beq .1
cmp #S.IOCTL.STATCODE.GETDIB
bne .9
bne .3
ldy #S.DIB-1
.HS 2C bit abs
@ -60,7 +60,34 @@ DRV.TERM.STATUS jsr DRV.TERM.GetIOCTLBufCntDCB
clc
rts
.3 cmp #S.IOCTL.STATCODE.GETRC
bne .9
ldy #S.DCB.TTY.OUTTAIL
lda (ZPDCBPtr),y
iny
sbc (ZPDCBPtr),y OUTHEAD
and #$F
bit bActive
bpl .8
bit OPENAPPLE
bmi .8
bit KBD
bpl .8
inc
.8 sta (ZPBufPtr)
ldy #1
lda #0
sta (ZPBufPtr),y
clc
rts
.9 lda #MLI.E.BADCTL
sec
rts
@ -1219,55 +1246,6 @@ RESET.VALUES .DA #0 S.DCB.TTY.MODE
SCR.BASEL .HS 00.80.00.80.00.80.00.80.28.A8.28.A8.28.A8.28.A8.50.D0.50.D0.50.D0.50.D0
SCR.BASEH .HS 04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07.04.04.05.05.06.06.07.07
*--------------------------------------
BUF.BASEL .DA #0
.DA #80
.DA #160
.DA #240
.DA #320
.DA #400
.DA #480
.DA #560
.DA #640
.DA #720
.DA #800
.DA #880
.DA #960
.DA #1040
.DA #1120
.DA #1200
.DA #1280
.DA #1360
.DA #1440
.DA #1520
.DA #1600
.DA #1680
.DA #1760
.DA #1840
BUF.BASEH .DA /0
.DA /80
.DA /160
.DA /240
.DA /320
.DA /400
.DA /480
.DA /560
.DA /640
.DA /720
.DA /800
.DA /880
.DA /960
.DA /1040
.DA /1120
.DA /1200
.DA /1280
.DA /1360
.DA /1440
.DA /1520
.DA /1600
.DA /1680
.DA /1760
.DA /1840
*--------------------------------------
CtrlChars .HS 05080A0C0D151B
CtrlChars.Cnt .EQ *-CtrlChars
*--------------------------------------

View File

@ -226,6 +226,55 @@ GetCharAtCurPos ldy #S.DCB.TTY.CV
rts
*--------------------------------------
BUF.BASEL .DA #0
.DA #80
.DA #160
.DA #240
.DA #320
.DA #400
.DA #480
.DA #560
.DA #640
.DA #720
.DA #800
.DA #880
.DA #960
.DA #1040
.DA #1120
.DA #1200
.DA #1280
.DA #1360
.DA #1440
.DA #1520
.DA #1600
.DA #1680
.DA #1760
.DA #1840
BUF.BASEH .DA /0
.DA /80
.DA /160
.DA /240
.DA /320
.DA /400
.DA /480
.DA /560
.DA /640
.DA /720
.DA /800
.DA /880
.DA /960
.DA /1040
.DA /1120
.DA /1200
.DA /1280
.DA /1360
.DA /1440
.DA /1520
.DA /1600
.DA /1680
.DA /1760
.DA /1840
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.TERMLC
LOAD USR/SRC/SYS/KERNEL.S

View File

@ -453,6 +453,7 @@ K.StrFTime jsr MEM.SPtr1PPtr2
.8 lda #0 Terminate C string
sta (ZPPtr1)
clc
rts
*--------------------------------------
K.StrFTime.TBL .AS "aAbBdHImMpSwyY"