2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2019-05-12 20:45:11 +00:00
|
|
|
|
AUTO 3,1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # putchar (BLOCKING)
|
2018-10-04 15:30:14 +00:00
|
|
|
|
* Print A (char) to StdOut
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
2020-03-10 16:42:07 +00:00
|
|
|
|
* `int putchar ( short int character );`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2019-02-22 16:08:37 +00:00
|
|
|
|
* `lda character`
|
2018-10-04 15:30:14 +00:00
|
|
|
|
* `>SYSCALL putchar`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* CC = success
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*\--------------------------------------
|
2019-02-22 16:08:37 +00:00
|
|
|
|
K.PutChar >PUSHA character
|
2018-05-29 15:31:44 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
ldy #S.PS.hStdOut
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2019-02-22 16:08:37 +00:00
|
|
|
|
jsr K.FPutC
|
2020-08-25 10:56:00 +00:00
|
|
|
|
bcc .8
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
tay
|
|
|
|
|
bne .8
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
>PULLA CS,A=0:BLOCKING, restore A
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
.8 rts
|
2018-11-16 16:04:20 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # fputc (BLOCKING)
|
2018-11-16 16:04:20 +00:00
|
|
|
|
* Print A (char) to hFILE
|
|
|
|
|
* ## C
|
2020-03-10 16:42:07 +00:00
|
|
|
|
* `int fputc ( hFILE stream , short int character );`
|
2018-11-16 16:04:20 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHB character`
|
|
|
|
|
* `lda stream`
|
|
|
|
|
* `>SYSCALL fputc`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FPutC jsr PFT.CheckNodeA
|
2020-08-25 10:56:00 +00:00
|
|
|
|
bcs .8
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-02-22 16:08:37 +00:00
|
|
|
|
lda (pStack) character
|
2019-02-22 21:54:47 +00:00
|
|
|
|
sta K.IOBuf
|
2018-08-08 15:13:37 +00:00
|
|
|
|
|
2019-05-12 20:45:11 +00:00
|
|
|
|
lda #0
|
|
|
|
|
>PUSHA
|
|
|
|
|
inc write 1 byte
|
|
|
|
|
>PUSHA
|
|
|
|
|
|
|
|
|
|
>PUSHWI K.IOBuf buf
|
2019-07-27 20:51:39 +00:00
|
|
|
|
jsr UNISTD.Write
|
2020-08-25 10:56:00 +00:00
|
|
|
|
bcc .8 pop char...
|
|
|
|
|
|
2020-06-30 05:59:37 +00:00
|
|
|
|
cmp #E.NODATA
|
2020-06-30 10:40:19 +00:00
|
|
|
|
sec
|
2020-08-25 10:56:00 +00:00
|
|
|
|
bne .8
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
inc CS,A=0:BLOCKING
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.8 >POP 1
|
2019-02-25 14:47:31 +00:00
|
|
|
|
rts
|
2018-05-29 15:31:44 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # puts (BLOCKING)
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Write Str to StdOut, appends '\r\n'
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int puts ( const char * str );`
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-07-27 13:34:34 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* `>LDYAI str`
|
2020-02-28 07:21:46 +00:00
|
|
|
|
* `>SYSCALL PutS`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* CC = success
|
2018-05-29 15:31:44 +00:00
|
|
|
|
*\--------------------------------------
|
2020-08-25 10:56:00 +00:00
|
|
|
|
K.PutS >STYA .1+1
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
.1 lda $FFFF,y SELF MODIFIED
|
2019-05-12 20:45:11 +00:00
|
|
|
|
beq .2
|
2020-08-25 10:56:00 +00:00
|
|
|
|
|
2019-05-12 20:45:11 +00:00
|
|
|
|
sta K.IOBuf,y
|
|
|
|
|
iny
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.9 lda #E.BUF
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 lda #C.CR
|
|
|
|
|
sta K.IOBuf,y
|
|
|
|
|
iny
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
lda #C.LF
|
|
|
|
|
sta K.IOBuf,y
|
|
|
|
|
iny
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta K.IOBuf,y
|
|
|
|
|
|
2018-05-29 15:31:44 +00:00
|
|
|
|
ldy #S.PS.hStdOut
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2020-08-25 10:56:00 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHWI K.IOBuf
|
|
|
|
|
|
2018-10-04 15:30:14 +00:00
|
|
|
|
jsr K.FPutS
|
2020-08-25 10:56:00 +00:00
|
|
|
|
|
2019-07-25 15:10:59 +00:00
|
|
|
|
bcc K.PutS.RTS
|
2020-08-25 10:56:00 +00:00
|
|
|
|
tay
|
2020-06-30 10:40:19 +00:00
|
|
|
|
bne K.PutS.RTS
|
2019-05-22 07:38:18 +00:00
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
>LDYA .1+1 CS,A=0:BLOCKING, restore Y,A
|
2019-07-25 15:10:59 +00:00
|
|
|
|
|
2020-08-25 10:56:00 +00:00
|
|
|
|
K.PutS.RET3 >POP 3 pop StdOut & buffer
|
2019-07-25 15:10:59 +00:00
|
|
|
|
K.PutS.RTS rts
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # fputs (BLOCKING)
|
2019-05-12 20:45:11 +00:00
|
|
|
|
* Write Str to hFILE
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
2018-07-26 15:26:39 +00:00
|
|
|
|
* `int fputs (hFILE stream, const char * str );`
|
2018-07-27 13:34:34 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2020-08-25 10:56:00 +00:00
|
|
|
|
* `>PUSHB stream`
|
2018-07-27 13:34:34 +00:00
|
|
|
|
* `>PUSHW str`
|
|
|
|
|
* `>SYSCALL fputs`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* CC = success
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*\--------------------------------------
|
2020-08-25 10:56:00 +00:00
|
|
|
|
K.FPutS jsr PFT.CheckNode2 set IO.hFD
|
|
|
|
|
bcs K.PutS.RET3
|
2018-07-27 13:34:34 +00:00
|
|
|
|
|
2019-05-12 20:45:11 +00:00
|
|
|
|
lda (pStack)
|
|
|
|
|
sta ZPPtr2 Get String
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (pStack),y
|
|
|
|
|
sta ZPPtr2+1
|
2020-08-25 10:56:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #0
|
2019-05-12 20:45:11 +00:00
|
|
|
|
ldx #0
|
2020-03-04 16:38:32 +00:00
|
|
|
|
|
2019-05-12 20:45:11 +00:00
|
|
|
|
.1 lda (ZPPtr2),y
|
|
|
|
|
beq .2
|
2020-08-25 10:56:00 +00:00
|
|
|
|
|
2019-05-12 20:45:11 +00:00
|
|
|
|
iny
|
|
|
|
|
bne .1
|
2020-08-25 10:56:00 +00:00
|
|
|
|
|
2019-05-12 20:45:11 +00:00
|
|
|
|
inx
|
|
|
|
|
bra .1
|
2020-08-25 10:56:00 +00:00
|
|
|
|
|
2019-05-12 20:45:11 +00:00
|
|
|
|
.2 txa
|
|
|
|
|
>PUSHA push len HI
|
|
|
|
|
|
|
|
|
|
tya
|
|
|
|
|
>PUSHA push len LO
|
|
|
|
|
|
|
|
|
|
>PUSHW ZPPtr2
|
2019-07-27 20:51:39 +00:00
|
|
|
|
jsr UNISTD.Write
|
2020-08-25 10:56:00 +00:00
|
|
|
|
bcc K.PutS.RET3
|
2020-06-30 05:59:37 +00:00
|
|
|
|
|
|
|
|
|
cmp #E.NODATA
|
2020-06-30 10:40:19 +00:00
|
|
|
|
sec
|
2020-08-25 10:56:00 +00:00
|
|
|
|
bne K.PutS.RET3 IO Error
|
|
|
|
|
|
2020-03-04 16:38:32 +00:00
|
|
|
|
inc FF-> 0 = BLOCKING
|
2020-08-25 10:56:00 +00:00
|
|
|
|
|
|
|
|
|
K.FPutS.RTS rts
|
2017-10-09 15:30:48 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # fgets (BLOCKING)
|
2018-07-27 13:34:34 +00:00
|
|
|
|
* 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
|
|
|
|
|
* string is then terminated with a null byte.
|
|
|
|
|
* ## C
|
|
|
|
|
* `char *fgets(hFILE stream, char * s, int n);`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHW n`
|
|
|
|
|
* `>PUSHW s`
|
|
|
|
|
* `lda hFILE`
|
|
|
|
|
* `>SYSCALL fgets`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-07-27 13:34:34 +00:00
|
|
|
|
* Y,A: s
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
2019-02-25 14:47:31 +00:00
|
|
|
|
* (pStack)+2 n
|
|
|
|
|
* (pStack)+0 s
|
|
|
|
|
*--------------------------------------
|
2018-11-16 16:04:20 +00:00
|
|
|
|
K.FGetS jsr PFT.CheckNodeA
|
2020-02-14 16:32:52 +00:00
|
|
|
|
bcs K.FPutS.RTS
|
2018-08-08 15:13:37 +00:00
|
|
|
|
|
2019-05-10 14:49:53 +00:00
|
|
|
|
lda (pStack)
|
2019-05-31 07:31:41 +00:00
|
|
|
|
sta ZPPtr2 s LO
|
2019-05-07 15:39:35 +00:00
|
|
|
|
ldy #1
|
2019-02-25 14:47:31 +00:00
|
|
|
|
lda (pStack),y
|
2019-05-31 07:31:41 +00:00
|
|
|
|
sta ZPPtr2+1 s HI
|
2018-08-08 15:13:37 +00:00
|
|
|
|
|
2019-02-25 14:47:31 +00:00
|
|
|
|
iny
|
2019-05-31 07:31:41 +00:00
|
|
|
|
lda (pStack),y n LO
|
|
|
|
|
sta ZPPtr1
|
2019-05-07 15:39:35 +00:00
|
|
|
|
|
2019-02-25 14:47:31 +00:00
|
|
|
|
iny
|
2019-05-31 07:31:41 +00:00
|
|
|
|
lda (pStack),y n HI
|
|
|
|
|
sta ZPPtr1+1
|
|
|
|
|
bmi .3 already something in buffer
|
|
|
|
|
|
2020-03-11 16:41:45 +00:00
|
|
|
|
.1 jsr STDIO.Get.1
|
2019-05-31 07:31:41 +00:00
|
|
|
|
bcc .2
|
2020-06-30 05:59:37 +00:00
|
|
|
|
|
|
|
|
|
cmp #E.NODATA
|
2020-06-30 10:40:19 +00:00
|
|
|
|
sec
|
2020-06-30 05:59:37 +00:00
|
|
|
|
bne .9 IO error
|
|
|
|
|
|
2020-07-30 11:14:37 +00:00
|
|
|
|
.11 lda #0 BLOCKING
|
2019-05-31 07:31:41 +00:00
|
|
|
|
rts
|
2020-03-11 16:41:45 +00:00
|
|
|
|
|
2019-05-17 14:57:14 +00:00
|
|
|
|
.2 lda K.IOBuf
|
2020-07-09 18:57:35 +00:00
|
|
|
|
cmp #C.LF Discard any leading LF from a previous CR/LF
|
2020-07-30 06:29:34 +00:00
|
|
|
|
* beq .8 returns as empty string
|
2020-07-30 11:14:37 +00:00
|
|
|
|
beq .11 CS -> NODATA -> BLOCKING
|
2019-05-31 07:31:41 +00:00
|
|
|
|
|
2019-05-17 14:57:14 +00:00
|
|
|
|
cmp #C.CR
|
2019-05-31 07:31:41 +00:00
|
|
|
|
beq .8 empty string
|
|
|
|
|
|
2019-07-28 20:39:30 +00:00
|
|
|
|
jsr SHARED.PutCharPtr2
|
2019-05-31 07:31:41 +00:00
|
|
|
|
|
|
|
|
|
lda ZPPtr1
|
|
|
|
|
eor #$ff
|
|
|
|
|
sta ZPPtr1
|
|
|
|
|
|
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
eor #$ff
|
|
|
|
|
sta ZPPtr1+1
|
2020-03-11 16:41:45 +00:00
|
|
|
|
|
2019-05-31 07:31:41 +00:00
|
|
|
|
.3 inc ZPPtr1
|
|
|
|
|
bne .4
|
2019-05-07 15:39:35 +00:00
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
beq .8 Buffer full
|
2018-12-20 21:56:44 +00:00
|
|
|
|
|
2020-03-11 16:41:45 +00:00
|
|
|
|
.4 jsr STDIO.Get.1
|
2019-05-31 07:31:41 +00:00
|
|
|
|
bcs .5
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-05-31 07:31:41 +00:00
|
|
|
|
lda K.IOBuf
|
|
|
|
|
cmp #C.CR
|
2019-05-22 15:46:20 +00:00
|
|
|
|
beq .8
|
2020-06-30 05:59:37 +00:00
|
|
|
|
|
2019-07-28 20:39:30 +00:00
|
|
|
|
jsr SHARED.PutCharPtr2
|
2019-05-31 07:31:41 +00:00
|
|
|
|
bra .3
|
2020-06-30 05:59:37 +00:00
|
|
|
|
|
2019-05-31 07:31:41 +00:00
|
|
|
|
.5 cmp #MLI.E.EOF
|
|
|
|
|
beq .8 String terminated by EOF
|
2020-06-30 05:59:37 +00:00
|
|
|
|
|
|
|
|
|
cmp #E.NODATA
|
2020-06-30 10:40:19 +00:00
|
|
|
|
sec
|
2020-06-30 05:59:37 +00:00
|
|
|
|
bne .9 I/O error
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-05-31 07:31:41 +00:00
|
|
|
|
lda ZPPtr2 NO DATA, but string not yet terminated
|
2019-05-07 15:39:35 +00:00
|
|
|
|
sta (pStack) s
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-05-07 15:39:35 +00:00
|
|
|
|
ldy #1
|
2019-05-31 07:31:41 +00:00
|
|
|
|
lda ZPPtr2+1
|
2019-05-07 15:39:35 +00:00
|
|
|
|
sta (pStack),y s
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-05-07 15:39:35 +00:00
|
|
|
|
iny
|
2019-05-31 07:31:41 +00:00
|
|
|
|
lda ZPPtr1
|
|
|
|
|
sta (pStack),y !n LO
|
2019-02-25 14:47:31 +00:00
|
|
|
|
|
2019-05-07 15:39:35 +00:00
|
|
|
|
iny
|
2019-05-31 07:31:41 +00:00
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
sta (pStack),y !n HI
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
|
|
|
|
lda #0 BLOCKING
|
2020-06-30 10:40:19 +00:00
|
|
|
|
* sec
|
2019-05-07 15:39:35 +00:00
|
|
|
|
rts
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-05-07 15:39:35 +00:00
|
|
|
|
.8 lda #0
|
2019-02-25 14:47:31 +00:00
|
|
|
|
sta (ZPPtr2) terminate string
|
2019-05-07 15:39:35 +00:00
|
|
|
|
clc
|
2019-07-25 15:10:59 +00:00
|
|
|
|
.9 >RET 4
|
2018-07-27 13:34:34 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # getchar (BLOCKING)
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Get char from StdIn
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `short int getchar ( );`
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `>SYSCALL getchar`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CC = success
|
|
|
|
|
* A = char
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*\--------------------------------------
|
2018-05-31 15:54:00 +00:00
|
|
|
|
K.GetChar ldy #S.PS.hStdIn
|
2020-02-28 07:21:46 +00:00
|
|
|
|
lda (pPS),y
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # getc (BLOCKING)
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Get char from Node
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `short int getc ( short int stream );`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `lda stream`
|
|
|
|
|
* `>SYSCALL getc`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CC = success
|
|
|
|
|
* A = char
|
2018-10-05 14:58:38 +00:00
|
|
|
|
*\--------------------------------------
|
2018-11-16 16:04:20 +00:00
|
|
|
|
K.GetC jsr PFT.CheckNodeA
|
2019-02-22 16:08:37 +00:00
|
|
|
|
bcs K.GetC.RTS
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-03-11 16:41:45 +00:00
|
|
|
|
jsr STDIO.Get.1
|
2019-02-22 16:08:37 +00:00
|
|
|
|
bcc .8
|
2020-06-30 05:59:37 +00:00
|
|
|
|
|
|
|
|
|
cmp #E.NODATA
|
2020-06-30 10:40:19 +00:00
|
|
|
|
sec
|
2020-06-30 05:59:37 +00:00
|
|
|
|
bne K.GetC.RTS I/O error
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
|
|
|
|
inc 0 = BLOCKING
|
|
|
|
|
rts
|
|
|
|
|
|
2019-02-22 16:08:37 +00:00
|
|
|
|
.8 lda K.IOBuf
|
2019-05-04 21:13:50 +00:00
|
|
|
|
|
2019-07-15 06:41:12 +00:00
|
|
|
|
K.GetC.RTS rts
|
|
|
|
|
*--------------------------------------
|
2020-03-11 16:41:45 +00:00
|
|
|
|
STDIO.Get.1 lda #0
|
2019-07-15 06:41:12 +00:00
|
|
|
|
>PUSHA
|
|
|
|
|
inc read 1 byte
|
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHWI K.IOBuf
|
2019-07-27 20:51:39 +00:00
|
|
|
|
jmp UNISTD.READ
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*/--------------------------------------
|
2020-07-01 05:48:31 +00:00
|
|
|
|
* # ungetc
|
|
|
|
|
* push byte back into input stream
|
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `short int ungetc(short int c, short int stream);`
|
2020-07-01 05:48:31 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHB c`
|
|
|
|
|
* `>PUSHB stream`
|
|
|
|
|
* `>SYSCALL ungetc`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* CC = success
|
|
|
|
|
* A = char
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.UngetC clc
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* # FOpen
|
|
|
|
|
* Open a file
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## C
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `short int fopen ( const char *filename, short int flags, short int ftype, int auxtype );`
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## ASM
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `>PUSHW filename`
|
|
|
|
|
* `>PUSHB flags`
|
2018-10-02 15:52:30 +00:00
|
|
|
|
* + O.RDONLY : if R and !exists -> ERROR
|
|
|
|
|
* + O.WRONLY : if W and !exists -> CREATE
|
2018-10-03 15:25:03 +00:00
|
|
|
|
* + O.TRUNC : Reset Size To 0
|
2018-10-02 15:52:30 +00:00
|
|
|
|
* + O.APPEND : Append
|
|
|
|
|
* + O.TEXT : Open/Append in Text mode
|
|
|
|
|
* + O.CREATE : Create if not exists
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `>PUSHB ftype`
|
|
|
|
|
* `>PUSHW auxtype`
|
2018-10-04 15:30:14 +00:00
|
|
|
|
* TODO: replace flags/ftype/auxtype with mode="w+,t=TYP,x=AUXTYPE"
|
2018-10-03 15:25:03 +00:00
|
|
|
|
* + r = O_RDONLY
|
|
|
|
|
* + r+ = O_RDWR
|
|
|
|
|
* + w = O_WRONLY | O_CREAT | O_TRUNC
|
|
|
|
|
* + w+ = O_RDWR | O_CREAT | O_TRUNC
|
|
|
|
|
* + a = O_WRONLY | O_CREAT | O_APPEND
|
|
|
|
|
* + a+ = O_RDWR | O_CREAT | O_APPEND
|
|
|
|
|
* + ,t=123 or t=$ff or t=TXT
|
|
|
|
|
* + ,x=12345 or x=$ffff
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CC : A = hFILE
|
|
|
|
|
* CS : A = EC
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*\--------------------------------------
|
2020-02-14 07:21:56 +00:00
|
|
|
|
K.FOpen jsr PFT.CheckPath4
|
2020-03-11 16:41:45 +00:00
|
|
|
|
bcs .9
|
2018-12-03 13:56:52 +00:00
|
|
|
|
|
2019-07-27 20:51:39 +00:00
|
|
|
|
>PULLW IO.Open.AUXTYPE
|
2020-02-14 07:21:56 +00:00
|
|
|
|
>PULLB IO.Open.TYPE
|
|
|
|
|
>PULLB IO.Open.FLAGS
|
|
|
|
|
|
|
|
|
|
inc pStack discard filename
|
|
|
|
|
inc pStack
|
|
|
|
|
|
2019-07-27 20:51:39 +00:00
|
|
|
|
jsr UNISTD.Open
|
2020-03-11 16:41:45 +00:00
|
|
|
|
bcs .99
|
2018-12-03 13:56:52 +00:00
|
|
|
|
|
2019-01-13 13:10:14 +00:00
|
|
|
|
jsr STDIO.NewHFile
|
2020-03-11 16:41:45 +00:00
|
|
|
|
bcc .99
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-08-19 19:39:43 +00:00
|
|
|
|
pha Save Error Code
|
|
|
|
|
lda IO.hFD
|
|
|
|
|
jsr K.Close
|
|
|
|
|
pla
|
|
|
|
|
sec
|
2018-11-16 16:04:20 +00:00
|
|
|
|
|
2020-03-11 16:41:45 +00:00
|
|
|
|
.9 >POP 6
|
|
|
|
|
.99 rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
* # FClose
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Close a file
|
2018-07-10 15:33:13 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int fclose ( short int stream );`
|
2018-07-10 15:33:13 +00:00
|
|
|
|
* ## ASM
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `lda stream`
|
2020-02-28 07:21:46 +00:00
|
|
|
|
* `>SYSCALL FClose`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.FClose jsr PFT.CheckNodeA
|
2019-02-28 16:45:33 +00:00
|
|
|
|
bcs K.FClose.RTS
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-01-25 12:43:50 +00:00
|
|
|
|
sta .1+1 store hFile
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-07-27 20:51:39 +00:00
|
|
|
|
jsr UNISTD.Close
|
2019-02-28 16:45:33 +00:00
|
|
|
|
bcs K.FClose.RTS
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-10-03 06:25:27 +00:00
|
|
|
|
.1 ldx #$ff SELF MODIFIED
|
2019-02-27 15:00:56 +00:00
|
|
|
|
stz OF.Table.hFD-1,x
|
2018-05-31 15:54:00 +00:00
|
|
|
|
|
2019-02-27 15:00:56 +00:00
|
|
|
|
lda OF.Table.hPath-1,x
|
2019-02-28 16:45:33 +00:00
|
|
|
|
beq K.FClose.RTS special files have no path
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-02-27 15:00:56 +00:00
|
|
|
|
stz OF.Table.hPath-1,x
|
2019-01-25 12:43:50 +00:00
|
|
|
|
jmp K.FreeMem discard filename
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # FRead (BLOCKING)
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Read bytes from file
|
2018-10-04 15:30:14 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int fread (short int stream, void * ptr, int count );`
|
2018-10-04 15:30:14 +00:00
|
|
|
|
* ## ASM
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-07-24 16:00:24 +00:00
|
|
|
|
* `>PUSHWI count`
|
|
|
|
|
* `>PUSHW ptr`
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `lda stream`
|
2018-07-24 16:00:24 +00:00
|
|
|
|
* `>SYSCALL fread`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Y,A = Bytes Read
|
|
|
|
|
*\--------------------------------------
|
2018-07-24 16:00:24 +00:00
|
|
|
|
K.FRead jsr PFT.CheckNodeA
|
2020-03-10 16:42:07 +00:00
|
|
|
|
bcs K.FWrite.RET4
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-07-27 20:51:39 +00:00
|
|
|
|
jsr UNISTD.Read
|
2019-05-21 15:52:52 +00:00
|
|
|
|
bcs K.FWrite.9
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-07-25 15:10:59 +00:00
|
|
|
|
K.FClose.RTS rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
2019-02-20 16:07:43 +00:00
|
|
|
|
* # FWrite (BLOCKING)
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Write bytes to file
|
2018-06-19 15:08:22 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int fwrite ( short int stream, const void * ptr, int count );`
|
2018-06-19 15:08:22 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-07-24 16:00:24 +00:00
|
|
|
|
* `>PUSHWI count`
|
|
|
|
|
* `>PUSHW ptr`
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `lda stream`
|
2018-07-24 16:00:24 +00:00
|
|
|
|
* `>SYSCALL fwrite`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Y,A = Bytes Written
|
|
|
|
|
*\--------------------------------------
|
2018-07-24 16:00:24 +00:00
|
|
|
|
K.FWrite jsr PFT.CheckNodeA
|
2020-03-10 16:42:07 +00:00
|
|
|
|
bcs K.FWrite.RET4
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-07-27 20:51:39 +00:00
|
|
|
|
jsr UNISTD.Write
|
2019-05-21 15:52:52 +00:00
|
|
|
|
bcc K.FWrite.RTS
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-06-30 05:59:37 +00:00
|
|
|
|
K.FWrite.9 cmp #E.NODATA
|
2020-06-30 10:40:19 +00:00
|
|
|
|
sec
|
2020-06-30 05:59:37 +00:00
|
|
|
|
bne K.FWrite.RTS IO Error
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-05-21 15:52:52 +00:00
|
|
|
|
dec pStack FF = NODATA
|
|
|
|
|
dec pStack
|
|
|
|
|
dec pStack
|
|
|
|
|
dec pStack keep ptr & count on stack
|
2019-05-12 20:45:11 +00:00
|
|
|
|
inc 0 = BLOCKING
|
2020-06-30 10:40:19 +00:00
|
|
|
|
* sec
|
2019-05-21 15:52:52 +00:00
|
|
|
|
K.FWrite.RTS rts
|
2020-03-10 16:42:07 +00:00
|
|
|
|
|
|
|
|
|
K.FWrite.RET4 >RET 4
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
* # FFlush
|
2018-07-25 15:26:14 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int fflush( short int stream );`
|
2018-07-25 15:26:14 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `lda stream`
|
|
|
|
|
* `>SYSCALL fflush`
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.FFlush jsr PFT.CheckNodeA
|
2018-10-04 06:13:44 +00:00
|
|
|
|
bcs .9
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
|
|
|
|
lda (pFD)
|
|
|
|
|
bne STDIO.IOERR
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLIFLUSH
|
2018-10-04 06:13:44 +00:00
|
|
|
|
.9 rts
|
2019-05-12 20:45:11 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
STDIO.IOERR lda #MLI.E.IO
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/-------------------------------------
|
|
|
|
|
* # FSeek
|
|
|
|
|
* Set the file-position indicator for hFILE
|
2018-07-25 15:26:14 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int fseek( short int stream, long offset, short int whence );`
|
2018-07-25 15:26:14 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* `>PUSHBI whence`
|
|
|
|
|
* `>PUSHL offset`
|
|
|
|
|
* `lda stream`
|
|
|
|
|
* `>SYSCALL fseek`
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\-------------------------------------
|
2018-08-08 15:13:37 +00:00
|
|
|
|
K.FSeek jsr PFT.CheckNodeA
|
2018-11-16 16:04:20 +00:00
|
|
|
|
bcc .11
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
|
|
|
|
>RET 5
|
|
|
|
|
|
2019-07-26 06:28:52 +00:00
|
|
|
|
.11 lda (pFD)
|
|
|
|
|
bne STDIO.IOERR
|
2019-07-27 20:51:39 +00:00
|
|
|
|
>PULLL ACC32
|
2019-09-24 15:25:07 +00:00
|
|
|
|
>PULLA whence
|
|
|
|
|
cmp #SEEK.END
|
2019-07-27 20:51:39 +00:00
|
|
|
|
beq .30
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bcs .98
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-09-24 15:25:07 +00:00
|
|
|
|
dec
|
2019-07-27 20:51:39 +00:00
|
|
|
|
beq .20
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-07-27 20:51:39 +00:00
|
|
|
|
stz K.MLI.PARAMS+2
|
2018-05-31 15:54:00 +00:00
|
|
|
|
stz K.MLI.PARAMS+3
|
|
|
|
|
stz K.MLI.PARAMS+4
|
2018-05-22 06:01:05 +00:00
|
|
|
|
bra .8
|
|
|
|
|
|
2018-10-02 15:52:30 +00:00
|
|
|
|
* SEEK.CUR
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.20 >MLICALL MLIGETMARK
|
|
|
|
|
bcc .8
|
|
|
|
|
rts
|
|
|
|
|
|
2018-10-02 15:52:30 +00:00
|
|
|
|
* SEEK.END
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.30 >MLICALL MLIGETEOF
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
.8 ldy #0
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
clc
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.81 lda K.MLI.PARAMS+2,y
|
2019-07-27 20:51:39 +00:00
|
|
|
|
adc ACC32,y
|
2018-05-31 15:54:00 +00:00
|
|
|
|
sta K.MLI.PARAMS+2,y
|
2018-05-25 15:09:14 +00:00
|
|
|
|
|
|
|
|
|
iny
|
2019-07-27 20:51:39 +00:00
|
|
|
|
tya 3 bytes, 24 bits!!!
|
|
|
|
|
eor #3
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bne .81
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bcs .99 Offset out of range!
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.82 >MLICALL MLISETMARK
|
|
|
|
|
bcc .9
|
|
|
|
|
cmp #MLI.E.BEYEOF
|
|
|
|
|
bne .9
|
|
|
|
|
>MLICALL MLISETEOF
|
|
|
|
|
bcc .82
|
|
|
|
|
.9 rts
|
|
|
|
|
|
2018-11-20 15:54:49 +00:00
|
|
|
|
.98 lda #E.BADARG
|
2017-08-24 06:47:31 +00:00
|
|
|
|
.HS 2C bit abs
|
2018-10-21 20:54:07 +00:00
|
|
|
|
.99 lda #E.FTB
|
2019-07-25 15:10:59 +00:00
|
|
|
|
* sec
|
2019-10-03 06:25:27 +00:00
|
|
|
|
K.FSeek.RTS rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
* # FEOF
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Test the end-of-file indicator for hFILE
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int feof( short int stream );`
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `lda stream`
|
|
|
|
|
* `>SYSCALL feof`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CC :
|
2019-05-02 09:52:32 +00:00
|
|
|
|
* A = $ff EOF
|
|
|
|
|
* A = 0 NOT EOF
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CS :
|
|
|
|
|
*\--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.FEOF jsr PFT.CheckNodeA
|
2019-06-28 15:15:58 +00:00
|
|
|
|
bcs K.FSeek.RTS
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-07-31 15:10:59 +00:00
|
|
|
|
IO.EOF lda (pFD)
|
|
|
|
|
tax
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.1 .DA IO.EOF.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
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FTell
|
|
|
|
|
* Return the current value of the file-position indicator
|
2018-07-25 15:26:14 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `long ftell( short int stream );`
|
2018-07-25 15:26:14 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* `lda stream`
|
|
|
|
|
* `>SYSCALL ftell`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* On stack (long)
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
2018-08-08 15:13:37 +00:00
|
|
|
|
K.FTell jsr PFT.CheckNodeA
|
2018-11-16 16:04:20 +00:00
|
|
|
|
bcs .9
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLIGETMARK
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bcs .9
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda #0
|
2018-08-08 15:13:37 +00:00
|
|
|
|
>PUSHA
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-08-08 15:13:37 +00:00
|
|
|
|
ldy #2
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 lda K.MLI.PARAMS+2,y
|
2018-08-08 15:13:37 +00:00
|
|
|
|
>PUSHA
|
2018-05-31 15:54:00 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
* # Remove
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* Remove a file or directory
|
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int remove ( const char *pathname );`
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
2020-05-20 13:14:28 +00:00
|
|
|
|
* `>LDYA pathname`
|
2018-10-04 06:13:44 +00:00
|
|
|
|
* `>SYSCALL remove`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
2020-05-20 13:14:28 +00:00
|
|
|
|
K.Remove jsr PFT.CheckPathYA
|
2018-11-16 16:04:20 +00:00
|
|
|
|
bcs .9
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLIDESTROY
|
2020-05-20 13:14:28 +00:00
|
|
|
|
.9 rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # Rename
|
|
|
|
|
* Rename a file
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* ## C
|
2020-08-02 12:19:43 +00:00
|
|
|
|
* `int rename ( const char * oldpath, const char * newpath );`
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* ## ASM
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2020-02-14 07:21:56 +00:00
|
|
|
|
* `>PUSHW oldpath`
|
2018-08-08 15:13:37 +00:00
|
|
|
|
* `>PUSHW newpath`
|
|
|
|
|
* `>SYSCALL rename`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
2020-02-14 07:21:56 +00:00
|
|
|
|
K.Rename jsr PFT.CheckPath2
|
2018-11-16 16:04:20 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2020-03-10 16:42:07 +00:00
|
|
|
|
lda (pStack)
|
|
|
|
|
sta ZPPtr1
|
|
|
|
|
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (pStack),y
|
|
|
|
|
sta ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
dey ldy #0
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-10-10 10:23:02 +00:00
|
|
|
|
.1 lda (ZPPtr1),y
|
2017-09-21 15:29:45 +00:00
|
|
|
|
beq .8
|
2019-10-10 10:23:02 +00:00
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
iny
|
2018-05-31 15:54:00 +00:00
|
|
|
|
sta K.Buf256,y
|
|
|
|
|
cpy #MLI.MAXPATH
|
|
|
|
|
bne .1
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.8 sty K.Buf256
|
|
|
|
|
>LDYAI K.Buf256
|
|
|
|
|
>STYA K.MLI.PARAMS+3
|
|
|
|
|
>MLICALL MLIRENAME
|
2020-03-10 16:42:07 +00:00
|
|
|
|
|
|
|
|
|
.9 >RET 4
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
2019-01-13 13:10:14 +00:00
|
|
|
|
* K.Buf256 = filepath
|
2018-10-03 15:25:03 +00:00
|
|
|
|
* X = hFD
|
|
|
|
|
*--------------------------------------
|
2020-03-11 16:41:45 +00:00
|
|
|
|
STDIO.NewHFile ldx #1
|
2020-07-10 13:59:56 +00:00
|
|
|
|
|
2019-02-27 15:00:56 +00:00
|
|
|
|
.1 lda OF.Table.hFD-1,x
|
2018-10-03 15:25:03 +00:00
|
|
|
|
beq .2
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-10-03 15:25:03 +00:00
|
|
|
|
inx
|
2019-02-27 15:00:56 +00:00
|
|
|
|
cpx #K.OF.MAX+1
|
2018-10-03 15:25:03 +00:00
|
|
|
|
bne .1
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2018-10-21 20:54:07 +00:00
|
|
|
|
lda #E.OOH
|
2019-10-03 06:25:27 +00:00
|
|
|
|
* sec
|
2018-10-03 15:25:03 +00:00
|
|
|
|
rts
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-03-11 16:41:45 +00:00
|
|
|
|
.2 stx .4+1
|
|
|
|
|
|
|
|
|
|
ldx #0
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-02-18 06:42:17 +00:00
|
|
|
|
lda (pFD)
|
2019-01-13 13:10:14 +00:00
|
|
|
|
cmp #S.FD.T.CDEV
|
2020-03-11 16:41:45 +00:00
|
|
|
|
beq .3
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-02-18 06:42:17 +00:00
|
|
|
|
cmp #S.FD.T.BDEV
|
2020-03-11 16:41:45 +00:00
|
|
|
|
beq .3 No hPath for DEV
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2020-03-11 16:41:45 +00:00
|
|
|
|
>LDYAI K.buf256
|
2020-03-10 16:42:07 +00:00
|
|
|
|
>SYSCALL2 StrDup
|
2018-10-03 15:25:03 +00:00
|
|
|
|
bcs .9
|
2019-02-18 06:42:17 +00:00
|
|
|
|
|
2020-03-11 16:41:45 +00:00
|
|
|
|
.3 txa
|
|
|
|
|
|
|
|
|
|
.4 ldx #$ff SELF MODIFIED
|
2019-02-27 15:00:56 +00:00
|
|
|
|
sta OF.Table.hPath-1,x
|
2020-03-11 16:41:45 +00:00
|
|
|
|
lda IO.hFD
|
2019-02-27 15:00:56 +00:00
|
|
|
|
sta OF.Table.hFD-1,x
|
2018-10-03 15:25:03 +00:00
|
|
|
|
txa hFILE
|
2019-05-12 20:45:11 +00:00
|
|
|
|
|
2019-02-27 15:00:56 +00:00
|
|
|
|
clc
|
2018-10-03 15:25:03 +00:00
|
|
|
|
.9 rts
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-23 15:05:29 +00:00
|
|
|
|
MAN
|
2020-05-26 14:23:09 +00:00
|
|
|
|
SAVE usr/src/sys/kernel.s.stdio
|
|
|
|
|
LOAD usr/src/sys/kernel.s
|
2017-08-23 15:05:29 +00:00
|
|
|
|
ASM
|