mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-09 00:54:29 +00:00
181 lines
3.5 KiB
Plaintext
181 lines
3.5 KiB
Plaintext
|
NEW
|
|||
|
AUTO 3,1
|
|||
|
*/--------------------------------------
|
|||
|
* # open
|
|||
|
* ## C
|
|||
|
* `hFD open(const char *pathname, short int flags);`
|
|||
|
* ## ASM
|
|||
|
* **In:**
|
|||
|
* `>PUSHB flags`
|
|||
|
* `>LDYA pathname`
|
|||
|
* `>SYSCALL open`
|
|||
|
* ## RETURN VALUE
|
|||
|
* A = hFD
|
|||
|
* REG File created on ProDOS : T=TXT,X=$0000
|
|||
|
*\--------------------------------------
|
|||
|
.DUMMY
|
|||
|
.OR ZPTMP+20 7 Bytes
|
|||
|
IO.Open.FLAGS .BS 1
|
|||
|
IO.Open.TYPE .BS 1
|
|||
|
IO.Open.AUXTYPE .BS 2
|
|||
|
IO.hDev .BS 1
|
|||
|
IO.hFD .BS 1
|
|||
|
IO.hFILE .BS 1
|
|||
|
.ED
|
|||
|
*--------------------------------------
|
|||
|
K.Open jsr PFT.YAToMLIPATH
|
|||
|
>PULLB IO.Open.FLAGS
|
|||
|
|
|||
|
lda #S.FI.T.TXT
|
|||
|
sta IO.Open.TYPE
|
|||
|
stz IO.Open.AUXTYPE
|
|||
|
stz IO.Open.AUXTYPE+1
|
|||
|
*--------------------------------------
|
|||
|
UNISTD.Open ldx #5 /DEV/
|
|||
|
cpx K.MLI.PATH
|
|||
|
bcs .9
|
|||
|
|
|||
|
.1 lda K.MLI.PATH,x
|
|||
|
cmp IO.DEVDIR-1,x
|
|||
|
bne .9
|
|||
|
dex
|
|||
|
bne .1
|
|||
|
*--------------------------------------
|
|||
|
* /DEV/xxxxxx (CDEV,BDEV,LNK,DSOCK,SSOCK,PIPE)
|
|||
|
*--------------------------------------
|
|||
|
>LDYAI K.MLI.PATH+6 skip $/DEV/
|
|||
|
|
|||
|
jsr K.GetDevByName
|
|||
|
bcc .7
|
|||
|
|
|||
|
ldx #2
|
|||
|
|
|||
|
.10 lda Nod.Table.hPath-2,x
|
|||
|
beq .3
|
|||
|
|
|||
|
jsr K.GetMemPtr
|
|||
|
>STYA ZPPtr1
|
|||
|
|
|||
|
ldy #0
|
|||
|
|
|||
|
.2 lda (ZPPtr1),y
|
|||
|
iny
|
|||
|
cmp K.MLI.PATH,y
|
|||
|
bne .3
|
|||
|
cmp #0 end of string ?
|
|||
|
bne .2
|
|||
|
|
|||
|
lda Nod.Table.hFD-2,x return hFD
|
|||
|
jsr IO.GetPFD
|
|||
|
|
|||
|
bra .71
|
|||
|
|
|||
|
.3 inx
|
|||
|
cpx #K.NOD.MAX+2
|
|||
|
bne .10
|
|||
|
|
|||
|
lda #MLI.E.NODEV
|
|||
|
* sec
|
|||
|
rts no OF found
|
|||
|
|
|||
|
.7 stx IO.hDev
|
|||
|
>STYA pFD
|
|||
|
|
|||
|
.71 lda (pFD) #S.FD.T
|
|||
|
tax
|
|||
|
jmp (.8,x)
|
|||
|
|
|||
|
.8 .DA STDIO.IOERR REG
|
|||
|
.DA STDIO.IOERR DIR
|
|||
|
.DA IO.OPEN.CDEV
|
|||
|
.DA IO.OPEN.BDEV
|
|||
|
.DA STDIO.IOERR LNK
|
|||
|
.DA IO.OPEN.DSOCK
|
|||
|
.DA IO.OPEN.SSOCK
|
|||
|
.DA IO.OPEN.PIPE
|
|||
|
.9 jmp IO.OPEN.REG
|
|||
|
*/--------------------------------------
|
|||
|
* # close
|
|||
|
* ## C
|
|||
|
* `int close(hFD fd);`
|
|||
|
* ## ASM
|
|||
|
* **In:**
|
|||
|
* `lda fd`
|
|||
|
* `>SYSCALL close`
|
|||
|
*\--------------------------------------
|
|||
|
K.Close jsr IO.GetPFD
|
|||
|
|
|||
|
UNISTD.Close lda (pFD) #S.FD.T
|
|||
|
tax
|
|||
|
jmp (.1,x)
|
|||
|
|
|||
|
.1 .DA IO.CLOSE.REG
|
|||
|
.DA IO.CLOSE.DIR
|
|||
|
.DA IO.CLOSE.CDEV
|
|||
|
.DA IO.CLOSE.BDEV
|
|||
|
.DA STDIO.IOERR LNK
|
|||
|
.DA IO.CLOSE.DSOCK
|
|||
|
.DA IO.CLOSE.SSOCK
|
|||
|
.DA IO.CLOSE.PIPE
|
|||
|
*/--------------------------------------
|
|||
|
* # read
|
|||
|
* ## C
|
|||
|
* `int read(hFD fd, void *buf, int count);`
|
|||
|
* ## ASM
|
|||
|
* **In:**
|
|||
|
* `>PUSHWI count`
|
|||
|
* `>PUSHW buf`
|
|||
|
* `lda fd`
|
|||
|
* `>SYSCALL read`
|
|||
|
* ## RETURN VALUE
|
|||
|
* CC: Y,A = bytes read
|
|||
|
* CS: A = EC
|
|||
|
*\--------------------------------------
|
|||
|
K.Read jsr IO.GetPFD
|
|||
|
|
|||
|
UNISTD.Read lda (pFD) #S.FD.T
|
|||
|
tax
|
|||
|
jmp (.1,x)
|
|||
|
|
|||
|
.1 .DA IO.READ.REG
|
|||
|
.DA STDIO.IOERR DIR
|
|||
|
.DA IO.READ.CDEV
|
|||
|
.DA STDIO.IOERR BDEV
|
|||
|
.DA STDIO.IOERR LNK
|
|||
|
.DA STDIO.IOERR DSOCK
|
|||
|
.DA IO.READ.SSOCK
|
|||
|
.DA IO.READ.PIPE
|
|||
|
*/--------------------------------------
|
|||
|
* # write
|
|||
|
* ## C
|
|||
|
* `int write(hFD fd, const void *buf, int count);`
|
|||
|
* ## ASM
|
|||
|
* **In:**
|
|||
|
* `>PUSHWI count`
|
|||
|
* `>PUSHW buf`
|
|||
|
* `lda fd`
|
|||
|
* `>SYSCALL write`
|
|||
|
* ## RETURN VALUE
|
|||
|
* CC: Y,A = bytes written
|
|||
|
* CS: A = EC
|
|||
|
*\--------------------------------------
|
|||
|
K.Write jsr IO.GetPFD
|
|||
|
|
|||
|
UNISTD.Write lda (pFD) #S.FD.T
|
|||
|
tax
|
|||
|
jmp (.1,x)
|
|||
|
|
|||
|
.1 .DA IO.WRITE.REG
|
|||
|
.DA STDIO.IOERR DIR
|
|||
|
.DA IO.WRITE.CDEV
|
|||
|
.DA STDIO.IOERR BDEV
|
|||
|
.DA STDIO.IOERR LNK
|
|||
|
.DA STDIO.IOERR DSOCK
|
|||
|
.DA IO.WRITE.SSOCK
|
|||
|
.DA IO.WRITE.PIPE
|
|||
|
*--------------------------------------
|
|||
|
MAN
|
|||
|
SAVE USR/SRC/SYS/KERNEL.S.UNISTD
|
|||
|
LOAD USR/SRC/SYS/KERNEL.S
|
|||
|
ASM
|