mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 20:33:13 +00:00
Kernel 0.9.2
This commit is contained in:
parent
44ca048591
commit
66f6298626
@ -240,7 +240,7 @@ Change The type of a ProDOS File
|
||||
# open
|
||||
|
||||
## C
|
||||
`hFD open(const char *pathname, int flags);`
|
||||
`hFD open(const char *pathname, short int flags);`
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
@ -249,7 +249,7 @@ Change The type of a ProDOS File
|
||||
`>SYSCALL open`
|
||||
**Out:**
|
||||
A = hFD
|
||||
note : if file is created on ProDOS : T=TXT,X=$0000
|
||||
REG File created on ProDOS : T=TXT,X=$0000
|
||||
|
||||
# close
|
||||
|
||||
@ -604,20 +604,22 @@ Print A (char) to hFILE
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
A : character
|
||||
Y : stream
|
||||
`>PUSHB character`
|
||||
`lda stream`
|
||||
`>SYSCALL fputc`
|
||||
**Out:**
|
||||
CC = success
|
||||
|
||||
# PutChar
|
||||
Print A (char) to StdOut
|
||||
|
||||
## C
|
||||
`int putchar ( int character );`
|
||||
|
||||
## ASM
|
||||
Print A (char) to StdOut
|
||||
**In:**
|
||||
A : char to print
|
||||
`lda caracter`
|
||||
`>SYSCALL putchar`
|
||||
**Out:**
|
||||
CC = success
|
||||
|
||||
@ -793,20 +795,20 @@ A = Number of arguments filled.
|
||||
Open a file
|
||||
|
||||
## C
|
||||
`hFILE fopen ( const char * filename, short int mode, short int ftype, int auxtype );`
|
||||
`hFILE fopen ( const char * filename, short int flags, short int ftype, int auxtype );`
|
||||
**In:**
|
||||
|
||||
## ASM
|
||||
`>PUSHWI auxtype`
|
||||
`>PUSHBI ftype`
|
||||
`>PUSHBI mode`
|
||||
`>PUSHBI flags`
|
||||
+ O.RDONLY : if R and exists -> ERROR
|
||||
+ O.WRONLY : if W and exists -> CREATE
|
||||
+ O.TRUNC : Reset Size To 0
|
||||
+ O.APPEND : Append
|
||||
+ O.TEXT : Open/Append in Text mode
|
||||
+ O.CREATE : Create if not exists
|
||||
TODO: mode="w+,t=TYP,x=AUXTYPE"
|
||||
TODO: replace flags/ftype/auxtype with mode="w+,t=TYP,x=AUXTYPE"
|
||||
+ r = O_RDONLY
|
||||
+ r+ = O_RDWR
|
||||
+ w = O_WRONLY | O_CREAT | O_TRUNC
|
||||
@ -833,8 +835,12 @@ int fclose ( hFILE stream );
|
||||
**Out:**
|
||||
|
||||
# FRead
|
||||
int fread (hFILE stream, void * ptr, int count );
|
||||
Read bytes from file
|
||||
|
||||
## C
|
||||
int fread (hFILE stream, void * ptr, int count );
|
||||
|
||||
## ASM
|
||||
**In:**
|
||||
`>PUSHWI count`
|
||||
`>PUSHW ptr`
|
||||
@ -938,10 +944,10 @@ Rename a file
|
||||
# strtof
|
||||
Convert String to 40 bits Float
|
||||
|
||||
##C
|
||||
## C
|
||||
`float strtof (const char* str, char** endptr);`
|
||||
|
||||
##ASM
|
||||
## ASM
|
||||
**In:**
|
||||
`>PUSHWI EndPtr`
|
||||
`>LDYA str`
|
||||
@ -1132,7 +1138,7 @@ Get System Time in Buffer
|
||||
## C
|
||||
`time_t time (S.TIME* timer);`
|
||||
|
||||
##ASM
|
||||
## ASM
|
||||
**In:**
|
||||
Y,A = PTR to S.TIME
|
||||
**Out:**
|
||||
@ -1144,7 +1150,7 @@ S.TIME filled with System date/time
|
||||
## C
|
||||
`int PTime2Time (long* ptime, S.TIME* timer);`
|
||||
|
||||
##ASM
|
||||
## ASM
|
||||
**In :**
|
||||
`>PUSHW timer`
|
||||
`>LDYA ptime`
|
||||
@ -1157,7 +1163,7 @@ S.TIME filled with System date/time
|
||||
## C
|
||||
`int CTime2Time (long* ctime, S.TIME* timer);`
|
||||
|
||||
##ASM
|
||||
## ASM
|
||||
**In :**
|
||||
`>PUSHW timer`
|
||||
`>LDYA ctime`
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -105,11 +105,11 @@ SEEK.END .EQ $04
|
||||
*--------------------------------------
|
||||
* .EQ $00
|
||||
* .EQ $02
|
||||
SYS.Stat .EQ $04
|
||||
SYS.MKDir .EQ $06
|
||||
SYS.MKNod .EQ $08
|
||||
SYS.MKFIFO .EQ $0A
|
||||
SYS.FStat .EQ $0C
|
||||
SYS.FStat .EQ $04
|
||||
SYS.Stat .EQ $06
|
||||
SYS.MKDir .EQ $08
|
||||
SYS.MKNod .EQ $0A
|
||||
SYS.MKFIFO .EQ $0C
|
||||
* .EQ $0E
|
||||
|
||||
SYS.OpenDir .EQ $10
|
||||
|
@ -13,23 +13,33 @@ A2osX.D1.S .EQ A2osX.D2-A2osX.D1
|
||||
A2osX.D2.S .EQ A2osX.E0-A2osX.D2
|
||||
A2osX.E0.S .EQ A2osX.E0.E-A2osX.E0
|
||||
*--------------------------------------
|
||||
.LIST OFF
|
||||
.DO A2osX.MAIN.S>$700
|
||||
.LIST ON
|
||||
* ERROR:MAIN too big
|
||||
.LIST OFF
|
||||
.FIN
|
||||
.DO A2osX.AUX.S>$C00
|
||||
.LIST ON
|
||||
* ERROR:AUX too big
|
||||
.LIST OFF
|
||||
.FIN
|
||||
.DO A2osX.GP.SC>$1E0
|
||||
.LIST ON
|
||||
* ERROR:GP too big
|
||||
.LIST OFF
|
||||
.FIN
|
||||
.DO A2osX.D1.S>$1000
|
||||
.LIST ON
|
||||
* ERROR:BNK1 too big
|
||||
.LIST OFF
|
||||
.FIN
|
||||
.DO A2osX.D2.S>$1000
|
||||
.LIST ON
|
||||
* ERROR:BNK2 too big
|
||||
.LIST OFF
|
||||
.FIN
|
||||
*--------------------------------------
|
||||
.LIST OFF
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.CTRL
|
||||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||||
|
@ -133,7 +133,7 @@ Kernel.Init3 sta SETALTZP
|
||||
|
||||
ldy #S.PS.hPREFIX
|
||||
lda (pPs),y
|
||||
>SYSCALL GetMemPtr
|
||||
jsr K.GetMemPtr
|
||||
|
||||
>PUSHYA
|
||||
|
||||
@ -166,7 +166,7 @@ Kernel.Init3 sta SETALTZP
|
||||
|
||||
bcs .9
|
||||
pla
|
||||
>SYSCALL FreeMem ...discard...
|
||||
jsr K.FreeMem ...discard...
|
||||
|
||||
>LDYAI MSG.Init3.OK
|
||||
>SYSCALL puts
|
||||
@ -914,7 +914,7 @@ TskMgrInit >LDYAI MSG.TSK
|
||||
>SYSCALL puts
|
||||
|
||||
>LDYAI K.ENV.SIZE get a buffer for ENV
|
||||
>SYSCALL GetMem0 make sure blank!!
|
||||
jsr K.GetMem0 make sure blank!!
|
||||
bcs .9
|
||||
|
||||
txa
|
||||
|
@ -4,7 +4,7 @@ AUTO 4,1
|
||||
*/--------------------------------------
|
||||
* # open
|
||||
* ## C
|
||||
* `hFD open(const char *pathname, int flags);`
|
||||
* `hFD open(const char *pathname, short int flags);`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHB flags`
|
||||
@ -12,32 +12,149 @@ AUTO 4,1
|
||||
* `>SYSCALL open`
|
||||
* **Out:**
|
||||
* A = hFD
|
||||
* note : if file is created on ProDOS : T=TXT,X=$0000
|
||||
* REG File created on ProDOS : T=TXT,X=$0000
|
||||
*\--------------------------------------
|
||||
K.Open jsr PFT.CheckPathYA check if not /mnt
|
||||
|
||||
K.Open.I jsr STDIO.SetMLIPathYA local pathname...
|
||||
>PULLB K.FOpen.MODE
|
||||
K.Open.FLAGS .BS 1
|
||||
K.Open.TYPE .BS 1
|
||||
K.Open.AUXTYPE .BS 2
|
||||
*--------------------------------------
|
||||
K.Open pha
|
||||
>PULLB K.Open.FLAGS
|
||||
pla
|
||||
|
||||
IO.Open.I jsr STDIO.SetMLIPathYA
|
||||
|
||||
lda #S.FI.T.TXT
|
||||
sta K.Open.TYPE
|
||||
stz K.Open.AUXTYPE
|
||||
stz K.Open.AUXTYPE+1
|
||||
|
||||
ldx #5 $/DEV/
|
||||
cpx K.MLI.PATH
|
||||
bcs K.Open.REG
|
||||
bcs .2
|
||||
|
||||
.1 lda K.MLI.PATH,x
|
||||
cmp IO.DEVDIR,x
|
||||
bne K.Open.REG
|
||||
bne .2
|
||||
dex
|
||||
bne .1
|
||||
*--------------------------------------
|
||||
K.Open.DEV >LDYAI K.MLI.PATH+6 skip $/DEV/
|
||||
* CDEV,BDEV,DSOCK,SSOCK,PIPE
|
||||
*--------------------------------------
|
||||
.2 >LDYAI K.MLI.PATH+6 skip $/DEV/
|
||||
|
||||
jsr K.GetDevByName
|
||||
bcs .9
|
||||
bcs IO.OPEN.RTS
|
||||
|
||||
>STYA pFD
|
||||
stx .1+1 DEVID
|
||||
|
||||
jsr K.IOCTL.GetPDrv
|
||||
lda (pFD) #S.FD.T
|
||||
tax
|
||||
jmp (.3,x)
|
||||
|
||||
.3 .DA STDIO.IOERR REG
|
||||
.DA STDIO.IOERR DIR
|
||||
.DA IO.OPEN.CDEV
|
||||
.DA STDIO.IOERR BDEV
|
||||
.DA STDIO.IOERR LNK
|
||||
.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 K.IO.OPEN.REG.E Already Exists
|
||||
|
||||
bit K.Open.FLAGS Create if not exists ?
|
||||
bpl IO.OPEN.9 No, return MLI error
|
||||
|
||||
lda #S.FI.A.FULL Yes, Create...
|
||||
sta K.MLI.PARAMS+3 Access
|
||||
lda K.Open.TYPE
|
||||
sta K.MLI.PARAMS+4 File type
|
||||
>LDYA K.Open.AUXTYPE
|
||||
>STYA K.MLI.PARAMS+5 Aux type
|
||||
lda #S.FI.ST.STD
|
||||
sta K.MLI.PARAMS+7
|
||||
|
||||
ldx #3
|
||||
|
||||
.1 lda DATELO,x
|
||||
sta K.MLI.PARAMS+8,x
|
||||
dex
|
||||
bpl .1
|
||||
|
||||
>MLICALL MLICREATE
|
||||
bcs IO.OPEN.RTS
|
||||
|
||||
K.IO.OPEN.REG.E >LDYAI S.FD.REG
|
||||
ldx #S.MEM.F.INIT0+S.MEM.F.FD
|
||||
jsr MEM.GetMem.YAX
|
||||
bcs IO.OPEN.RTS
|
||||
|
||||
>STYA pFD
|
||||
stx .8+1 save hFD
|
||||
|
||||
* ldy #S.FD.T Done by GetMem0
|
||||
* lda #S.FD.T.REG
|
||||
* sta (pFD),y
|
||||
|
||||
jsr STDIO.SetIOBUF
|
||||
bcs .9
|
||||
|
||||
>MLICALL MLIOPEN
|
||||
bcs .9
|
||||
|
||||
lda K.MLI.PARAMS+5 get ref_num
|
||||
ldy #S.FD.REG.REF
|
||||
sta (pFD),y
|
||||
|
||||
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
|
||||
|
||||
lda K.Open.FLAGS
|
||||
bit #O.WRONLY
|
||||
beq .20 Write mode ?
|
||||
|
||||
and #O.APPEND Append ?
|
||||
bne .11 yes, go to end of file
|
||||
|
||||
stz K.MLI.PARAMS+2
|
||||
stz K.MLI.PARAMS+3
|
||||
stz K.MLI.PARAMS+4
|
||||
>MLICALL MLISETEOF no, reset size to 0
|
||||
bra .21
|
||||
|
||||
.11 >MLICALL MLIGETEOF
|
||||
bcs .9
|
||||
|
||||
>MLICALL MLISETMARK
|
||||
.21 bcs .9
|
||||
|
||||
.20 lda K.Open.FLAGS
|
||||
and #O.TEXT Text Mode ?
|
||||
beq .8
|
||||
|
||||
lda #$FF
|
||||
sta K.MLI.PARAMS+2
|
||||
lda #C.CR
|
||||
sta K.MLI.PARAMS+3
|
||||
>MLICALL MLINEWLINE
|
||||
bcs .9
|
||||
|
||||
.8 lda #$ff
|
||||
rts
|
||||
|
||||
.9 pha
|
||||
lda .8+1
|
||||
pha
|
||||
jsr IO.Close.I
|
||||
pla
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
IO.OPEN.CDEV jsr K.IOCTL.GetPDrv
|
||||
|
||||
.1 lda #$ff SELF MODIFIED pass A=DEVID To Driver
|
||||
ldx #IOCTL.OPEN
|
||||
@ -48,11 +165,13 @@ K.Open.DEV >LDYAI K.MLI.PATH+6 skip $/DEV/
|
||||
lda Dev.Table.hFD,x
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
K.Open.REG lda #S.FI.T.TXT
|
||||
sta K.FOpen.TYPE
|
||||
stz K.FOpen.AUXTYPE
|
||||
stz K.FOpen.AUXTYPE+1
|
||||
jmp K.FOpen.I
|
||||
IO.OPEN.DSOCK
|
||||
*--------------------------------------
|
||||
IO.OPEN.SSOCK
|
||||
*--------------------------------------
|
||||
IO.OPEN.PIPE
|
||||
clc
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # close
|
||||
* ## C
|
||||
@ -62,30 +181,26 @@ K.Open.REG lda #S.FI.T.TXT
|
||||
* `lda fd`
|
||||
* `>SYSCALL close`
|
||||
*\--------------------------------------
|
||||
K.Close jsr K.GetMemPtr
|
||||
bcs .9
|
||||
|
||||
K.Close pha save hFD
|
||||
jsr K.GetMemPtr
|
||||
>STYA pFD
|
||||
|
||||
lda (pFD) #S.FD.T
|
||||
IO.Close.I lda (pFD) #S.FD.T
|
||||
tax
|
||||
pla
|
||||
jmp (.1,x)
|
||||
|
||||
.1 .DA IO.CLOSE.REG
|
||||
.DA IO.CLOSE.DIR
|
||||
.DA IO.CLOSE.CDEV
|
||||
.DA STDIO.IOERR BDEV
|
||||
.DA IO.CLOSE.BDEV
|
||||
.DA STDIO.IOERR LNK
|
||||
.DA IO.CLOSE.DSOCK
|
||||
.DA IO.CLOSE.SSOCK
|
||||
.DA IO.CLOSE.PIPE
|
||||
|
||||
.9 lda #MLI.E.NODEV
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
IO.CLOSE.REG
|
||||
IO.CLOSE.DIR
|
||||
IO.CLOSE.DIR pha save hFD
|
||||
ldy #S.FD.REG.REF
|
||||
lda (pFD),y
|
||||
beq .1
|
||||
@ -94,14 +209,15 @@ IO.CLOSE.DIR
|
||||
|
||||
.1 ldy #S.FD.REG.IOBUF
|
||||
lda (pFD),y
|
||||
beq .8
|
||||
beq .2
|
||||
|
||||
jsr K.FreeMem
|
||||
|
||||
.2 pla
|
||||
jmp K.FreeMem
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
IO.CLOSE.CDEV
|
||||
IO.CLOSE.BDEV
|
||||
*--------------------------------------
|
||||
IO.CLOSE.DSOCK
|
||||
IO.CLOSE.SSOCK
|
||||
|
@ -8,11 +8,11 @@ AUTO 4,1
|
||||
*--------------------------------------
|
||||
K.SYSCALL.JMP .DA 0 $00
|
||||
.DA 0
|
||||
.DA K.FStat
|
||||
.DA K.Stat
|
||||
.DA K.MKDir
|
||||
.DA K.MKNod
|
||||
.DA K.MKFIFO
|
||||
.DA K.FStat
|
||||
.DA 0
|
||||
|
||||
.DA K.OpenDir $10
|
||||
|
@ -3,7 +3,7 @@ PREFIX /A2OSX.BUILD
|
||||
AUTO 4,1
|
||||
*--------------------------------------
|
||||
* # FStat
|
||||
* Return information about a hfile
|
||||
* Return information about a hFILE
|
||||
* ## C
|
||||
* `int fstat(short int hFILE, struct stat *statbuf);`
|
||||
* ## ASM
|
||||
@ -14,38 +14,14 @@ AUTO 4,1
|
||||
* **Out:**
|
||||
*--------------------------------------
|
||||
K.FStat jsr PFT.CheckNodeA
|
||||
jsr STDIO.GetHFile
|
||||
bcs .9
|
||||
|
||||
lda Nod.Table.hPath,x
|
||||
jsr K.GetMemPtr
|
||||
bra K.Stat.I
|
||||
|
||||
>STYA pFD
|
||||
|
||||
lda #S.FD.REG
|
||||
clc
|
||||
adc pFD
|
||||
tay
|
||||
lda /S.FD.REG
|
||||
adc pFD+1
|
||||
jsr K.Stat.I
|
||||
bcs .9
|
||||
|
||||
ldy #S.FD.REG.REF
|
||||
lda (pFD),y
|
||||
sta K.MLI.PARAMS+1
|
||||
>MLICALL MLIGETEOF
|
||||
bcs .9
|
||||
|
||||
ldy #S.STAT.SIZE+3
|
||||
lda #0
|
||||
sta (ZPPtr1),y
|
||||
|
||||
ldx #2
|
||||
|
||||
.1 dey
|
||||
lda K.MLI.PARAMS+2,x
|
||||
sta (ZPPtr1),y
|
||||
dex
|
||||
bpl .1
|
||||
|
||||
.9 rts
|
||||
.9 >RET 2 discard statbuf
|
||||
*/--------------------------------------
|
||||
* # Stat
|
||||
* Return information about a file
|
||||
|
@ -18,22 +18,25 @@ BCDBUF .EQ ARG
|
||||
* `int fputc ( hFILE stream , int character );`
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* A : character
|
||||
* Y : stream
|
||||
* `>PUSHB character`
|
||||
* `lda stream`
|
||||
* `>SYSCALL fputc`
|
||||
* **Out:**
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.FPutC sta K.IOBuf
|
||||
tya
|
||||
K.FPutC pha
|
||||
>PULLB K.IOBuf
|
||||
pla
|
||||
bra K.PutChar.1
|
||||
*/--------------------------------------
|
||||
* # PutChar
|
||||
* Print A (char) to StdOut
|
||||
* ## C
|
||||
* `int putchar ( int character );`
|
||||
* ## ASM
|
||||
* Print A (char) to StdOut
|
||||
* **In:**
|
||||
* A : char to print
|
||||
* `lda caracter`
|
||||
* `>SYSCALL putchar`
|
||||
* **Out:**
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
@ -43,14 +46,13 @@ K.PutChar sta K.IOBuf
|
||||
lda (pPs),y
|
||||
|
||||
K.PutChar.1 jsr STDIO.GetHFile
|
||||
bcs K.PutS.9
|
||||
bcs K.PutS.RTS
|
||||
|
||||
ldx #1
|
||||
ldy #1
|
||||
K.PutChar.Y lda #0
|
||||
|
||||
K.PutChar.X >LDYAI K.IOBuf
|
||||
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
|
||||
stx K.S.IOCTL+S.IOCTL.BYTECNT
|
||||
stz K.S.IOCTL+S.IOCTL.BYTECNT+1
|
||||
>PUSHYA
|
||||
>PUSHWI K.IOBuf
|
||||
jmp IO.Write.I
|
||||
*/--------------------------------------
|
||||
* # PutS
|
||||
@ -64,21 +66,22 @@ K.PutChar.X >LDYAI K.IOBuf
|
||||
* **Out:**
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.PutS >STYA K.S.IOCTL+S.IOCTL.BUFPTR
|
||||
>STYA ZPPtr1
|
||||
K.PutS >PUSHYA
|
||||
|
||||
ldy #S.PS.hStdOut
|
||||
lda (pPs),y
|
||||
jsr K.FPutS.I
|
||||
bcs K.PutS.9
|
||||
jsr K.FPutS
|
||||
bcs K.PutS.RTS
|
||||
|
||||
lda #13
|
||||
lda #C.CR
|
||||
sta K.IOBuf
|
||||
lda #10
|
||||
lda #C.LF
|
||||
sta K.IOBuf+1
|
||||
ldx #2
|
||||
bra K.PutChar.X
|
||||
K.PutS.9 rts
|
||||
|
||||
ldy #2
|
||||
bra K.PutChar.Y
|
||||
|
||||
K.PutS.RTS rts
|
||||
*/--------------------------------------
|
||||
* # FPutS
|
||||
* Write Str to FILE
|
||||
@ -92,34 +95,14 @@ K.PutS.9 rts
|
||||
* **Out:**
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.FPutS pha
|
||||
K.FPutS jsr STDIO.GetHFile
|
||||
bcs K.PutS.RTS
|
||||
|
||||
>PULLA
|
||||
sta K.S.IOCTL+S.IOCTL.BUFPTR
|
||||
sta ZPPtr1
|
||||
>PULLA
|
||||
sta K.S.IOCTL+S.IOCTL.BUFPTR+1
|
||||
sta ZPPtr1+1
|
||||
|
||||
pla
|
||||
|
||||
K.FPutS.I jsr STDIO.GetHFile
|
||||
bcs K.PutS.9
|
||||
|
||||
ldy #0
|
||||
ldx #0
|
||||
|
||||
.1 lda (ZPPtr1),y
|
||||
beq .2
|
||||
|
||||
iny
|
||||
bne .1
|
||||
inx
|
||||
inc ZPPtr1+1
|
||||
bra .1
|
||||
|
||||
.2 sty K.S.IOCTL+S.IOCTL.BYTECNT
|
||||
stx K.S.IOCTL+S.IOCTL.BYTECNT+1
|
||||
>PULLYA Get String
|
||||
>STYA ZPPtr2 Save Buffer
|
||||
>SYSCALL strlen Get String len in Y,A
|
||||
>PUSHYA push len
|
||||
>PUSHW ZPPtr2 push buffer
|
||||
jmp IO.Write.I
|
||||
*/--------------------------------------
|
||||
* # PrintF/SPrintF/FPrintF
|
||||
@ -189,8 +172,8 @@ K.SPrintF >STYA pIOBuf Out Buffer
|
||||
>PULLW ZPPtr1 format
|
||||
bra K.PrintF.1
|
||||
|
||||
K.FPrintF jsr K.GetMemPtr A = hFILE
|
||||
>STYA pFD
|
||||
K.FPrintF jsr STDIO.GetHFile
|
||||
bcs K.PutS.RTS
|
||||
|
||||
>PULLW ZPPtr1 format
|
||||
bra K.PrintF.0
|
||||
@ -199,15 +182,14 @@ K.PrintF >STYA ZPPtr1 format
|
||||
ldy #S.PS.hStdOut
|
||||
lda (pPs),y
|
||||
|
||||
jsr K.GetMemPtr
|
||||
>STYA pFD
|
||||
jsr STDIO.GetHFile
|
||||
bcs K.PutS.RTS
|
||||
|
||||
K.PrintF.0 >LDYAI K.IOBuf
|
||||
>STYA pIOBuf
|
||||
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
|
||||
|
||||
K.PrintF.1 stz K.S.IOCTL+S.IOCTL.BYTECNT
|
||||
stz K.S.IOCTL+S.IOCTL.BYTECNT+1
|
||||
K.PrintF.1 stz PrintF.Cnt
|
||||
stz PrintF.Cnt+1
|
||||
|
||||
stz PrintF.GetByte+1
|
||||
|
||||
@ -269,7 +251,10 @@ K.PrintF.1 stz K.S.IOCTL+S.IOCTL.BYTECNT
|
||||
bcc .1
|
||||
bcs .99
|
||||
|
||||
.8 jsr PrintF.Flush
|
||||
.8 lda pIOBuf+1
|
||||
eor /K.IOBuf
|
||||
bne .99
|
||||
jsr PrintF.Flush
|
||||
bra .99
|
||||
|
||||
.10 cmp #'\'
|
||||
@ -299,7 +284,11 @@ K.PrintF.1 stz K.S.IOCTL+S.IOCTL.BYTECNT
|
||||
sta pStack CC
|
||||
pla
|
||||
plp
|
||||
rts
|
||||
bcs .9
|
||||
|
||||
>LDYA PrintF.Cnt
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
PrintF.ESC jmp (.1,x)
|
||||
.1 .DA PrintF.B,PrintF.BB
|
||||
@ -646,9 +635,9 @@ PrintF.GetByte lda #$FF SELF MODIFIED LStack Ptr
|
||||
*--------------------------------------
|
||||
PrintF.COut phy
|
||||
|
||||
ldy K.S.IOCTL+S.IOCTL.BYTECNT
|
||||
ldy PrintF.Cnt
|
||||
sta (pIOBuf),y
|
||||
inc K.S.IOCTL+S.IOCTL.BYTECNT
|
||||
inc PrintF.Cnt
|
||||
bne .8
|
||||
|
||||
lda pIOBuf+1
|
||||
@ -657,25 +646,29 @@ PrintF.COut phy
|
||||
|
||||
* we are printing to IObuf, flush!
|
||||
|
||||
lda K.S.IOCTL+S.IOCTL.BYTECNT+1
|
||||
lda PrintF.Cnt+1
|
||||
pha
|
||||
lda #1 Flush $100 bytes
|
||||
sta K.S.IOCTL+S.IOCTL.BYTECNT+1
|
||||
sta PrintF.Cnt+1
|
||||
|
||||
jsr PrintF.Flush
|
||||
|
||||
pla
|
||||
inc
|
||||
sta K.S.IOCTL+S.IOCTL.BYTECNT+1
|
||||
|
||||
sta PrintF.Cnt+1
|
||||
|
||||
.7 inc pIOBuf+1
|
||||
inc K.S.IOCTL+S.IOCTL.BYTECNT+1
|
||||
inc PrintF.Cnt+1
|
||||
|
||||
.8 ply
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.Flush jmp IO.Write.I
|
||||
PrintF.Flush >PUSHW PrintF.Cnt
|
||||
>PUSHWI K.IOBuf
|
||||
jmp IO.Write.I
|
||||
*--------------------------------------
|
||||
PrintF.Cnt .BS 2
|
||||
*/--------------------------------------
|
||||
* # FGetS
|
||||
* read bytes from stream into the array
|
||||
@ -953,19 +946,19 @@ K.SScanF.Fwd tya Y=char count parsed
|
||||
* # FOpen
|
||||
* Open a file
|
||||
* ## C
|
||||
* `hFILE fopen ( const char * filename, short int mode, short int ftype, int auxtype );`
|
||||
* `hFILE fopen ( const char * filename, short int flags, short int ftype, int auxtype );`
|
||||
* **In:**
|
||||
* ## ASM
|
||||
* `>PUSHWI auxtype`
|
||||
* `>PUSHBI ftype`
|
||||
* `>PUSHBI mode`
|
||||
* `>PUSHBI flags`
|
||||
* + O.RDONLY : if R and !exists -> ERROR
|
||||
* + O.WRONLY : if W and !exists -> CREATE
|
||||
* + O.TRUNC : Reset Size To 0
|
||||
* + O.APPEND : Append
|
||||
* + O.TEXT : Open/Append in Text mode
|
||||
* + O.CREATE : Create if not exists
|
||||
* TODO: mode="w+,t=TYP,x=AUXTYPE"
|
||||
* TODO: replace flags/ftype/auxtype with mode="w+,t=TYP,x=AUXTYPE"
|
||||
* + r = O_RDONLY
|
||||
* + r+ = O_RDWR
|
||||
* + w = O_WRONLY | O_CREAT | O_TRUNC
|
||||
@ -979,110 +972,34 @@ K.SScanF.Fwd tya Y=char count parsed
|
||||
* CC : A = hFILE
|
||||
* CS : A = EC
|
||||
*\--------------------------------------
|
||||
K.FOpen.PATH .BS 2
|
||||
*--------------------------------------
|
||||
K.FOpen jsr PFT.CheckPathYA
|
||||
|
||||
>STYA K.FOpen.PATH
|
||||
jsr STDIO.SetMLIPathYA
|
||||
>PULLB K.FOpen.MODE
|
||||
>PULLB K.FOpen.TYPE
|
||||
>PULLW K.FOpen.AUXTYPE
|
||||
pha
|
||||
>PULLB K.Open.FLAGS
|
||||
>PULLB K.Open.TYPE
|
||||
>PULLW K.Open.AUXTYPE
|
||||
|
||||
K.FOpen.I >MLICALL MLIGETFILEINFO
|
||||
bcc K.FOpen.10 Already Exists
|
||||
pla
|
||||
jsr IO.Open.I
|
||||
bcs K.FOpen.RTS
|
||||
|
||||
bit K.FOpen.MODE Create if not exists ?
|
||||
bpl K.FOpen.9 No, return MLI error
|
||||
sta .1+1 save hFD
|
||||
tax
|
||||
|
||||
lda #S.FI.A.FULL Yes, Create...
|
||||
sta K.MLI.PARAMS+3 Access
|
||||
lda K.FOpen.TYPE
|
||||
sta K.MLI.PARAMS+4 File type
|
||||
>LDYA K.FOpen.AUXTYPE
|
||||
>STYA K.MLI.PARAMS+5 Aux type
|
||||
lda #S.FI.ST.STD
|
||||
sta K.MLI.PARAMS+7
|
||||
|
||||
ldx #3
|
||||
|
||||
.1 lda DATELO,x
|
||||
sta K.MLI.PARAMS+8,x
|
||||
dex
|
||||
bpl .1
|
||||
|
||||
>MLICALL MLICREATE
|
||||
bcc K.FOpen.10
|
||||
K.FOpen.9 rts
|
||||
|
||||
K.FOpen.10 >LDYAI S.FD.REG
|
||||
ldx #S.MEM.F.INIT0+S.MEM.F.FD
|
||||
jsr MEM.GetMem.YAX
|
||||
bcs K.FOpen.9
|
||||
|
||||
>STYA pFD
|
||||
stx .8+1
|
||||
|
||||
* ldy #S.FD.T Done by GetMem0
|
||||
* lda #S.FD.T.REG
|
||||
* sta (pFD),y
|
||||
|
||||
jsr STDIO.SetIOBUF
|
||||
bcs .98
|
||||
|
||||
>MLICALL MLIOPEN
|
||||
bcs .98
|
||||
|
||||
lda K.MLI.PARAMS+5 get ref_num
|
||||
ldy #S.FD.REG.REF
|
||||
sta (pFD),y
|
||||
|
||||
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
|
||||
|
||||
lda K.FOpen.MODE
|
||||
bit #O.WRONLY
|
||||
beq .20 Write mode ?
|
||||
|
||||
and #O.APPEND Append ?
|
||||
bne .11 yes, go to end of file
|
||||
|
||||
stz K.MLI.PARAMS+2
|
||||
stz K.MLI.PARAMS+3
|
||||
stz K.MLI.PARAMS+4
|
||||
>MLICALL MLISETEOF no, reset size to 0
|
||||
bra .21
|
||||
|
||||
.11 >MLICALL MLIGETEOF
|
||||
bcs .98
|
||||
|
||||
>MLICALL MLISETMARK
|
||||
.21 bcs .98
|
||||
|
||||
.20 lda K.FOpen.MODE
|
||||
and #O.TEXT Text Mode ?
|
||||
beq .22
|
||||
|
||||
lda #$FF
|
||||
sta K.MLI.PARAMS+2
|
||||
lda #C.CR
|
||||
sta K.MLI.PARAMS+3
|
||||
>MLICALL MLINEWLINE
|
||||
|
||||
.22 >LDYA K.FOpen.PATH
|
||||
|
||||
.8 ldx #$ff Self Modified, hFD
|
||||
>LDYA K.FOpen.PATH
|
||||
|
||||
jsr STDIO.NewHFileYAX
|
||||
bcc .80
|
||||
bcc K.FOpen.RTS
|
||||
|
||||
.98 pha save MLI error
|
||||
lda .8+1
|
||||
pha save MLI error
|
||||
.1 lda #$ff SELF MODIFIED
|
||||
jsr K.Close
|
||||
pla get back MLI error
|
||||
sec
|
||||
.80 rts
|
||||
*--------------------------------------
|
||||
K.FOpen.PATH .BS 2
|
||||
K.FOpen.MODE .BS 1
|
||||
K.FOpen.TYPE .BS 1
|
||||
K.FOpen.AUXTYPE .BS 2
|
||||
K.FOpen.RTS rts
|
||||
*/--------------------------------------
|
||||
* # FClose
|
||||
* Close a file
|
||||
@ -1118,8 +1035,10 @@ K.FClose jsr PFT.CheckNodeA
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # FRead
|
||||
* int fread (hFILE stream, void * ptr, int count );
|
||||
* Read bytes from file
|
||||
* ## C
|
||||
* int fread (hFILE stream, void * ptr, int count );
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHWI count`
|
||||
* `>PUSHW ptr`
|
||||
|
@ -4,9 +4,9 @@ AUTO 4,1
|
||||
*/--------------------------------------
|
||||
* # strtof
|
||||
* Convert String to 40 bits Float
|
||||
* ##C
|
||||
* ## C
|
||||
* `float strtof (const char* str, char** endptr);`
|
||||
* ##ASM
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* `>PUSHWI EndPtr`
|
||||
* `>LDYA str`
|
||||
|
@ -13,7 +13,7 @@ DAY0 .EQ 4 day 0 was a thursday
|
||||
* Get System Time in Buffer
|
||||
* ## C
|
||||
* `time_t time (S.TIME* timer);`
|
||||
* ##ASM
|
||||
* ## ASM
|
||||
* **In:**
|
||||
* Y,A = PTR to S.TIME
|
||||
* **Out:**
|
||||
@ -29,7 +29,7 @@ K.Time >STYA ZPPtr2
|
||||
* Convert ProDOS Time To S.TIME
|
||||
* ## C
|
||||
* `int PTime2Time (long* ptime, S.TIME* timer);`
|
||||
* ##ASM
|
||||
* ## ASM
|
||||
* **In :**
|
||||
* `>PUSHW timer`
|
||||
* `>LDYA ptime`
|
||||
@ -164,7 +164,7 @@ K.ComputeWDAY lda #3 Thursday : 4 (-1 for mod 7)
|
||||
* Convert CTime Time To S.TIME
|
||||
* ## C
|
||||
* `int CTime2Time (long* ctime, S.TIME* timer);`
|
||||
* ##ASM
|
||||
* ## ASM
|
||||
* **In :**
|
||||
* `>PUSHW timer`
|
||||
* `>LDYA ctime`
|
||||
|
108
SYS/KERNEL.S.txt
108
SYS/KERNEL.S.txt
@ -1,64 +1,64 @@
|
||||
NEW
|
||||
PREFIX /A2OSX.BUILD
|
||||
AUTO 4,1
|
||||
.LIST OFF
|
||||
.OP 65C02
|
||||
.OR $2000
|
||||
.TF SYS/KERNEL
|
||||
.LIST OFF
|
||||
.OP 65C02
|
||||
.OR $2000
|
||||
.TF SYS/KERNEL
|
||||
|
||||
.INB INC/MACROS.I
|
||||
.INB INC/KERNEL.I
|
||||
.INB INC/A2OSX.I
|
||||
.INB INC/IO.I
|
||||
.INB INC/MLI.I
|
||||
.INB INC/MLI.E.I
|
||||
.INB INC/XY.MOUSE.I
|
||||
.INB INC/GUI.I
|
||||
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.INIT
|
||||
.INB /A2OSX.SRC/X.PRINTF.S
|
||||
.INB INC/MACROS.I
|
||||
.INB INC/KERNEL.I
|
||||
.INB INC/A2OSX.I
|
||||
.INB INC/IO.I
|
||||
.INB INC/MLI.I
|
||||
.INB INC/MLI.E.I
|
||||
.INB INC/XY.MOUSE.I
|
||||
.INB INC/GUI.I
|
||||
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.INIT
|
||||
.INB /A2OSX.SRC/X.PRINTF.S
|
||||
|
||||
A2osX.MAIN .PH $1100
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.CORE
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.DRV
|
||||
.EP
|
||||
A2osX.AUX .PH $0C00
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.OSD
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.SLIST
|
||||
.EP
|
||||
A2osX.GP .PH $BD00
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.GP
|
||||
.EP
|
||||
A2osX.D1 .PH $D000
|
||||
.DA #RRAMWRAMBNK1
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STAT
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.DIRENT
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STDIO
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STDLIB
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.PFT
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.DEV
|
||||
.EP
|
||||
A2osX.D2 .PH $D000
|
||||
.DA #RRAMWRAMBNK2
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STRING
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.TIME
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.BIN
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.PS
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.ARG
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.ENV
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.MATH
|
||||
.EP
|
||||
A2osX.E0 .PH $E000
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.JMP
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.IRQ
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.MEM
|
||||
A2osX.MAIN .PH $1100
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.CORE
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.DRV
|
||||
.EP
|
||||
A2osX.AUX .PH $0C00
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.OSD
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.SLIST
|
||||
.EP
|
||||
A2osX.GP .PH $BD00
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.GP
|
||||
.EP
|
||||
A2osX.D1 .PH $D000
|
||||
.DA #RRAMWRAMBNK1
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STAT
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.DIRENT
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STDIO
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STDLIB
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.PFT
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.DEV
|
||||
.EP
|
||||
A2osX.D2 .PH $D000
|
||||
.DA #RRAMWRAMBNK2
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.STRING
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.TIME
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.BIN
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.PS
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.ARG
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.ENV
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.MATH
|
||||
.EP
|
||||
A2osX.E0 .PH $E000
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.JMP
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.IRQ
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.MEM
|
||||
********* TMP ***** go to A2osX.D1
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.IO
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.FIO
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.IO
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.FIO
|
||||
DevMgr.FreeMem .EQ *
|
||||
.EP
|
||||
A2osX.E0.E .EQ *
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.CTRL
|
||||
.EP
|
||||
A2osX.E0.E .EQ *
|
||||
.INB /A2OSX.SRC/SYS/KERNEL.S.CTRL
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S
|
||||
ASM
|
||||
|
Loading…
Reference in New Issue
Block a user