diff --git a/.Docs/KERNEL.md b/.Docs/KERNEL.md index 31af695c..6e13c228 100644 --- a/.Docs/KERNEL.md +++ b/.Docs/KERNEL.md @@ -829,6 +829,21 @@ A = hFILE CC = OK, CS = ERROR A = hFD +# fputc (BLOCKING) +Print A (char) to hFILE + +## C +`int fputc ( hFILE stream , short int character );` + +## ASM +**In:** +`>PUSHB stream` +`>PUSHB character` +`>SYSCALL fputc` + +## RETURN VALUE +CC = success + # putchar (BLOCKING) Print A (char) to StdOut @@ -843,21 +858,6 @@ Print A (char) to StdOut ## RETURN VALUE CC = success -# fputc (BLOCKING) -Print A (char) to hFILE - -## C -`int fputc ( hFILE stream , short int character );` - -## ASM -**In:** -`>PUSHB character` -`lda stream` -`>SYSCALL fputc` - -## RETURN VALUE -CC = success - # puts (BLOCKING) Write Str to StdOut, appends '\r\n' @@ -1004,9 +1004,9 @@ Read bytes from file ## ASM **In:** -`>PUSHWI count` +`>PUSHB stream` `>PUSHW ptr` -`lda stream` +`>PUSHW count` `>SYSCALL fread` ## RETURN VALUE @@ -1020,9 +1020,9 @@ Write bytes to file ## ASM **In:** -`>PUSHWI count` +`>PUSHB stream` `>PUSHW ptr` -`lda stream` +`>PUSHW count` `>SYSCALL fwrite` ## RETURN VALUE @@ -1046,9 +1046,9 @@ Set the file-position indicator for hFILE ## ASM **In:** -`>PUSHBI whence` +`>PUSHB stream` `>PUSHL offset` -`lda stream` +`>PUSHB whence` `>SYSCALL fseek` # FEOF @@ -1561,8 +1561,8 @@ Convert S.TIME struct to CSTR ## ASM **In:** +`>PUSHW pathname` `>PUSHB flags` -`>LDYA pathname` `>SYSCALL open` ## RETURN VALUE @@ -1586,9 +1586,9 @@ REG File created on ProDOS : T=TXT,X=$0000 ## ASM **In:** -`>PUSHWI count` +`>PUSHB fd` `>PUSHW buf` -`lda fd` +`>PUSHW count` `>SYSCALL read` ## RETURN VALUE @@ -1602,15 +1602,28 @@ CS: A = EC ## ASM **In:** -`>PUSHWI count` +`>PUSHB fd` `>PUSHW buf` -`lda fd` +`>PUSHW count` `>SYSCALL write` ## RETURN VALUE CC: Y,A = bytes written CS: A = EC +# LSeek +Set the file-position indicator for hFD + +## C +`int lseek( short int hFD, long offset, short int whence );` + +## ASM +**In:** +`>PUSHB hFD` +`>PUSHL offset` +`>PUSHB whence` +`>SYSCALL fseek` + # ChOwn ## C diff --git a/.Floppies/A2OSX.BUILD.po b/.Floppies/A2OSX.BUILD.po index 4a2ed30a..3c64be38 100644 Binary files a/.Floppies/A2OSX.BUILD.po and b/.Floppies/A2OSX.BUILD.po differ diff --git a/BIN/ASM.S.FIO.txt b/BIN/ASM.S.FIO.txt index d043962a..adfe3b7a 100644 --- a/BIN/ASM.S.FIO.txt +++ b/BIN/ASM.S.FIO.txt @@ -6,6 +6,7 @@ FIO.Init.RTS rts FIO.Init >LDYAI 256 >SYSCALL GetMem bcs FIO.Init.RTS + >STYA ZPLineBuf txa >STA.G SRC.hLineBuf @@ -13,6 +14,7 @@ FIO.Init >LDYAI 256 >LDYAI 256 >SYSCALL GetMem bcs FIO.Init.RTS + >STYA ZPTmpBuf txa >STA.G SRC.hTmpBuf @@ -183,10 +185,12 @@ FIO.ReadLine >LDA.G SRC.Depth lda (pData),y bmi .10 - >PUSHWI 256 + jsr FIO.GethFile >PUSHW ZPLineBuf + >PUSHWI 256 jsr FIO.ReadFromFile bcs .19 + tya beq .13 @@ -194,17 +198,21 @@ FIO.ReadLine >LDA.G SRC.Depth lda (ZPLineBuf),y eor #C.CR beq .22 + iny .22 lda #0 replace ending $0D with $00 .13 sta (ZPLineBuf),y >INC.G SRC.LINENUM bne .19 + >INC.G SRC.LINENUM+1 + .19 rts *--------------------------------------- -.10 >PUSHWI 3 +.10 jsr FIO.GethFile >PUSHW ZPTmpBuf + >PUSHWI 3 jsr FIO.ReadFromFile bcs .19 @@ -216,61 +224,81 @@ FIO.ReadLine >LDA.G SRC.Depth >STA.G SRC.LINENUM+1 pla >STA.G SRC.LINENUM - lda (ZPTmpBuf) LEN + + + jsr FIO.GethFile + >PUSHW ZPTmpBuf + + lda #0 LENHI = 0 + >PUSHA + + lda (ZPTmpBuf) LEN sec sbc #3 - bcc .9 LEN should be at least 3 + bcc .9 LEN should be at least 3 - tay - lda #0 - >PUSHYA - >PUSHW ZPTmpBuf + >PUSHA jsr FIO.ReadFromFile bcs .9 + >LDYA ZPTmpBuf >STYA ZPPtr1 ldy #0 .1 lda (ZPPtr1) inc ZPPtr1 bne .11 + inc ZPPtr1+1 .11 tax bmi .2 + sta (ZPLineBuf),y beq .8 Ending 00 iny bne .1 + bra .99 + .2 cmp #$C0 REPEAT char? bne .5 lda (ZPPtr1) Get Repeat Count inc ZPPtr1 bne .3 + inc ZPPtr1+1 + .3 tax lda (ZPPtr1) Get Repeat Char inc ZPPtr1 bne .4 + inc ZPPtr1+1 + .4 sta (ZPLineBuf),y iny beq .99 + dex bne .4 bra .1 + .5 and #$3F Compute blank count tax lda #$20 + .6 sta (ZPLineBuf),y iny beq .99 + dex bne .6 + bra .1 + .8 clc .9 rts @@ -278,17 +306,21 @@ FIO.ReadLine >LDA.G SRC.Depth sec rts *-------------------------------------- -FIO.ReadFromFile - >LDA.G SRC.Depth +FIO.GethFile >LDA.G SRC.Depth clc adc #SRC.hFILES-1 tay lda (pData),y - + >PUSHA + rts +*-------------------------------------- +FIO.ReadFromFile >SYSCALL FRead bcs .9 + tax $100 byte transfered ? beq .9 + lda #E.LINE.TOO.LONG sec .9 rts diff --git a/BIN/ASM.S.OUT.txt b/BIN/ASM.S.OUT.txt index cb355a2c..de40fbd1 100644 --- a/BIN/ASM.S.OUT.txt +++ b/BIN/ASM.S.OUT.txt @@ -16,13 +16,13 @@ OUT.EmitByte phy >LDA.G ASM.DU.ON bmi .1 + >PUSHB.G DST.hREFNUM txa - pha >PUSHA - >LDA.G DST.hREFNUM + phx >SYSCALL FPutC plx - bcs .99 + bcs .9 .1 >INC.G ASM.PC bne .2 @@ -50,7 +50,7 @@ OUT.EmitByte phy phx jsr OUT.PrintBuf plx - bcs .99 + bcs .9 ldy #OUT.Buf lda #0 @@ -65,7 +65,7 @@ OUT.EmitByte phy .8 clc -.99 plx +.9 plx ply rts *--------------------------------------- diff --git a/BIN/CMP.S.txt b/BIN/CMP.S.txt index 5acae314..6c7fd739 100644 --- a/BIN/CMP.S.txt +++ b/BIN/CMP.S.txt @@ -239,32 +239,32 @@ CS.RUN.SEEK >LDYA ZPPtr1 bcs .9 >PULLL SeekOfs + lda bSkip1 bmi .1 - >PUSHBI SEEK.SET + >PUSHB hFile1 >PUSHL SeekOfs - lda hFile1 - + >PUSHBI SEEK.SET >SYSCALL FSeek bcs .9 -.1 >PUSHBI SEEK.SET +.1 >PUSHB hFile2 >PUSHL SeekOfs - lda hFile2 + >PUSHBI SEEK.SET >SYSCALL FSeek .9 rts *-------------------------------------- -CS.RUN.READ1 >PUSHWI 256 +CS.RUN.READ1 >PUSHB hFile1 >PUSHW ZPBufPtr1 - lda hFile1 + >PUSHWI 256 >SYSCALL FRead rts *-------------------------------------- -CS.RUN.READ2 >PUSHWI 256 +CS.RUN.READ2 >PUSHB hFile2 >PUSHW ZPBufPtr2 - lda hFile2 + >PUSHWI 256 >SYSCALL FRead rts *-------------------------------------- diff --git a/BIN/CSH.S.CORE.txt b/BIN/CSH.S.CORE.txt index 7bae2fe7..df37fd4d 100644 --- a/BIN/CSH.S.CORE.txt +++ b/BIN/CSH.S.CORE.txt @@ -346,6 +346,12 @@ CSH.fDeclaration lda #CSH.Q.FUNC tsb ZPVarType + + jsr CSH.SkipLine + clc + rts + + jsr CSH.GetNextCharNB Skip ( bcs .9 @@ -359,8 +365,6 @@ CSH.fDeclaration .5 jsr CSH.GetNextCharNB Skip ) - jsr CSH.SkipLine - clc rts diff --git a/BIN/CSH.S.EXEC.txt b/BIN/CSH.S.EXEC.txt index 35c3a428..ed743890 100644 --- a/BIN/CSH.S.EXEC.txt +++ b/BIN/CSH.S.EXEC.txt @@ -114,6 +114,10 @@ CSH.BOPS.LOR clc rts *-------------------------------------- +EXEC.pwr >FPU PWR + clc + rts +*-------------------------------------- EXEC.log >FPU LOG clc rts @@ -183,7 +187,17 @@ EXEC.malloc >PULLYA >PUSHYA rts *-------------------------------------- - +EXEC.fopen >SYSCALL FOpen + >PUSHYA +*-------------------------------------- +EXEC.fclose >SYSCALL FClose + >PUSHYA +*-------------------------------------- +EXEC.fread >SYSCALL FRead + >PUSHYA +*-------------------------------------- +EXEC.fwrite >SYSCALL FWrite + >PUSHYA *-------------------------------------- MAN SAVE usr/src/bin/csh.s.exec diff --git a/BIN/CSH.S.KW.txt b/BIN/CSH.S.KW.txt index eb928b9a..5980eb12 100644 --- a/BIN/CSH.S.KW.txt +++ b/BIN/CSH.S.KW.txt @@ -11,22 +11,29 @@ CSH.KW.JMP txa CSH.WHILE CSH.IF jsr CSH.GetCharNB bcs .9 + cmp #'(' bne .9 + jsr CSH.GetNextCharNB bcs .9 lda #0 Any var type jsr CSH.ExpEval bcs .99 + jsr CSH.GetCharNB bcs .99 + cmp #')' bne .9 + jsr CSH.GetNextCharNB skip ')' bcs .99 + cmp #'{' bne .9 + jsr CSH.GetNextCharNB Skip '{' bcs .99 @@ -44,6 +51,7 @@ CSH.IF jsr CSH.GetCharNB pla .1 jsr CSH.Push bcs .99 + lda #'}' Tell '}' is expected at the end of block jsr CSH.Push bcs .99 diff --git a/BIN/CSH.S.txt b/BIN/CSH.S.txt index 663575ae..f9b2e2f0 100644 --- a/BIN/CSH.S.txt +++ b/BIN/CSH.S.txt @@ -164,7 +164,8 @@ J.CSH.STYPES .DA CSH.SCHAR J.CSH.KW.END .DA CSH.IF.END .DA CSH.WHILE.END *-------------------------------------- -J.CSH.EXEC .DA EXEC.log +J.CSH.EXEC .DA EXEC.pwr + .DA EXEC.log .DA EXEC.sqr .DA EXEC.exp .DA EXEC.cos @@ -181,6 +182,10 @@ J.CSH.EXEC .DA EXEC.log .DA EXEC.unsetenv .DA EXEC.MD5 .DA EXEC.malloc + .DA EXEC.fopen + .DA EXEC.fclose + .DA EXEC.fread + .DA EXEC.fwrite .DA 0 *-------------------------------------- * Called once at process creation @@ -358,9 +363,10 @@ PrintErrMsg lda hDefine cmp ZPInputBufPtr+1 beq .8 -.6 >PUSHBI '-' - ldy #S.PS.hStdErr +.6 ldy #S.PS.hStdErr lda (pPS),y + >PUSHA + >PUSHBI '-' >SYSCALL FPutC inc ZPPtr3 bne .5 @@ -390,9 +396,10 @@ PrintDebugMsg >LDYA pStack *-------------------------------------- PrintTraceMsg >STYA ZPPtr3 -PrintTraceMsg.3 >PUSHBI '>' - ldy #S.PS.hStdErr +PrintTraceMsg.3 ldy #S.PS.hStdErr lda (pPS),y + >PUSHA + >PUSHBI '>' >SYSCALL FPutC ldy #$ff @@ -405,9 +412,12 @@ PrintTraceMsg.3 >PUSHBI '>' beq .8 phy - >PUSHA + pha ldy #S.PS.hStdErr lda (pPS),y + >PUSHA + pla + >PUSHA >SYSCALL FPutC ply bra .1 @@ -543,7 +553,13 @@ CSH.FTYPES >PSTR "fastcall" CSH.TYPESIZE .HS 0001010202040405 *-------------------------------------- CSH.FN -* float cos ( float x ); +* float pwr (float x, float y); + >PSTR "pwr" + .DA #CSH.T.FLOAT returned value + .DA #CSH.T.FLOAT + .DA #CSH.T.FLOAT + .DA #0 +* float cos (float x); >PSTR "log" .DA #CSH.T.FLOAT returned value .DA #CSH.T.FLOAT @@ -626,6 +642,33 @@ CSH.FN .DA #CSH.Q.POINTER+CSH.T.VOID returned value .DA #CSH.T.SINT .DA #0 +* short int fopen(const char*,short int,short int,int); + >PSTR "fopen" + .DA #CSH.T.SCHAR + .DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.UCHAR + .DA #CSH.T.SCHAR + .DA #CSH.T.SCHAR + .DA #CSH.T.SINT + .DA #0 +* int fclose(short int); + >PSTR "fclose" + .DA #CSH.T.SINT + .DA #CSH.T.SCHAR + .DA #0 +* int fread (short int,void*,int); + >PSTR "fread" + .DA #CSH.T.SINT + .DA #CSH.T.SCHAR + .DA #CSH.Q.POINTER+CSH.T.VOID + .DA #CSH.T.SINT + .DA #0 +* int fwrite (short int,const void*,int); + >PSTR "fwrite" + .DA #CSH.T.SINT + .DA #CSH.T.SCHAR + .DA #CSH.Q.CONST+CSH.Q.POINTER+CSH.T.VOID + .DA #CSH.T.SINT + .DA #0 *-------------------------------------- .DA #0 *-------------------------------------- diff --git a/BIN/EDIT.S.FILE.txt b/BIN/EDIT.S.FILE.txt index 7d7155b3..840e551a 100644 --- a/BIN/EDIT.S.FILE.txt +++ b/BIN/EDIT.S.FILE.txt @@ -496,17 +496,25 @@ FILE.Open stz TmpIndex .9 rts *-------------------------------------- -FILE.ReadY lda #0 - >PUSHYA +FILE.ReadY phy + + >PUSHB TmpIndex >PUSHW ZPPTR1 - lda TmpIndex + + ply + lda #0 + >PUSHYA >SYSCALL FRead rts *-------------------------------------- -FILE.WriteY lda #0 - >PUSHYA +FILE.WriteY phy + + >PUSHB TmpIndex >PUSHW ZPPTR1 - lda TmpIndex + + ply + lda #0 + >PUSHYA >SYSCALL FWrite rts *-------------------------------------- diff --git a/BIN/FORTH.S.GFX.txt b/BIN/FORTH.S.GFX.txt index 581a7350..1807798d 100644 --- a/BIN/FORTH.S.GFX.txt +++ b/BIN/FORTH.S.GFX.txt @@ -1,8 +1,8 @@ NEW AUTO 3,1 *-------------------------------------- -GFX.Open >PUSHBI 0 - >LDYA L.DEV.GFX +GFX.Open >PUSHW L.DEV.GFX + >PUSHBI 0 >SYSCALL Open bcs .9 diff --git a/BIN/GTEST.S.txt b/BIN/GTEST.S.txt index 1db3b9e7..894d59c4 100644 --- a/BIN/GTEST.S.txt +++ b/BIN/GTEST.S.txt @@ -277,8 +277,8 @@ CS.QUIT lda hFont .7 lda hDevGFX beq .8 -* >DEBUG -* >SYSCALL close + + >SYSCALL close .8 clc rts @@ -310,8 +310,8 @@ LoadResources >LDYA L.FONTFILE .9 rts *-------------------------------------- -GFX.Open >PUSHBI 0 - >LDYA L.DEVNAME.GFX +GFX.Open >PUSHW L.DEVNAME.GFX + >PUSHBI 0 >SYSCALL Open bcs .9 sta hDevGFX diff --git a/BIN/HTTPGET.S.txt b/BIN/HTTPGET.S.txt index 248eb6bb..6287e522 100644 --- a/BIN/HTTPGET.S.txt +++ b/BIN/HTTPGET.S.txt @@ -512,16 +512,16 @@ CS.RUN.RESPONSE jsr Init.TimeOut sec ror bHeader -.6 >PUSHW ZPRespBufLen - >PUSHW ZPRespBufPtr - - lda hFile +.6 lda hFile bne .7 ldy #S.PS.hStdOut lda (pPS),y -.7 >SYSCALL FWrite +.7 >PUSHA + >PUSHW ZPRespBufPtr + >PUSHW ZPRespBufLen + >SYSCALL FWrite bcs .9 lda hRespBuf diff --git a/BIN/KCONFIG.S.txt b/BIN/KCONFIG.S.txt index 7cdfa552..3cbe449d 100644 --- a/BIN/KCONFIG.S.txt +++ b/BIN/KCONFIG.S.txt @@ -244,8 +244,9 @@ CS.RUN.Save >PUSHW L.FILENAME bcs .9 pha save hFile - >PUSHWI 16 LEN + >PUSHA >PUSHW ZPCfgPtr + >PUSHWI 16 LEN pla pha >SYSCALL FWrite @@ -258,6 +259,7 @@ CS.RUN.Save >PUSHW L.FILENAME pla sec rts + .1 pla >SYSCALL FClose diff --git a/BIN/MD5.S.txt b/BIN/MD5.S.txt index faf8bc3d..f31237f4 100644 --- a/BIN/MD5.S.txt +++ b/BIN/MD5.S.txt @@ -133,9 +133,9 @@ CS.RUN.FILE >LDYAI FILEBUF.SIZE .1 >SLEEP - >PUSHWI FILEBUF.SIZE Bytes To Read + >PUSHB hFile >PUSHW ZPDataBufPtr Dst Ptr - lda hFile + >PUSHWI FILEBUF.SIZE Bytes To Read >SYSCALL FRead bcc .2 diff --git a/BIN/PAK.S.txt b/BIN/PAK.S.txt index 30745309..795b2ca7 100644 --- a/BIN/PAK.S.txt +++ b/BIN/PAK.S.txt @@ -370,9 +370,9 @@ CS.RUN.OpenFile >PUSHW ZPFullPath .9 rts *-------------------------------------- -CS.RUN.ReadFile >PUSHWI CHNK.SIZE +CS.RUN.ReadFile >PUSHB.G hFile >PUSHW ZPSrcBufPtr - >LDA.G hFile + >PUSHWI CHNK.SIZE >SYSCALL FRead bcs .9 @@ -431,17 +431,15 @@ CS.RUN.AppendArc rts + >PUSHB.G hArcFile + >PUSHLZ >PUSHBI SEEK.SET - >PUSHWI 0 - >PUSHWI 0 - >LDA.G hArcFile >SYSCALL FSeek bcs CS.RUN.OpenArc.RTS - >PUSHWI 3 + >PUSHB.G hArcFile >PUSHW ZPSrcBufPtr - >LDA.G hArcFile - + >PUSHWI 3 >SYSCALL FRead bcs .9 @@ -456,10 +454,9 @@ CS.RUN.AppendArc dey bpl .2 + >PUSHB.G hArcFile + >PUSHLZ >PUSHBI SEEK.END - >PUSHWI 0 - >PUSHWI 0 - >LDA.G hArcFile >SYSCALL FSeek * bcc .9 * cmp #MLI.E.EOF @@ -547,9 +544,9 @@ CS.RUN.WriteSrcData jsr CS.RUN.WriteArcByteA bcs .9 - >PUSHW.G Shunk.SrcSize + >PUSHB.G hArcFile >PUSHW ZPSrcBufPtr - >LDA.G hArcFile + >PUSHW.G Shunk.SrcSize >SYSCALL FWrite .9 rts *-------------------------------------- @@ -566,9 +563,9 @@ CS.RUN.WritePakData jsr CS.RUN.WriteArcByteA bcs .9 - >PUSHW.G Shunk.DstSize + >PUSHB.G hArcFile >PUSHW ZPDstBufPtr - >LDA.G hArcFile + >PUSHW.G Shunk.DstSize >SYSCALL FWrite .9 rts *-------------------------------------- @@ -576,8 +573,10 @@ CS.RUN.WriteArcByteY lda (ZPFileStat),y CS.RUN.WriteArcByteA + pha + >PUSHB.G hArcFile + pla >PUSHA - >LDA.G hArcFile >SYSCALL FPutC rts *-------------------------------------- diff --git a/BIN/PAKME.S.txt b/BIN/PAKME.S.txt index 8f6729d4..43a55440 100644 --- a/BIN/PAKME.S.txt +++ b/BIN/PAKME.S.txt @@ -122,22 +122,21 @@ CS.RUN.START >PUSHW L.MSG.SRCFILE jsr CS.RUN.GetSrcBufYA bcs CS.RUN.RTS + >PUSHB hSrcFile + >PUSHLZ >PUSHBI SEEK.SET - >PUSHWZ - >PUSHWZ - lda hSrcFile >SYSCALL FSeek bcs CS.RUN.RTS - >PUSHW ZPDstTableOfs + >PUSHB hSrcFile >PUSHW ZPSrcBufPtr - lda hSrcFile + >PUSHW ZPDstTableOfs >SYSCALL FRead bcs CS.RUN.RTS - >PUSHW ZPDstTableOfs + >PUSHB hDstFile >PUSHW ZPSrcBufPtr - lda hDstFile + >PUSHW ZPDstTableOfs >SYSCALL FWrite bcs CS.RUN.RTS @@ -259,7 +258,7 @@ CS.RUN.CheckSrcFile CS.RUN.CheckSrcFile.RTS rts *-------------------------------------- -CS.RUN.CheckTAG >PUSHBI SEEK.SET +CS.RUN.CheckTAG >PUSHB hSrcFile >PUSHWZ lda ZPSrcFileSize @@ -270,13 +269,13 @@ CS.RUN.CheckTAG >PUSHBI SEEK.SET sbc #0 >PUSHYA - lda hSrcFile + >PUSHBI SEEK.SET >SYSCALL FSeek bcs CS.RUN.CheckSrcFile.RTS - >PUSHWI 10 + >PUSHB hSrcFile >PUSHEA.G PAKME.HEADER - lda hSrcFile + >PUSHWI 10 >SYSCALL FRead bcs CS.RUN.CheckSrcFile.RTS @@ -307,13 +306,15 @@ CS.RUN.GetTable >LDA.G PAKME.HEADER+8 >SBC.G PAKME.HEADER+6 sta ZPDstTableOfs+1 - >PUSHBI SEEK.SET + >PUSHB hSrcFile >PUSHWZ >PUSHW ZPDstTableOfs - lda hSrcFile + >PUSHBI SEEK.SET >SYSCALL FSeek bcs .9 + >PUSHB hSrcFile + >PUSHEA.G PAKME.TABLE >LDA.G PAKME.HEADER+7 sta ZPChunkCnt @@ -322,8 +323,6 @@ CS.RUN.GetTable >LDA.G PAKME.HEADER+8 lda #0 >PUSHYA - >PUSHEA.G PAKME.TABLE - lda hSrcFile >SYSCALL FRead .9 rts @@ -348,16 +347,16 @@ CS.RUN.GetChunk lda ZPChunkIndex sbc (pData),y sta ZPChunkOfs+1 - >PUSHBI SEEK.SET + >PUSHB hSrcFile >PUSHWZ >PUSHW ZPChunkOfs - lda hSrcFile + >PUSHBI SEEK.SET >SYSCALL FSeek bcs .9 - >PUSHWI 3 + >PUSHB hSrcFile >PUSHEA.G CHUNK.HEADER - lda hSrcFile + >PUSHWI 3 >SYSCALL FRead bcs .9 @@ -375,9 +374,9 @@ CS.RUN.GetChunk lda ZPChunkIndex jsr CS.RUN.GetSrcBufYA bcs .9 - >PUSHW ZPChunkLen + >PUSHB hSrcFile >PUSHW ZPSrcBufPtr - lda hSrcFile + >PUSHW ZPChunkLen >SYSCALL FRead bcs .9 @@ -412,21 +411,21 @@ CS.RUN.Pak >LDYA ZPChunkLen .9 rts *-------------------------------------- CS.RUN.RewriteTable - >PUSHBI SEEK.SET + >PUSHB hDstFile >PUSHWZ >PUSHW ZPDstTableOfs - lda hDstFile + >PUSHBI SEEK.SET >SYSCALL FSeek bcs CS.RUN.WriteTable.RTS *-------------------------------------- CS.RUN.WriteTable + >PUSHB hDstFile + >PUSHEA.G PAKME.TABLE >LDA.G PAKME.HEADER+7 asl tay lda #0 >PUSHYA - >PUSHEA.G PAKME.TABLE - lda hDstFile >SYSCALL FWrite CS.RUN.WriteTable.RTS rts @@ -439,9 +438,9 @@ CS.RUN.WritePak lda hDstFile inc pStack inc pStack - >PUSHW ZPChunkPakedLen + >PUSHB hDstFile >PUSHW ZPDstBufPtr - lda hDstFile + >PUSHW ZPChunkPakedLen >SYSCALL FWrite bcs .9 @@ -464,15 +463,15 @@ CS.RUN.WriteStore inc pStack inc pStack - >PUSHWI 3 + >PUSHB hDstFile >PUSHEA.G CHUNK.HEADER - lda hDstFile + >PUSHWI 3 >SYSCALL FWrite bcs .9 - >PUSHW ZPChunkLen + >PUSHB hDstFile >PUSHW ZPSrcBufPtr - lda hDstFile + >PUSHW ZPChunkLen >SYSCALL FWrite bcs .9 diff --git a/BIN/PPPTEST.S.txt b/BIN/PPPTEST.S.txt index 0f9b3944..21ff78e7 100644 --- a/BIN/PPPTEST.S.txt +++ b/BIN/PPPTEST.S.txt @@ -99,20 +99,20 @@ CS.RUN.TEST >LDYA L.PPP.1 jsr DumpBuf - >PUSHWI PPP.1.LEN + >PUSHB hDev >PUSHW L.PPP.1 - lda hDev - + >PUSHWI PPP.1.LEN >SYSCALL FWrite bcs .9 >SLEEP - >PUSHWI BUFSIZE + >PUSHB hDev >PUSHW ZPBufPtr - lda hDev + >PUSHWI BUFSIZE >SYSCALL FRead bcs .9 + >STYA ZPBufLen >LDYA ZPBufPtr @@ -132,17 +132,23 @@ CS.RUN.LOOP >SLEEP tay bne .1 EOF, no char - >PUSHWI BUFSIZE + >PUSHB hDev >PUSHW ZPBufPtr - lda hDev + >PUSHWI BUFSIZE >SYSCALL FRead bcs CS.RUN.RTS - >PUSHYA len - >PUSHW ZPBufPtr + phy + pha + ldy #S.PS.hStdOut lda (pPS),y + >PUSHA + >PUSHW ZPBufPtr + pla + ply + >PUSHYA len >SYSCALL FWrite bcs .9 @@ -154,10 +160,11 @@ CS.RUN.LOOP >SLEEP tay bne CS.RUN.LOOP EOF = true, no char from STDIN - >PUSHWI BUFSIZE - >PUSHW ZPBufPtr ldy #S.PS.hStdIn lda (pPS),y + >PUSHA + >PUSHW ZPBufPtr + >PUSHWI BUFSIZE >SYSCALL FRead bcs .9 @@ -168,11 +175,16 @@ CS.RUN.LOOP >SLEEP txa - >PUSHYA len + phy + pha + >PUSHB hDev >PUSHW ZPBufPtr - lda hDev + pla + ply + >PUSHYA len >SYSCALL FWrite bcs .9 + jmp CS.RUN.LOOP .9 rts @@ -203,9 +215,9 @@ CS.QUIT lda hDev ATInit lda #250 sta TimeOut - >PUSHWI MSG.AT.LEN + >PUSHB hDev >PUSHW L.MSG.AT - lda hDev + >PUSHWI MSG.AT.LEN >SYSCALL FWrite bcs .9 @@ -223,9 +235,9 @@ ATInit lda #250 rts -.2 >PUSHWI BUFSIZE +.2 >PUSHB hDev >PUSHW ZPBufPtr - lda hDev + >PUSHWI BUFSIZE >SYSCALL FRead bcs .9 diff --git a/BIN/SH.S.CL.txt b/BIN/SH.S.CL.txt index 95177d09..2f560d29 100644 --- a/BIN/SH.S.CL.txt +++ b/BIN/SH.S.CL.txt @@ -8,7 +8,7 @@ CL.Init >LDYAI 256 >STYA ZPCLBuf txa - >STA.G CL.hCLBuf + >STA.G CL.hBuf .9 rts *-------------------------------------- @@ -145,7 +145,10 @@ CL.Insert >LDA.G CL.Len bmi .7 txa + >SYSCALL PutChar + bcs .9 + jsr CL.PrintEOL .7 >LDA.G CL.MaxCnt READ N = 1, don't wait for CR @@ -156,7 +159,7 @@ CL.Insert >LDA.G CL.Len >STA.G CL.bReady .8 clc - rts +.9 rts *-------------------------------------- CL.CHARIN.CTRL cpx #C.CR beq .18 @@ -189,11 +192,12 @@ CL.CLR lda (ZPCLBuf) beq CL.Reset.1 >LDA.G CL.bSilent - bmi CL.Reset.1 + bmi CL.Reset .1 >LDA.G CL.Ptr >CMP.G CL.Len beq .2 + inc >STA.G CL.Ptr lda #C.FS @@ -209,12 +213,13 @@ CL.CLR lda (ZPCLBuf) lda (ZPCLBuf),y bne .3 - jsr CL.PrintCLBuf + jsr CL.Print *-------------------------------------- CL.Reset lda #0 sta (ZPCLBuf) CL.Reset.1 lda #0 + ldy #CL.Ptr .1 sta (pData),y @@ -228,7 +233,9 @@ CL.ReadResetV sec Verbose mode CL.ReadReset lda #$ff >STA.G CL.MaxCnt + adc #0 CC = silent + iny CL.bSilent sta (pData),y rts @@ -322,7 +329,7 @@ CL.PrintEOL >LDA.G CL.Ptr CL.PrintEOL.8 clc rts *-------------------------------------- -CL.PrintCLBuf ldy #S.PS.hStdOut +CL.Print ldy #S.PS.hStdOut lda (pPS),y >PUSHA >PUSHW ZPCLBuf diff --git a/BIN/SH.S.HIS.txt b/BIN/SH.S.HIS.txt index 9cc6c59c..8d1e0351 100644 --- a/BIN/SH.S.HIS.txt +++ b/BIN/SH.S.HIS.txt @@ -9,9 +9,9 @@ HIS.Init >LDYAI HISTORY.MAX Get a buffer for History >STA.G HIS.hBuf - >STZ.G HIS.Count - >STA.G HIS.Index - >STA.G HIS.LRU +* >STZ.G HIS.Count +* >STA.G HIS.Index +* >STA.G HIS.LRU .9 rts *-------------------------------------- HIS.Add >LDA.G HIS.hBuf @@ -22,18 +22,20 @@ HIS.Add >LDA.G HIS.hBuf bcc .2 >LDA.G HIS.LRU - tax - inc cmp #HIS.MAX bne .1 lda #0 -.1 >STA.G HIS.LRU +.1 inc + >STA.G HIS.LRU + tax + >DEBUG bra .7 -.2 tax - >INC.G HIS.Count +.2 inc + >STA.G HIS.Count + tax .7 >PUSHB.G HIS.hBuf >PUSHBI 0 @@ -51,19 +53,24 @@ HIS.Select >LDA.G HIS.Count clc .99 rts -.10 >STZ.G HIS.Index +.10 jsr CL.Reset -.1 jsr HIS.GetIndex + >STZ.G HIS.Index + +.1 >INC.G HIS.Index + jsr HIS.GetIndex bcs .99 >PUSHW L.MSG.HIS - >PUSHB.G HIS.Index + >LDA.G HIS.Index + dec + >PUSHA >PUSHW ZPCLBuf >PUSHBI 3 >SYSCALL PrintF bcs .9 - >INC.G HIS.Index + >LDA.G HIS.Index >CMP.G HIS.Count bne .1 @@ -83,6 +90,8 @@ HIS.Select >LDA.G HIS.Count bcs .7 and #$f + inc + >STA.G HIS.Index .7 >PUSHW L.MSG.HISROMPTCLR @@ -90,49 +99,37 @@ HIS.Select >LDA.G HIS.Count >SYSCALL PrintF jsr CL.PrintPrompt - bcs .9 - - >LDA.G HIS.Index - bne HIS.GetToCL1 - - jmp CL.Reset - -.8 clc - + bcc HIS.GetToCL1 .9 HIS.Select.RTS rts *-------------------------------------- -HIS.GetPrev >LDA.G HIS.hBuf - beq HIS.Select.RTS - - >LDA.G HIS.Count +HIS.GetPrev >LDA.G HIS.Count beq HIS.Select.RTS empty history,nothing to do >LDA.G HIS.Index bne .1 >LDA.G HIS.Count + bra HIS.GetToCL .1 dec bra HIS.GetToCL *-------------------------------------- -HIS.GetNext >LDA.G HIS.hBuf - beq HIS.Select.RTS - - >LDA.G HIS.Count +HIS.GetNext >LDA.G HIS.Count beq HIS.Select.RTS empty history,nothing to do + >EOR.G HIS.Index + beq HIS.GetToCL + >LDA.G HIS.Index inc - >CMP.G HIS.Count - bne HIS.GetToCL - -HIS.Reset >STZ.G HIS.Index - jmp CL.CLR *-------------------------------------- HIS.GetToCL >STA.G HIS.Index -HIS.GetToCL1 jsr CL.CLR + jsr CL.CLR + +HIS.GetToCL1 >LDA.G HIS.Index + beq .9 jsr HIS.GetIndex bcs .9 @@ -147,7 +144,7 @@ HIS.GetToCL1 jsr CL.CLR >STA.G CL.Ptr >STA.G CL.Len - jmp CL.PrintCLBuf + jmp CL.Print .9 rts *-------------------------------------- diff --git a/BIN/SH.S.txt b/BIN/SH.S.txt index 5703eb23..85f0a139 100644 --- a/BIN/SH.S.txt +++ b/BIN/SH.S.txt @@ -264,6 +264,7 @@ CS.RUN.LOOP >SLEEP tay bne CS.RUN.LOOP + >SYSCALL GetChar bcs .9 I/O err @@ -464,7 +465,7 @@ CS.QUIT jsr CORE.FUNCRESET >SYSCALL FreeStkObj -.1 ldy #CL.hCLBuf +.1 ldy #CL.hBuf jsr .7 .2 jsr CMD.POPD @@ -562,7 +563,7 @@ CS.END MSG.GREETINGS .AZ "\r\nA2osX-SH %d.%d\r\n\r\n" MSG.HIS .AZ "\r\n%3d : %s" MSG.HISPROMPT .AZ "\r\n\r\n? " -MSG.HISROMPTCLR .DA #C.BS,#C.BS,0 +MSG.HISROMPTCLR .DA #C.BS,#C.BS,#0 MSG.PROMPT .AZ "\e[?7h$ " Enable Line Wrap MSG.PROMPTCRLF .AZ "\e[?7l\r\n" Disable Line Wrap MSG.TRACE .AS ">" @@ -697,7 +698,7 @@ bSET.X .BS 1 Sleep .BS 4 -CL.hCLBuf .BS 1 +CL.hBuf .BS 1 CL.Ptr .BS 1 CL.Len .BS 1 diff --git a/BIN/TELNET.S.txt b/BIN/TELNET.S.txt index d1bb6d58..76824fb2 100644 --- a/BIN/TELNET.S.txt +++ b/BIN/TELNET.S.txt @@ -192,7 +192,8 @@ CS.RUN.LOOP >SLEEP lda hSocket >LIBCALL hLIBTCPIP,LIBTCPIP.EOF - bcs .99 + bcs .98 + tay bne .2 EOF, no char @@ -200,30 +201,40 @@ CS.RUN.LOOP >SLEEP >PUSHW ZPBufPtr lda hSocket >LIBCALL hLIBTCPIP,LIBTCPIP.Read +.98 bcs .99 -.99 bcs .9 - - >PUSHYA len - >PUSHW ZPBufPtr + pha + phy + ldy #S.PS.hStdOut lda (pPS),y + >PUSHA + >PUSHW ZPBufPtr + + ply + pla + >PUSHYA len >SYSCALL FWrite bcs .11 .2 ldy #S.PS.hStdIn lda (pPS),y - >SYSCALL FEOF bcs .11 CS.RUN.IOERR + tay bne CS.RUN.LOOP EOF = true, no char from STDIN - >PUSHWI BUFSIZE - >PUSHW ZPBufPtr ldy #S.PS.hStdIn lda (pPS),y + >PUSHA + >PUSHW ZPBufPtr + >PUSHWI BUFSIZE >SYSCALL FRead -.11 bcs CS.RUN.IOERR +.11 bcc .3 + + bra CS.RUN.IOERR +.99 bra CS.RUN.SKTERR .3 >STYA ZPBufLen lda (ZPBufPtr) @@ -234,8 +245,8 @@ CS.RUN.LOOP >SLEEP >PUSHW ZPBufPtr lda hSocket >LIBCALL hLIBTCPIP,LIBTCPIP.Write - .9 bcs CS.RUN.SKTERR + jmp CS.RUN.LOOP *-------------------------------------- CS.RUN.SKTERR pha diff --git a/BIN/TERM.S.txt b/BIN/TERM.S.txt index f8d70d6c..2b4aea2c 100644 --- a/BIN/TERM.S.txt +++ b/BIN/TERM.S.txt @@ -85,17 +85,22 @@ CS.RUN.LOOP >SLEEP tay bne .1 EOF, no char - >PUSHWI BUFSIZE + >PUSHB hDev >PUSHW ZPBufPtr - lda hDev + >PUSHWI BUFSIZE >SYSCALL FRead bcs CS.RUN.RTS - >PUSHYA len - >PUSHW ZPBufPtr + pha + phy + ldy #S.PS.hStdOut lda (pPS),y - + >PUSHA + >PUSHW ZPBufPtr + ply + pla + >PUSHYA len >SYSCALL FWrite bcs .9 @@ -107,10 +112,11 @@ CS.RUN.LOOP >SLEEP tay bne CS.RUN.LOOP EOF = true, no char from STDIN - >PUSHWI BUFSIZE - >PUSHW ZPBufPtr ldy #S.PS.hStdIn lda (pPS),y + >PUSHA + >PUSHW ZPBufPtr + >PUSHWI BUFSIZE >SYSCALL FRead bcs .9 @@ -120,11 +126,17 @@ CS.RUN.LOOP >SLEEP beq .8 txa - >PUSHYA len + + pha + phy + >PUSHB hDev >PUSHW ZPBufPtr - lda hDev + ply + pla + >PUSHYA len >SYSCALL FWrite bcs .9 + jmp CS.RUN.LOOP .8 sec diff --git a/BIN/UNPAK.S.txt b/BIN/UNPAK.S.txt index 14d67b96..628ae327 100644 --- a/BIN/UNPAK.S.txt +++ b/BIN/UNPAK.S.txt @@ -243,20 +243,23 @@ CS.RUN.OpenArc >PUSHYA bcs .9 >STA.G hArcFile - pha - >PUSHWI 3 + >PUSHA >PUSHW ZPInBufPtr - pla + >PUSHWI 3 >SYSCALL FRead bcs .9 + cpy #3 bne .99 + dey .1 lda MSG.PAK,y cmp (ZPInBufPtr),y bne .99 + dey bpl .1 + clc .9 rts @@ -269,21 +272,23 @@ CS.RUN.E.IARC >PUSHW L.MSG.E.IARC rts *-------------------------------------- CS.RUN.GetFileType - >PUSHWI 3 + >PUSHB.G hArcFile >PUSHEA.G FileType - >LDA.G hArcFile + >PUSHWI 3 >SYSCALL FRead rts *-------------------------------------- CS.RUN.GetFileName jsr CS.RUN.GetByte bcs .9 - tay - lda #0 - - >PUSHYA + pha + + >PUSHB.G hArcFile >PUSHW ZPRelPathPtr - >LDA.G hArcFile + + ply + lda #0 + >PUSHYA >SYSCALL FRead bcs .9 @@ -293,12 +298,12 @@ CS.RUN.GetFileName * clc .9 rts *-------------------------------------- -CS.RUN.ReadData >PUSHW ZPInBufLen +CS.RUN.ReadData >PUSHB.G hArcFile >LDA.G hInBuf >SYSCALL GetMemPtr >STYA ZPInBufPtr >PUSHYA - >LDA.G hArcFile + >PUSHW ZPInBufLen >SYSCALL FRead rts *-------------------------------------- @@ -339,11 +344,11 @@ CS.RUN.OpenFile >PUSHW ZPFullPathPtr .9 rts *-------------------------------------- CS.RUN.WriteFile - >PUSHW ZPOutBufLen + >PUSHB.G hFile >LDA.G hOutBuf >SYSCALL GetMemPtr >PUSHYA - >LDA.G hFile + >PUSHW ZPOutBufLen >SYSCALL FWrite rts *-------------------------------------- diff --git a/INC/MACROS.I.txt b/INC/MACROS.I.txt index f5c9f1b6..7c44322a 100644 --- a/INC/MACROS.I.txt +++ b/INC/MACROS.I.txt @@ -530,6 +530,14 @@ FPU.FOUT .EQ 210 PrintF >PULLA sta ]1+1 .EM +*-------------------------------------- + .MA PUSHLZ + lda #0 + ldy #3 +:1 >PUSHA + dey + bpl :1 + .EM *-------------------------------------- .MA PUSHL ldy #3 diff --git a/INCLUDE/stdio.h.txt b/INCLUDE/stdio.h.txt index d778cf5a..df56a9d1 100644 --- a/INCLUDE/stdio.h.txt +++ b/INCLUDE/stdio.h.txt @@ -9,21 +9,25 @@ NEW #define O_TEXT 64 #define O_CREATE 128 +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + int fastcall putchar(short int); -// int fputc ( hFILE stream , short int character ); +int fputc (short int, short int); int fastcall puts(const char*); -int fputs (short int, const char*); -char* fgets(short int, char* s, int n); +int fputs (short int,const char*); +char* fgets(short int,char* s,int n); short int getchar(); short int fastcall getc(short int); // short int ungetc(short int c, short int ); short int fopen(const char*,short int,short int,int); int fclose(short int); -// int fread (short int stream, void * ptr, int count ); -// int fwrite (short int stream, const void * ptr, int count ); +int fread (short int,void*,int); +int fwrite (short int,const void*,int); int fastcall fflush(short int); -// int fseek( short int stream, long offset, short int whence ); +int fseek(short int,long,short int); int fastcall feof(short int); long fastcall ftell(short int); int fastcall remove(const char*); diff --git a/INCLUDE/stdlib.h.txt b/INCLUDE/stdlib.h.txt index c3e11a20..9cda86a2 100644 --- a/INCLUDE/stdlib.h.txt +++ b/INCLUDE/stdlib.h.txt @@ -10,11 +10,11 @@ unsigned long strtoul(const char*,char**,int); long fastcall atol(const char*); int fastcall atoi(const char*); -char *realpath(const char*,char*); -char *expand(const char*,char*); +char* realpath(const char*,char*); +char* expand(const char*,char*); int setenv(const char*,const char*); -char *getenv(const char*, char*); +char* getenv(const char*, char*); int putenv(char*); int unsetenv(const char*); diff --git a/INCLUDE/string.h.txt b/INCLUDE/string.h.txt index b5f2ef2c..00cbf093 100644 --- a/INCLUDE/string.h.txt +++ b/INCLUDE/string.h.txt @@ -9,5 +9,6 @@ char* fastcall strupr (char*); char* fastcall strlwr (char*); int strcmp(const char*,const char*); int strcasecmp(const char*,const char *); + MAN TEXT include/string.h diff --git a/INCLUDE/unistd.h.txt b/INCLUDE/unistd.h.txt new file mode 100644 index 00000000..59a1531a --- /dev/null +++ b/INCLUDE/unistd.h.txt @@ -0,0 +1,13 @@ +NEW + AUTO 3,1 + +short int open(const char*, short int); +short int fastcall close(short int) +int read(short int, void*, int); +int write(short int, const void*, int); +// int lseek(short int,long,short int); + +short int chown(const char*, short int, short int);` + +MAN +TEXT include/unistd.h diff --git a/SBIN/GETTY.S.txt b/SBIN/GETTY.S.txt index e02b2f9f..99900e7f 100644 --- a/SBIN/GETTY.S.txt +++ b/SBIN/GETTY.S.txt @@ -131,10 +131,11 @@ CS.RUN.LOOP0 >SLEEP >PUSHW L.ENV.TERM >SYSCALL UnsetEnv -.1 >PUSHWI TELNETOPTS.LEN - >PUSHW L.TELNETOPTS - ldy #S.PS.hStdOut +.1 ldy #S.PS.hStdOut lda (pPS),y + >PUSHA + >PUSHW L.TELNETOPTS + >PUSHWI TELNETOPTS.LEN >SYSCALL FWrite bcs CS.RUN.EXIT I/O error @@ -156,8 +157,10 @@ CS.RUN.LOOP1 >SLEEP cmp #IAC beq CS.RUN.IACMODE + >SYSCALL PutChar bcs CS.RUN.EXIT + bra CS.RUN.LOOP1 .1 lda TimeOut @@ -206,23 +209,29 @@ CS.RUN.IAC.CMD cmp #WILL cpx #TN.O.TTYPE bne .2 - >PUSHWI TELNETOPT.TTYPE.LEN + ldy #S.PS.hStdOut + lda (pPS),y + >PUSHA >PUSHW L.TELNETOPT.TTYPE + >PUSHWI TELNETOPT.TTYPE.LEN bra .7 .2 cpx #TN.O.LINEMODE bne .8 - >PUSHWI TELNETOPT.LMODE.LEN - >PUSHW L.TELNETOPT.LMODE - -.7 ldy #S.PS.hStdOut + ldy #S.PS.hStdOut lda (pPS),y - >SYSCALL FWrite + >PUSHA + >PUSHW L.TELNETOPT.LMODE + >PUSHWI TELNETOPT.LMODE.LEN + +.7 >SYSCALL FWrite + .8 jmp CS.RUN.LOOP1 *-------------------------------------- CS.RUN.IAC.SB >SYSCALL GetChar Wait for IAC SB.IS or SEND bcs .9 + sta IAC.SB.CMD stz IAC.SB.LEN .2 >SYSCALL GetChar diff --git a/SBIN/HTTPD.S.txt b/SBIN/HTTPD.S.txt index c64a0db0..91c4fb6f 100644 --- a/SBIN/HTTPD.S.txt +++ b/SBIN/HTTPD.S.txt @@ -574,9 +574,9 @@ CS.RUN.SendFile >PUSHW ZPRepPtr jsr CS.RUN.SendBuf Y,A = car count -.1 >PUSHWI 1024 +.1 >PUSHB REQ.hFile >PUSHW ZPRepPtr - lda REQ.hFile + >PUSHWI 1024 >SYSCALL FRead bcs .8 diff --git a/SBIN/NETWORKD.S.txt b/SBIN/NETWORKD.S.txt index 5852d8fd..13ac59aa 100644 --- a/SBIN/NETWORKD.S.txt +++ b/SBIN/NETWORKD.S.txt @@ -87,8 +87,8 @@ CS.INIT lda DevID sec rts *-------------------------------------- -CS.INIT.DEV >PUSHBI 0 - >LDYA L.DEVNAME +CS.INIT.DEV >PUSHW L.DEVNAME + >PUSHBI 0 >SYSCALL Open bcc .8 diff --git a/SHARED/X.CPMVRM.S.txt b/SHARED/X.CPMVRM.S.txt index 40d6a844..a7cabeed 100644 --- a/SHARED/X.CPMVRM.S.txt +++ b/SHARED/X.CPMVRM.S.txt @@ -516,7 +516,7 @@ CS.RUN.CopyStart ldy #hSrcFullPath lda #O.RDONLY jsr CS.RUN.Open - bcs CS.RUN.CopyEnd + bcs .9 >STA.G hSrcFile @@ -532,9 +532,9 @@ CS.RUN.CopyStart * clc rts *-------------------------------------- -CS.RUN.Copy >PUSHWI X.COPY.BUF.SIZE Bytes To Read +CS.RUN.Copy >PUSHB.G hSrcFile >PUSHW ZPPtr1 Dst Ptr - >LDA.G hSrcFile + >PUSHWI X.COPY.BUF.SIZE Bytes To Read >SYSCALL FRead bcc .1 @@ -545,9 +545,13 @@ CS.RUN.Copy >PUSHWI X.COPY.BUF.SIZE Bytes To Read clc bra .9 -.1 >PUSHYA Bytes To Write +.1 phy + pha + >PUSHB.G hDstFile >PUSHW ZPPtr1 Src Ptr - >LDA.G hDstFile + pla + ply + >PUSHYA Bytes To Write >SYSCALL FWrite bcs .9 diff --git a/SYS/KERNEL.S.CORE.txt b/SYS/KERNEL.S.CORE.txt index 23e1f7a9..1ea8a324 100644 --- a/SYS/KERNEL.S.CORE.txt +++ b/SYS/KERNEL.S.CORE.txt @@ -87,13 +87,13 @@ CORE.Events jsr CORE.GetEvents >STYA pStack lda #Evt.Table sta pEvent + .1 lda (pEvent) beq .3 - bmi .2 Ignore & Discard any timer event + bpl .3 -* jsr CORE.DumpEvent -.2 jsr CORE.DestroyEvent + jsr CORE.DestroyEvent Discard any timer event .3 lda pEvent clc @@ -366,14 +366,6 @@ CORE.GetPS tay .8 clc rts *-------------------------------------- -*CORE.DumpEvent ldy #S.EVT-1 -*.1 >PUSHB (pEvent),y -* dey -* bpl .1 -* >LDYAI .2 -* jmp K.printf -*.2 .AZ "!Evt:F=%b,Dev=$%h,LO=$%h,HI=$%h,W1=$%H,W2=$%H\n" -*-------------------------------------- CORE.DestroyEvent lda (pEvent) beq .9 diff --git a/SYS/KERNEL.S.DEV.txt b/SYS/KERNEL.S.DEV.txt index be674f47..b59413ac 100644 --- a/SYS/KERNEL.S.DEV.txt +++ b/SYS/KERNEL.S.DEV.txt @@ -108,9 +108,11 @@ K.GetDevStatus >PULLW K.S.IOCTL+S.IOCTL.BUFPTR bcs K.GetDev.9 lda #S.IOCTL.S.GETDIB + .HS 2C BIT ABS *-------------------------------------- -DEV.GetDevStatus - sta K.S.IOCTL+S.IOCTL.S +DEV.EOF lda #S.IOCTL.S.EOF +*-------------------------------------- +DEV.GetStatus sta K.S.IOCTL+S.IOCTL.S ldy #S.FD.DEV.DEVID lda (pFD),y @@ -193,7 +195,7 @@ K.MKDev jsr SHARED.PullP2P1 ptr2=name,tr1=fd jsr DEV.GetPDrv lda #S.IOCTL.S.STATUS - jsr DEV.GetDevStatus + jsr DEV.GetStatus bcs .99 lda K.IOBuf Get Status byte diff --git a/SYS/KERNEL.S.FS.txt b/SYS/KERNEL.S.FS.txt index 73c42dd8..0e97d8ca 100644 --- a/SYS/KERNEL.S.FS.txt +++ b/SYS/KERNEL.S.FS.txt @@ -128,15 +128,18 @@ FS.WRITE.REG ldx #MLIWRITE ldy #S.FD.REG.REF lda (pFD),y sta K.MLI.PARAMS+1 - >PULLW K.MLI.PARAMS+2 >PULLW K.MLI.PARAMS+4 - + >PULLW K.MLI.PARAMS+2 + lda #4 Param Count = 4 for MLIREAD & MLIWRITE jsr GP.MLICall bcs .9 + >LDYA K.MLI.PARAMS+6 -.9 rts +.9 inc pStack + + rts *-------------------------------------- FS.EOF.REG >MLICALL MLIGETMARK bcs .9 diff --git a/SYS/KERNEL.S.INIT.txt b/SYS/KERNEL.S.INIT.txt index 9cd2e9de..e4f652a7 100644 --- a/SYS/KERNEL.S.INIT.txt +++ b/SYS/KERNEL.S.INIT.txt @@ -438,7 +438,6 @@ HW.Detect >PUSHWI MSG.HW >PUSHB A2osX.HWSubT >PUSHBI 2 >SYSCALL2 printf - rts *-------------------------------------- CPU.Init >PUSHWI MSG.CPU diff --git a/SYS/KERNEL.S.PFT.txt b/SYS/KERNEL.S.PFT.txt index 6a49dfa3..3600ec3c 100644 --- a/SYS/KERNEL.S.PFT.txt +++ b/SYS/KERNEL.S.PFT.txt @@ -1,8 +1,6 @@ NEW AUTO 3,1 *-------------------------------------- -PFT.CheckPath0 ldy #0 - .HS 2C BIT ABS PFT.CheckPath1 ldy #1 .HS 2C BIT ABS PFT.CheckPath2 ldy #2 @@ -98,7 +96,7 @@ PFT.CheckNode4 ldy #4 .HS 2C BIT ABS PFT.CheckNode2 ldy #2 - lda (pStack),y +PFT.CheckNodeY lda (pStack),y PFT.CheckNodeA stx .80+1 Save SYSCALL # sta .81+1 Save hFILE diff --git a/SYS/KERNEL.S.PIPE.txt b/SYS/KERNEL.S.PIPE.txt index e0f69419..d7fa5cf8 100644 --- a/SYS/KERNEL.S.PIPE.txt +++ b/SYS/KERNEL.S.PIPE.txt @@ -7,8 +7,9 @@ PIPE.CNT .EQ ZPDRV+4 PIPE.BASEH .EQ ZPDRV+6 PIPE.BUFH .EQ ZPDRV+7 PIPE.SIZEH .EQ ZPDRV+8 +PIPE.nCNT .EQ ZPDRV+10 *-------------------------------------- -IO.OPEN.PIPE ldy #S.FD.PIPE.S +PIPE.OPEN ldy #S.FD.PIPE.S lda (pFD),y inc sta (pFD),y @@ -17,7 +18,7 @@ IO.OPEN.PIPE ldy #S.FD.PIPE.S clc rts *-------------------------------------- -IO.CLOSE.PIPE ldy #S.FD.PIPE.S +PIPE.CLOSE ldy #S.FD.PIPE.S lda (pFD),y bmi .1 remote PS closed its end @@ -34,30 +35,27 @@ IO.CLOSE.PIPE ldy #S.FD.PIPE.S .2 jmp DEV.Destroy *-------------------------------------- -* (pStack)+2 count -* (pStack)+0 buf +* (pStack)+2 buf +* (pStack)+0 count *-------------------------------------- -IO.WRITE.PIPE ldy #S.FD.PIPE.S +PIPE.WRITE ldy #S.FD.PIPE.S lda (pFD),y bpl .10 - jmp IO.READ.PIPE.EOF Remote PS closed the Pipe + jmp PIPE.eEOF Remote PS closed the Pipe .10 ldy #S.FD.PIPE.Free lda (pFD),y - ldy #2 - cmp (pStack),y + cmp (pStack) ldy #S.FD.PIPE.Free+1 lda (pFD),y - ldy #3 + ldy #1 sbc (pStack),y - bcc IO.READ.PIPE.NODATA not enough room in PIPE - - >PULLW PIPE.SRCBUF + bcc PIPE.eNODATA not enough room in PIPE ldy #S.FD.PIPE.Head+1 - jsr PIPE.GET.BUF + jsr PIPE.GetBuf >STYA PIPE.DSTBUF @@ -70,6 +68,9 @@ IO.WRITE.PIPE ldy #S.FD.PIPE.S sta PIPE.CNT+1 eor #$ff pha + + >PULLW PIPE.SRCBUF + ldy #S.FD.PIPE.Head lda (pFD),y tay @@ -118,22 +119,20 @@ IO.WRITE.PIPE ldy #S.FD.PIPE.S lda PIPE.BUFH sta (pFD),y ldy #S.FD.PIPE.Free - jsr PIPE.SUB.CNT + jsr PIPE.SubCnt iny #S.FD.PIPE.Used - jsr PIPE.ADD.CNT - jmp IO.READ.PIPE.EXIT + jsr PIPE.AddCnt + jmp PIPE.EXIT -IO.READ.PIPE.EOF - lda #MLI.E.EOF +PIPE.eEOF lda #MLI.E.EOF .HS 2C BIT ABS -IO.READ.PIPE.NODATA - lda #E.NODATA +PIPE.eNODATA lda #E.NODATA sec - >RET 4 + >RET 5 *-------------------------------------- -IO.READ.PIPE ldy #S.FD.PIPE.Used+1 +PIPE.READ ldy #S.FD.PIPE.Used+1 lda (pFD),y Data ? dey ora (pFD),y @@ -141,13 +140,12 @@ IO.READ.PIPE ldy #S.FD.PIPE.Used+1 ldy #S.FD.PIPE.S lda (pFD),y - bmi IO.READ.PIPE.EOF Remote PS closed the Pipe - bpl IO.READ.PIPE.NODATA - -.10 >PULLW PIPE.DSTBUF get dest buf + bmi PIPE.eEOF Remote PS closed the Pipe - ldy #S.FD.PIPE.Tail+1 - jsr PIPE.GET.BUF + bpl PIPE.eNODATA + +.10 ldy #S.FD.PIPE.Tail+1 + jsr PIPE.GetBuf >STYA PIPE.SRCBUF @@ -177,6 +175,9 @@ IO.READ.PIPE ldy #S.FD.PIPE.Used+1 txa eor #$ff tax + + >PULLW PIPE.DSTBUF get dest buf + ldy #S.FD.PIPE.Tail lda (pFD),y tay @@ -225,17 +226,18 @@ IO.READ.PIPE ldy #S.FD.PIPE.Used+1 lda PIPE.BUFH sta (pFD),y ldy #S.FD.PIPE.Free - jsr PIPE.ADD.CNT + jsr PIPE.AddCnt iny #S.FD.PIPE.Used - jsr PIPE.SUB.CNT -IO.READ.PIPE.EXIT - >LDYA PIPE.CNT Y,A = bytes written + jsr PIPE.SubCnt + +PIPE.EXIT >LDYA PIPE.CNT Y,A = bytes written + inc pStack clc rts *-------------------------------------- -PIPE.GET.BUF lda (pFD),y +PIPE.GetBuf lda (pFD),y sta PIPE.BUFH ldy #S.FD.PIPE.Size+1 @@ -252,7 +254,7 @@ PIPE.GET.BUF lda (pFD),y adc PIPE.BUFH rts *-------------------------------------- -PIPE.ADD.CNT clc +PIPE.AddCnt clc lda (pFD),y adc PIPE.CNT sta (pFD),y @@ -264,7 +266,7 @@ PIPE.ADD.CNT clc sta (pFD),y rts *-------------------------------------- -PIPE.SUB.CNT sec +PIPE.SubCnt sec lda (pFD),y sbc PIPE.CNT sta (pFD),y @@ -276,7 +278,7 @@ PIPE.SUB.CNT sec sta (pFD),y rts *-------------------------------------- -IO.EOF.PIPE clc +PIPE.EOF clc ldy #S.FD.PIPE.Used lda (pFD),y iny diff --git a/SYS/KERNEL.S.PS.txt b/SYS/KERNEL.S.PS.txt index 56324456..6b9a645d 100644 --- a/SYS/KERNEL.S.PS.txt +++ b/SYS/KERNEL.S.PS.txt @@ -513,16 +513,19 @@ PS.LoadGetHeader sta .1+1 - >PUSHWI 128 + >PUSHA >PUSHWI K.IOBuf+128 -.1 lda #$ff SELF MODIFIED + >PUSHWI 128 + >SYSCALL2 fread + php pha - lda .1+1 +.1 lda #$FF SELF MODIFIED >SYSCALL2 fclose pla plp + .9 rts *-------------------------------------- PS.Load.ROOT .AZ "ROOT" @@ -823,10 +826,10 @@ K.LoadFile clc >STYA PS.MemPtr stx PS.hMem - >PUSHWI $ffff + >PUSHB PS.hFILE >PUSHW PS.MemPtr - lda PS.hFILE - >SYSCALL2 FRead + >PUSHWI $ffff + >SYSCALL2 fread bcs .96 sty .7+1 diff --git a/SYS/KERNEL.S.PWD.txt b/SYS/KERNEL.S.PWD.txt index ae48bf37..70fce7fa 100644 --- a/SYS/KERNEL.S.PWD.txt +++ b/SYS/KERNEL.S.PWD.txt @@ -149,11 +149,11 @@ PWD.Flush >STYA PWD.FileSize .1 sta .7+1 - >PUSHW PWD.FileSize + >PUSHA lda .8+1 jsr K.getmemptr >PUSHYA - lda .7+1 + >PUSHW PWD.FileSize >SYSCALL2 FWrite bcc .7 diff --git a/SYS/KERNEL.S.STDIO.txt b/SYS/KERNEL.S.STDIO.txt index 7134a1f4..0d333b12 100644 --- a/SYS/KERNEL.S.STDIO.txt +++ b/SYS/KERNEL.S.STDIO.txt @@ -1,6 +1,35 @@ NEW AUTO 3,1 */-------------------------------------- +* # fputc (BLOCKING) +* Print A (char) to hFILE +* ## C +* `int fputc ( hFILE stream , short int character );` +* ## ASM +* **In:** +* `>PUSHB stream` +* `>PUSHB character` +* `>SYSCALL fputc` +* ## RETURN VALUE +* CC = success +*\-------------------------------------- +K.FPutC lda (pStack) character + sta K.IOBuf + + ldy #1 + lda (pStack),y hFile + >PUSHA + + jsr STDIO.Put1 + bcc .8 + + tay + beq .9 BLOCKING, keep parms on stack + +.8 >POP 2 + +.9 rts +*/-------------------------------------- * # putchar (BLOCKING) * Print A (char) to StdOut * ## C @@ -12,56 +41,28 @@ NEW * ## RETURN VALUE * CC = success *\-------------------------------------- -K.PutChar >PUSHA character +K.PutChar sta K.IOBuf character ldy #S.PS.hStdOut lda (pPS),y - jsr K.FPutC - bcc .8 - - tay - bne .8 - - >PULLA CS,A=0:BLOCKING, restore A - -.8 rts -*/-------------------------------------- -* # fputc (BLOCKING) -* Print A (char) to hFILE -* ## C -* `int fputc ( hFILE stream , short int character );` -* ## ASM -* **In:** -* `>PUSHB character` -* `lda stream` -* `>SYSCALL fputc` -* ## RETURN VALUE -* CC = success -*\-------------------------------------- -K.FPutC jsr PFT.CheckNodeA - bcs .8 - - lda (pStack) character - sta K.IOBuf + >PUSHA +*-------------------------------------- +STDIO.Put1 >PUSHWI K.IOBuf buf lda #0 >PUSHA inc write 1 byte >PUSHA - >PUSHWI K.IOBuf buf - jsr IO.Write - bcc .8 pop char... + jsr K.FWrite + bcc .9 - cmp #E.NODATA - sec - bne .8 + tay + bne .9 - inc CS,A=0:BLOCKING - rts + >POP 5 -.8 >POP 1 - rts +.9 rts */-------------------------------------- * # puts (BLOCKING) * Write Str to StdOut, appends '\r\n' @@ -76,13 +77,13 @@ K.FPutC jsr PFT.CheckNodeA *\-------------------------------------- K.PutS >STYA .1+1 - ldy #0 + ldx #0 -.1 lda $FFFF,y SELF MODIFIED +.1 lda $FFFF,x SELF MODIFIED beq .2 - sta K.IOBuf,y - iny + sta K.IOBuf,x + inx bne .1 .9 lda #E.BUF @@ -90,33 +91,32 @@ K.PutS >STYA .1+1 rts .2 lda #C.CR - sta K.IOBuf,y - iny + sta K.IOBuf,x + inx beq .9 lda #C.LF - sta K.IOBuf,y - iny + sta K.IOBuf,x + inx beq .9 - lda #0 - sta K.IOBuf,y - ldy #S.PS.hStdOut lda (pPS),y >PUSHA >PUSHWI K.IOBuf + >PUSHBI 0 + txa + >PUSHA - jsr K.FPutS + jsr K.FWrite + bcc .99 - bcc K.PutS.RTS tay - bne K.PutS.RTS + bne .99 - >LDYA .1+1 CS,A=0:BLOCKING, restore Y,A + >POP 5 pop hFile, buffer & len -K.PutS.RET3 >POP 3 pop StdOut & buffer -K.PutS.RTS rts +.99 rts */-------------------------------------- * # fputs (BLOCKING) * Write Str to hFILE @@ -130,42 +130,52 @@ K.PutS.RTS rts * ## RETURN VALUE * CC = success *\-------------------------------------- -K.FPutS jsr PFT.CheckNode2 set IO.hFD - bcs K.PutS.RET3 - - lda (pStack) - sta ZPPtr2 Get String +K.FPutS lda (pStack) + sta ZPPtr1 Get String + sta ZPPtr2 + ldy #1 lda (pStack),y + sta ZPPtr1+1 sta ZPPtr2+1 - + ldy #0 ldx #0 -.1 lda (ZPPtr2),y +.1 lda (ZPPtr1),y beq .2 iny bne .1 inx + inc ZPPtr1+1 bra .1 -.2 txa - >PUSHA push len HI +.2 phy - tya - >PUSHA push len LO + ldy #2 + lda (pStack),y + >PUSHA >PUSHW ZPPtr2 - jsr IO.Write - bcc K.PutS.RET3 - cmp #E.NODATA - sec - bne K.PutS.RET3 IO Error + txa + >PUSHA push len HI - inc FF-> 0 = BLOCKING + pla + >PUSHA push len LO + + jsr K.Write + bcc .8 + + tay + bne .8 + + >POP 5 + rts + +.8 >POP 2 K.FPutS.RTS rts */-------------------------------------- @@ -190,10 +200,7 @@ K.FPutS.RTS rts * (pStack)+2 s -> ZPPtr2 * (pStack)+0 n -> ZPPtr1 *-------------------------------------- -K.FGetS jsr PFT.CheckNode4 - bcs K.FPutS.RTS - - ldy #3 +K.FGetS ldy #3 .1 lda (pStack),y sta ZPPtr1,y @@ -203,18 +210,13 @@ K.FGetS jsr PFT.CheckNode4 lda ZPPtr1+1 bmi .4 already something in buffer -.2 jsr STDIO.Get.1 - bcc .3 +.2 ldy #4 + lda (pStack),y + jsr STDIO.Get1 + bcs .9 - cmp #MLI.E.EOF - beq .9 - - cmp #E.NODATA - sec - bne .9 IO error - - lda #0 BLOCKING - rts +* BLOCKING > POP 5 FREAD parms +* EOF or IOERR.... > POP 5 FGETS parms .3 lda K.IOBuf cmp #C.LF Discard any leading LF from a prev CR/LF @@ -233,7 +235,9 @@ K.FGetS jsr PFT.CheckNode4 bra .5 *-------------------------------------- -.4 jsr STDIO.Get.1 +.4 ldy #4 + lda (pStack),y + jsr STDIO.Get1 bcs .6 .5 lda K.IOBuf @@ -249,12 +253,15 @@ K.FGetS jsr PFT.CheckNode4 beq .8 Buffer full -.6 cmp #MLI.E.EOF +.6 tay + beq .70 + + cmp #MLI.E.EOF beq .8 String terminated by EOF - cmp #E.NODATA - sec - bne .9 I/O error + bra .9 I/O error > POP 5 FGETS parms + +.70 jsr .9 > POP 5 FREAD parms ldy #3 @@ -298,29 +305,27 @@ K.GetChar ldy #S.PS.hStdIn * CC = success * A = char *\-------------------------------------- -K.GetC jsr PFT.CheckNodeA - bcs .9 - - jsr STDIO.Get.1 +K.GetC jsr STDIO.Get1 bcc .8 - cmp #E.NODATA - sec + tay bne .9 I/O error - inc 0 = BLOCKING + >POP 5 BLOCKING rts .8 lda K.IOBuf .9 rts *-------------------------------------- -STDIO.Get.1 lda #0 +STDIO.Get1 >PUSHA + + >PUSHWI K.IOBuf + lda #0 >PUSHA inc read 1 byte >PUSHA - >PUSHWI K.IOBuf - jmp IO.Read + jmp K.FRead */-------------------------------------- * # ungetc * push byte back into input stream @@ -402,17 +407,17 @@ K.FClose jsr PFT.CheckNodeA * `int fread (short int stream, void * ptr, int count );` * ## ASM * **In:** -* `>PUSHWI count` +* `>PUSHB stream` * `>PUSHW ptr` -* `lda stream` +* `>PUSHW count` * `>SYSCALL fread` * ## RETURN VALUE * Y,A = Bytes Read *\-------------------------------------- -K.FRead jsr PFT.CheckNodeA - bcs K.FWrite.RET4 +K.FRead jsr PFT.CheckNode4 + bcs K.FWrite.RET5 - jsr IO.Read + jsr UNISTD.Read bcs K.FWrite.9 K.FRead.RTS rts @@ -423,32 +428,33 @@ K.FRead.RTS rts * `int fwrite ( short int stream, const void * ptr, int count );` * ## ASM * **In:** -* `>PUSHWI count` +* `>PUSHB stream` * `>PUSHW ptr` -* `lda stream` +* `>PUSHW count` * `>SYSCALL fwrite` * ## RETURN VALUE * Y,A = Bytes Written *\-------------------------------------- -K.FWrite jsr PFT.CheckNodeA - bcs K.FWrite.RET4 +K.FWrite jsr PFT.CheckNode4 + bcs K.FWrite.RET5 - jsr IO.Write - bcc K.FWrite.RTS + jsr UNISTD.Write + bcc K.FRead.RTS K.FWrite.9 cmp #E.NODATA sec - bne K.FWrite.RTS IO Error + bne K.FRead.RTS IO Error dec pStack FF = NODATA dec pStack dec pStack - dec pStack keep ptr & count on stack + dec pStack + dec pStack keep stream, ptr & count on stack inc 0 = BLOCKING * sec -K.FWrite.RTS rts + rts -K.FWrite.RET4 >RET 4 +K.FWrite.RET5 >RET 5 */-------------------------------------- * # FFlush * ## C @@ -476,25 +482,30 @@ STDIO.IOERR lda #MLI.E.IO * `int fseek( short int stream, long offset, short int whence );` * ## ASM * **In:** -* `>PUSHBI whence` +* `>PUSHB stream` * `>PUSHL offset` -* `lda stream` +* `>PUSHB whence` * `>SYSCALL fseek` *\------------------------------------- -K.FSeek jsr PFT.CheckNodeA +K.FSeek ldy #5 + jsr PFT.CheckNodeY bcc .11 >RET 5 .11 lda (pFD) bne STDIO.IOERR - >PULLL ACC32 + >PULLA whence - cmp #SEEK.END + tax + + >PULLL ACC32 + cpx #SEEK.END beq .30 + bcs .98 - dec + dex beq .20 stz K.MLI.PARAMS+2 @@ -557,17 +568,17 @@ K.FSeek.RTS rts K.FEOF jsr PFT.CheckNodeA bcs K.FSeek.RTS -IO.EOF lda (pFD) + lda (pFD) tax jmp (.1,x) .1 .DA FS.EOF.REG .DA STDIO.IOERR DIR - .DA IO.EOF.CDEV + .DA DEV.EOF .DA STDIO.IOERR BDEV .DA STDIO.IOERR LNK .DA STDIO.IOERR DSOCK .DA IO.EOF.SSOCK - .DA IO.EOF.PIPE + .DA PIPE.EOF */-------------------------------------- * # FTell * Return the current value of the file-position indicator @@ -831,20 +842,19 @@ K.PrintF.1 sec format string->ptr2 sec jmp STDIO.Exit *-------------------------------------- -.8 ldx PrintF.hFILE +.8 lda PrintF.hFILE beq .80 Writing to buffer, append \0 - >PUSHW PrintF.Cnt Writing to File/dev... + >PUSHA >PUSHWI K.IOBuf - - txa + >PUSHW PrintF.Cnt Writing to File/dev... jsr K.FWrite bcc .81 tay bne .9 - >RET 4 0=BLOCKING + >RET 5 0=BLOCKING .80 ldy PrintF.Cnt A=0, Writing to buffer, append \0 sta (pIOBuf),y @@ -1070,6 +1080,7 @@ PrintF.PutC phy ply inc PrintF.Cnt bne .8 + lda PrintF.hFILE bne .9 diff --git a/SYS/KERNEL.S.STRVX.txt b/SYS/KERNEL.S.STRVX.txt index c7882aa3..de89d7a8 100644 --- a/SYS/KERNEL.S.STRVX.txt +++ b/SYS/KERNEL.S.STRVX.txt @@ -182,7 +182,7 @@ STRVX.GetID jsr K.GetMemPtr rts *-------------------------------------- STRVX.Next lda (ZPPtr1) - sec + clc adc ZPPtr1 sta ZPPtr1 bcc .8 diff --git a/SYS/KERNEL.S.UNISTD.txt b/SYS/KERNEL.S.UNISTD.txt index d8ba4ace..a7bfec0b 100644 --- a/SYS/KERNEL.S.UNISTD.txt +++ b/SYS/KERNEL.S.UNISTD.txt @@ -6,14 +6,14 @@ NEW * `hFD open(const char *pathname, short int flags);` * ## ASM * **In:** +* `>PUSHW pathname` * `>PUSHB flags` -* `>LDYA pathname` * `>SYSCALL open` * ## RETURN VALUE * A = hFD * REG File created on ProDOS : T=TXT,X=$0000 *\-------------------------------------- -K.Open jsr PFT.YAToMLIPATH +K.Open jsr PFT.CheckPath1 >PULLB IO.Open.FLAGS lda #S.FI.T.TXT @@ -52,7 +52,7 @@ IO.Open ldx #5 /dev/ .DA STDIO.IOERR LNK .DA IO.OPEN.SOCK .DA IO.OPEN.SOCK - .DA IO.OPEN.PIPE + .DA PIPE.OPEN .8 jmp FS.OPEN.REG @@ -78,24 +78,27 @@ IO.Close lda (pFD) #S.FD.T .DA STDIO.IOERR LNK .DA IO.CLOSE.SOCK .DA IO.CLOSE.SOCK - .DA IO.CLOSE.PIPE + .DA PIPE.CLOSE */-------------------------------------- * # read * ## C * `int read(hFD fd, void *buf, int count);` * ## ASM * **In:** -* `>PUSHWI count` +* `>PUSHB fd` * `>PUSHW buf` -* `lda fd` +* `>PUSHW count` * `>SYSCALL read` * ## RETURN VALUE * CC: Y,A = bytes read * CS: A = EC *\-------------------------------------- -K.Read jsr DEV.GetPFD +K.Read ldy #4 hDev + lda (pStack),y + + jsr DEV.GetPFD -IO.Read lda (pFD) #S.FD.T +UNISTD.Read lda (pFD) #S.FD.T tax jmp (.1,x) .1 .DA FS.READ.REG @@ -105,24 +108,27 @@ IO.Read lda (pFD) #S.FD.T .DA STDIO.IOERR LNK .DA STDIO.IOERR DSOCK .DA IO.READ.SSOCK - .DA IO.READ.PIPE + .DA PIPE.READ */-------------------------------------- * # write * ## C * `int write(hFD fd, const void *buf, int count);` * ## ASM * **In:** -* `>PUSHWI count` +* `>PUSHB fd` * `>PUSHW buf` -* `lda fd` +* `>PUSHW count` * `>SYSCALL write` * ## RETURN VALUE * CC: Y,A = bytes written * CS: A = EC *\-------------------------------------- -K.Write jsr DEV.GetPFD +K.Write ldy #4 hDev + lda (pStack),y + + jsr DEV.GetPFD -IO.Write lda (pFD) #S.FD.T +UNISTD.Write lda (pFD) #S.FD.T tax jmp (.1,x) .1 .DA FS.WRITE.REG @@ -132,7 +138,7 @@ IO.Write lda (pFD) #S.FD.T .DA STDIO.IOERR LNK .DA STDIO.IOERR DSOCK .DA IO.WRITE.SSOCK - .DA IO.WRITE.PIPE + .DA PIPE.WRITE *-------------------------------------- IO.OPEN.DEV ldx #IOCTL.OPEN lda IO.hDevNod @@ -141,7 +147,8 @@ IO.OPEN.DEV ldx #IOCTL.OPEN *-------------------------------------- IO.OPEN.SOCK lda IO.hDevNod clc - rts + +IO.RTS rts *-------------------------------------- IO.CLOSE.DEV ldx #IOCTL.CLOSE lda IO.hDevNod @@ -152,16 +159,18 @@ IO.READ.CDEV ldx #IOCTL.READ *-------------------------------------- IO.WRITE.CDEV ldx #IOCTL.WRITE - >PULLW K.S.IOCTL+S.IOCTL.BUFPTR >PULLW K.S.IOCTL+S.IOCTL.BYTECNT + >PULLW K.S.IOCTL+S.IOCTL.BUFPTR + inc pStack pop hFD + >LDYAI K.S.IOCTL jsr DEV.pDrvJmp - bcs IO.RTS + bcs .9 >LDYA K.S.IOCTL+S.IOCTL.BYTECNT -IO.RTS rts +.9 rts *-------------------------------------- IO.CLOSE.SOCK ldy #S.FD.SSOCK.CLOSE .HS 2C BIT ABS @@ -183,9 +192,20 @@ IO.WRITE.SSOCK ldy #S.FD.SSOCK.WRITE >STYA .1+1 lda IO.hFD .1 jmp $FFFF SELF MODIFIED -*-------------------------------------- -IO.EOF.CDEV lda #S.IOCTL.S.EOF - jmp DEV.GetDevStatus +*/------------------------------------- +* # LSeek +* Set the file-position indicator for hFD +* ## C +* `int lseek( short int hFD, long offset, short int whence );` +* ## ASM +* **In:** +* `>PUSHB hFD` +* `>PUSHL offset` +* `>PUSHB whence` +* `>SYSCALL fseek` +*\------------------------------------- +K.LSeek + */-------------------------------------- * # ChOwn * ## C