2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2017-08-23 15:05:29 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # FPutC
|
2018-05-29 15:31:44 +00:00
|
|
|
|
* Print A (char) to hFILE
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int fputc ( int character, hFILE stream );`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-19 15:08:22 +00:00
|
|
|
|
* A : character
|
|
|
|
|
* Y : stream
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* CC = success
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-19 15:08:22 +00:00
|
|
|
|
K.FPutC sta K.IOBuf
|
|
|
|
|
tya
|
2018-06-18 06:22:50 +00:00
|
|
|
|
bra K.PutChar.1
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # PutChar
|
|
|
|
|
* ## C
|
|
|
|
|
* `int putchar ( int character );`
|
|
|
|
|
* ## ASM
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* Print A (char) to StdOut
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* A : char to print
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* CC = success
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
K.PutChar sta K.IOBuf
|
2018-05-29 15:31:44 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
ldy #S.PS.hStdOut
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
|
2018-06-19 15:08:22 +00:00
|
|
|
|
K.PutChar.1 jsr IO.SELECT
|
|
|
|
|
|
|
|
|
|
ldx #1
|
|
|
|
|
|
|
|
|
|
K.PutChar.X >LDYAI K.IOBuf
|
|
|
|
|
>STYA K.S.IOCTL+S.IOCTL.BUFPTR
|
|
|
|
|
stx K.S.IOCTL+S.IOCTL.BYTECNT
|
2018-06-22 06:24:35 +00:00
|
|
|
|
stz K.S.IOCTL+S.IOCTL.BYTECNT+1
|
2018-06-19 15:08:22 +00:00
|
|
|
|
jmp IO.WRITE
|
2018-05-29 15:31:44 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # PutS
|
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-06-19 15:08:22 +00:00
|
|
|
|
* Y,A : str
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* CC = success
|
2018-05-29 15:31:44 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-19 15:08:22 +00:00
|
|
|
|
K.PutS >STYA K.S.IOCTL+S.IOCTL.BUFPTR
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2018-05-29 15:31:44 +00:00
|
|
|
|
ldy #S.PS.hStdOut
|
|
|
|
|
lda (pPs),y
|
2018-06-19 15:08:22 +00:00
|
|
|
|
jsr K.FPutS.I
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda #13
|
2018-06-19 15:08:22 +00:00
|
|
|
|
sta K.IOBuf
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda #10
|
2018-06-19 15:08:22 +00:00
|
|
|
|
sta K.IOBuf+1
|
|
|
|
|
ldx #2
|
|
|
|
|
bra K.PutChar.X
|
2018-05-29 15:31:44 +00:00
|
|
|
|
.9 rts
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # FPutS
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Write Str to FILE
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int fputs ( const char * str, hFILE stream );`
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* PUSHB : hFILE
|
|
|
|
|
* Y,A: str
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* CC = success
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-19 15:08:22 +00:00
|
|
|
|
K.FPutS >STYA K.S.IOCTL+S.IOCTL.BUFPTR
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>PULLA
|
|
|
|
|
|
2018-06-19 15:08:22 +00:00
|
|
|
|
K.FPutS.I jsr IO.SELECT
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-06-19 15:08:22 +00:00
|
|
|
|
ldy #0
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldx #0
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-06-19 15:08:22 +00:00
|
|
|
|
.1 lda (ZPPtr1),y
|
2018-05-31 15:54:00 +00:00
|
|
|
|
beq .2
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
iny
|
|
|
|
|
bne .1
|
|
|
|
|
inx
|
2018-06-19 15:08:22 +00:00
|
|
|
|
inc ZPPtr1+1
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bra .1
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-06-19 15:08:22 +00:00
|
|
|
|
.2 sty K.S.IOCTL+S.IOCTL.BYTECNT
|
2018-06-22 06:24:35 +00:00
|
|
|
|
stx K.S.IOCTL+S.IOCTL.BYTECNT+1
|
2018-06-19 15:08:22 +00:00
|
|
|
|
jmp IO.WRITE
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # PrintF/SPrintF/FPrintF
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Prints C-Style String
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int printf ( const char * format, ... );`
|
|
|
|
|
* `int sprintf ( char * str, const char * format, ... );`
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* `int fprintf ( hFILE stream, const char * format, ... );`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* PrintF : (example is for printing Y,A as integer : format="Y,A= %I", 2 bytes)
|
|
|
|
|
* `>PUSHYA`
|
|
|
|
|
* `>PUSHBI 2`
|
|
|
|
|
* `>LDYAI format`
|
|
|
|
|
* `>SYSCALL printf`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* SPrintF :
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* `>PUSHYA`
|
|
|
|
|
* `>PUSHBI 2`
|
|
|
|
|
* `>PUSHWI format`
|
|
|
|
|
* `>LDYAI str`
|
|
|
|
|
* `>SYSCALL sprintf`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* FPrintF :
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* `>PUSHYA`
|
|
|
|
|
* `>PUSHBI 2`
|
|
|
|
|
* `>PUSHWI format`
|
|
|
|
|
* `lda hFILE`
|
|
|
|
|
* `>SYSCALL fprintf`
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* CC : success, Y,A = bytes sent
|
|
|
|
|
* CS : error, A = code from Output
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Specifiers :
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* + %b : pull 1 byte to Print BIN
|
|
|
|
|
* + %B : pull 2 bytes to Print BIN
|
|
|
|
|
* + %d : pull 1 byte unsigned DEC 0..255
|
|
|
|
|
* + %D : pull 2 bytes unsigned DEC 0..65535
|
|
|
|
|
* + %u : pull 4 bytes long unsigned DEC 0..4294967295
|
|
|
|
|
* + %e : pull 5 Bytes float (-)1.23456789e+12
|
|
|
|
|
* + %f : pull 5 Bytes float (-)3.1415
|
|
|
|
|
* + %h : pull 1 byte to Print HEX
|
|
|
|
|
* + %H : pull 2 bytes to Print HEX
|
|
|
|
|
* + %i : pull 1 byte to Print signed DEC -128..127
|
|
|
|
|
* + %I : pull 2 bytes to Print signed DEC -32768..32767
|
|
|
|
|
* + %L : pull 4 bytes signed DEC -2147483648..2147483647
|
|
|
|
|
* + %n : pull 1 byte to Print low Nibble HEX
|
|
|
|
|
* + %N : pull 1 byte to Print high Nibble HEX
|
|
|
|
|
* + %s : pull 2 bytes ptr to C-Style String
|
|
|
|
|
* + %S : pull 2 bytes ptr to P-Style String
|
|
|
|
|
* + \b : Print 'BS' (08)
|
|
|
|
|
* + \e : Print 'ESC' ($1B,27)
|
|
|
|
|
* + \f : Print 'FF' ($0C,12)
|
|
|
|
|
* + \n : Print 'LF' ($0A,10)
|
|
|
|
|
* + \r : Print 'CR' ($0D,13)
|
|
|
|
|
* + \\\\ : Print \
|
|
|
|
|
* + \\% : Print %
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Modifiers for len and padding :
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* + %d : '9' '12'
|
|
|
|
|
* + %2d : ' 9' '12'
|
|
|
|
|
* + %02d : '09' '12'
|
|
|
|
|
* + %11s : 'ABCDEFGH '
|
|
|
|
|
* + %011s : 'ABCDEFGH000'
|
|
|
|
|
* + %2f : '3.14'
|
2017-08-24 12:46:48 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
K.SPrintF >STYA pIOBuf Out Buffer
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>PULLW ZPPtr1 format
|
|
|
|
|
bra K.PrintF.1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-06-19 15:08:22 +00:00
|
|
|
|
K.FPrintF jsr IO.SELECT A = hFILE
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>PULLW ZPPtr1 format
|
2018-06-08 14:42:11 +00:00
|
|
|
|
bra K.PrintF.0
|
2018-05-31 15:54:00 +00:00
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
K.PrintF >STYA ZPPtr1 format
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldy #S.PS.hStdOut
|
|
|
|
|
lda (pPs),y
|
2018-06-19 15:08:22 +00:00
|
|
|
|
jsr IO.SELECT
|
2018-06-08 14:42:11 +00:00
|
|
|
|
|
|
|
|
|
K.PrintF.0 >LDYAI K.IOBuf
|
|
|
|
|
>STYA pIOBuf
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
K.PrintF.1 ldy #0
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
iny
|
|
|
|
|
cmp #'%'
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
stz K.PrintF.PadL
|
|
|
|
|
lda #' '
|
|
|
|
|
sta K.PrintF.PadC
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.2 ldx #PrintFTBL2-PrintFTBL1-1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
iny
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.3 cmp PrintFTBL1,x do we have a %x command?
|
|
|
|
|
beq .8 yes, jmp to it!
|
2017-08-24 12:46:48 +00:00
|
|
|
|
dex
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bpl .3 no valid letter...
|
|
|
|
|
|
|
|
|
|
cmp #'0' ...a 0...mmm... padding char?
|
|
|
|
|
bne .4
|
|
|
|
|
|
2018-06-18 08:44:02 +00:00
|
|
|
|
ldx K.PrintF.PadL K.PrintF.PadL is not nul, so this 0 is second digit
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
* lda #'0'
|
2018-06-18 08:44:02 +00:00
|
|
|
|
sta K.PrintF.PadC no, this is the first 0, so make it K.PrintF.PadC
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bra .2
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.4 jsr MEM.IsDigit
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
.5 and #$0F we have a digit
|
|
|
|
|
pha save it...
|
|
|
|
|
lda K.PrintF.PadL starts K.PrintF.PadL * 10
|
|
|
|
|
asl
|
|
|
|
|
asl A=times 4
|
|
|
|
|
adc K.PrintF.PadL CC by ASL, A=times 5
|
|
|
|
|
asl times 10
|
|
|
|
|
sta K.PrintF.PadL
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
pla get back digit
|
|
|
|
|
adc K.PrintF.PadL
|
|
|
|
|
sta K.PrintF.PadL
|
|
|
|
|
bra .2 go get next char...
|
|
|
|
|
|
|
|
|
|
.8 phy
|
|
|
|
|
txa
|
|
|
|
|
asl
|
|
|
|
|
tax
|
2018-06-08 14:42:11 +00:00
|
|
|
|
jsr PrintF.ESC
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ply
|
|
|
|
|
bcc .1
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.10 cmp #'\'
|
|
|
|
|
bne .20
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldx #PrintFTBL2.OUT-PrintFTBL2-1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
iny
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.12 cmp PrintFTBL2,x
|
|
|
|
|
beq .13
|
|
|
|
|
dex
|
|
|
|
|
bpl .12
|
|
|
|
|
bra .1
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.13 lda PrintFTBL2.OUT,x
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-06-08 14:42:11 +00:00
|
|
|
|
.20 jsr PrintF.COut
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bcc .1
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2018-06-08 14:42:11 +00:00
|
|
|
|
PrintF.ESC jmp (.1,x)
|
|
|
|
|
.1 .DA PrintF.B,PrintF.BB
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.DA PrintF.D,PrintF.DD,PrintF.U
|
|
|
|
|
.DA PrintF.E,PrintF.F
|
|
|
|
|
.DA PrintF.H,PrintF.HH
|
|
|
|
|
.DA PrintF.I,PrintF.II,PrintF.L
|
|
|
|
|
.DA PrintF.N,PrintF.NN
|
|
|
|
|
.DA PrintF.S,PrintF.SS
|
|
|
|
|
*--------------------------------------
|
2018-06-08 14:42:11 +00:00
|
|
|
|
PrintFTBL1 .AS "bBdDuefhHiILnNsS"
|
|
|
|
|
PrintFTBL2 .AS "befnr\%"
|
|
|
|
|
PrintFTBL2.OUT .HS 08.1B.0C.0A.0D \b\e\f\n\r
|
|
|
|
|
.DA #'\' \\
|
|
|
|
|
.DA #'%' \%
|
|
|
|
|
*--------------------------------------
|
2018-05-31 15:54:00 +00:00
|
|
|
|
PrintF.BB >PULLA
|
|
|
|
|
pha
|
|
|
|
|
jsr PrintF.B
|
|
|
|
|
pla
|
|
|
|
|
bcc PrintF.B.1
|
|
|
|
|
PrintF.BB.RTS rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.B >PULLA
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
PrintF.B.1 ldx #8
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 asl
|
|
|
|
|
pha
|
|
|
|
|
lda #'0'
|
|
|
|
|
adc #0 add Carry
|
2018-06-08 14:42:11 +00:00
|
|
|
|
jsr PrintF.COut
|
2018-05-31 15:54:00 +00:00
|
|
|
|
pla
|
|
|
|
|
bcs PrintF.BB.RTS
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.I sec signed short
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.D clc unsigned short (BYTE)
|
|
|
|
|
ldx #0 one byte
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>PULLB HEXBUF
|
|
|
|
|
stz HEXBUF+1
|
|
|
|
|
bra PrintF.DD.1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
PrintF.II sec signed int
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.DD clc unsigned int (WORD)
|
|
|
|
|
ldx #1 two bytes
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>PULLW HEXBUF
|
|
|
|
|
|
|
|
|
|
PrintF.DD.1 stz HEXBUF+2
|
|
|
|
|
stz HEXBUF+3
|
|
|
|
|
bra PrintF.U.1
|
|
|
|
|
|
|
|
|
|
PrintF.L sec signed long
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.U clc unsigned long (DWORD)
|
|
|
|
|
ldx #3 4 bytes
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>PULLW HEXBUF
|
|
|
|
|
>PULLW HEXBUF+2
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
PrintF.U.1 bcc PrintF.Hex2Dec unsigned, nothing to check
|
|
|
|
|
|
|
|
|
|
lda HEXBUF,x get sign
|
|
|
|
|
bpl PrintF.Hex2Dec
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* sec
|
|
|
|
|
|
|
|
|
|
ldy #0
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 lda HEXBUF,y two's complement of X bytes
|
|
|
|
|
eor #$ff
|
|
|
|
|
adc #0
|
|
|
|
|
sta HEXBUF,y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
sec tell to print a "-" sign....
|
2017-08-24 12:46:48 +00:00
|
|
|
|
*--------------------------------------
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Convert HEXBUF to ASCBUF decimal padded with 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.Hex2Dec ror .31+1
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldx #4
|
|
|
|
|
|
|
|
|
|
.1 stz BCDBUF,x Clear all 5 bytes
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
sed switch to BCD mode
|
|
|
|
|
|
|
|
|
|
ldx #32 let's roll 32 bits
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.2 asl HEXBUF
|
|
|
|
|
rol HEXBUF+1
|
|
|
|
|
rol HEXBUF+2
|
|
|
|
|
rol HEXBUF+3
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldy #4
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.3 lda BCDBUF,y
|
|
|
|
|
adc BCDBUF,y
|
|
|
|
|
sta BCDBUF,y
|
|
|
|
|
dey
|
|
|
|
|
bpl .3
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
dex
|
|
|
|
|
bne .2
|
2018-04-16 15:25:39 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
cld
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.31 bit #$ff SELF MODIFIED -sign to print before digits ?
|
|
|
|
|
bpl .9
|
|
|
|
|
lda #'-'
|
2018-06-08 14:42:11 +00:00
|
|
|
|
jsr PrintF.COut
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.9 lda K.PrintF.PadL any Len format ?
|
|
|
|
|
beq .4 no
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda #10
|
|
|
|
|
sec yes, Print only digits starting at pos 10-K.PrintF.PadL
|
|
|
|
|
sbc K.PrintF.PadL
|
|
|
|
|
|
|
|
|
|
.4 tax x=0 if no K.PrintF.PadL, or x=10-K.PrintF.PadL
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.5 txa X range 0 to 9
|
|
|
|
|
lsr CS if lo nibble (1,3,5,7,9)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
lda BCDBUF,y
|
|
|
|
|
|
|
|
|
|
bcs .6
|
|
|
|
|
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
|
|
|
|
|
.6 and #$0F
|
|
|
|
|
ora #$30
|
|
|
|
|
cmp #$30
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
beq .7 a zero?
|
|
|
|
|
|
|
|
|
|
inc K.PrintF.PadL found a non zero, Print all digits, even if 0, next time
|
|
|
|
|
ldy #'0'
|
|
|
|
|
sty K.PrintF.PadC
|
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.7 cpx #9 last digit ?
|
|
|
|
|
beq .8 Print always
|
|
|
|
|
|
|
|
|
|
ldy K.PrintF.PadL no pad to fill, do not Print 0
|
|
|
|
|
beq .10
|
|
|
|
|
|
|
|
|
|
lda K.PrintF.PadC fill with K.PrintF.PadC
|
|
|
|
|
|
2018-06-08 14:42:11 +00:00
|
|
|
|
.8 jsr PrintF.COut
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bcs .99
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.10 inx
|
|
|
|
|
cpx #10
|
|
|
|
|
bne .5
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
clc
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* EXP(8) 1(s) 1significants(31)
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* http://apple2.org.za/gswv/a2zine/GS.WorldView/Resources/GS.TECH.INFO/AppleSoft/
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.E sec Force "E+12"
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.F clc
|
|
|
|
|
lda pStack+1
|
|
|
|
|
sta INDEX+1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda pStack
|
|
|
|
|
sta INDEX
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
clc
|
|
|
|
|
adc #5
|
|
|
|
|
sta pStack
|
2018-06-13 15:18:08 +00:00
|
|
|
|
|
|
|
|
|
ldx #ROM.SETFAC
|
|
|
|
|
jsr GP.ROMCALL
|
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldy #3 In order not to trash A2osX.SaveSM,A2osX.SaveSX
|
2018-06-13 15:18:08 +00:00
|
|
|
|
ldx #ROM.FOUT
|
|
|
|
|
jsr GP.ROMCALL
|
2018-05-31 15:54:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.2 lda $102,y
|
|
|
|
|
beq .8
|
|
|
|
|
|
2018-06-08 14:42:11 +00:00
|
|
|
|
jsr PrintF.COut
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
iny
|
|
|
|
|
bne .2
|
2017-12-12 16:35:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.9 rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.HH >PULLA
|
|
|
|
|
pha
|
|
|
|
|
jsr PrintF.H
|
|
|
|
|
pla
|
|
|
|
|
bra PrintF.H.1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.H >PULLA
|
|
|
|
|
PrintF.H.1 pha
|
|
|
|
|
jsr PrintF.NN.1
|
|
|
|
|
pla
|
|
|
|
|
bra PrintF.N.1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.N >PULLA
|
|
|
|
|
PrintF.N.1 and #$0F
|
|
|
|
|
bra PrintF.NN.2
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
PrintF.NN >PULLA
|
|
|
|
|
PrintF.NN.1 lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
|
|
|
|
|
PrintF.NN.2 ora #$30
|
|
|
|
|
cmp #$3A
|
|
|
|
|
bcc .1
|
|
|
|
|
adc #6
|
2018-06-08 14:42:11 +00:00
|
|
|
|
.1 jmp PrintF.COut
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.S ldy #$ff CSTR
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.HS 2C bit abs
|
2018-05-31 15:54:00 +00:00
|
|
|
|
PrintF.SS ldy #$00 PSTR
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>PULLW ZPPtr2
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2) if CSTR:last char=0, if PSTR:len=0
|
|
|
|
|
beq .8
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
sty .1+1
|
|
|
|
|
|
|
|
|
|
.1 lda #$ff Self Modified
|
|
|
|
|
bne .11 CSTR
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
tya PSTR
|
|
|
|
|
cmp (ZPPtr2) len check
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
.11 iny
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
beq .2
|
|
|
|
|
|
2018-06-08 14:42:11 +00:00
|
|
|
|
jsr PrintF.COut
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda K.PrintF.PadL
|
|
|
|
|
beq .1
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
cpy K.PrintF.PadL
|
|
|
|
|
bne .1
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 lda K.PrintF.PadL
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
.3 cpy K.PrintF.PadL
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda K.PrintF.PadC
|
2018-06-08 14:42:11 +00:00
|
|
|
|
jsr PrintF.COut
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
iny
|
|
|
|
|
bne .3
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-08 14:42:11 +00:00
|
|
|
|
PrintF.COut phy
|
|
|
|
|
|
2018-06-22 06:24:35 +00:00
|
|
|
|
ldy S.IOCTL.BYTECNT
|
2018-06-08 14:42:11 +00:00
|
|
|
|
sta (pIOBuf),y
|
2018-06-22 06:24:35 +00:00
|
|
|
|
inc S.IOCTL.BYTECNT
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
lda pIOBuf+1
|
2018-06-08 14:42:11 +00:00
|
|
|
|
eor /K.IOBuf
|
|
|
|
|
bne .7
|
|
|
|
|
|
|
|
|
|
* we are printing to IObuf, flush!
|
|
|
|
|
|
2018-06-22 06:24:35 +00:00
|
|
|
|
lda S.IOCTL.BYTECNT+1
|
2018-06-08 14:42:11 +00:00
|
|
|
|
pha
|
|
|
|
|
lda #1 Flush $100 bytes
|
2018-06-22 06:24:35 +00:00
|
|
|
|
sta S.IOCTL.BYTECNT+1
|
2018-05-31 15:54:00 +00:00
|
|
|
|
|
2018-06-08 14:42:11 +00:00
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
inc
|
2018-06-22 06:24:35 +00:00
|
|
|
|
sta S.IOCTL.BYTECNT+1
|
2018-06-08 14:42:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.7 inc pIOBuf+1
|
2018-06-22 06:24:35 +00:00
|
|
|
|
inc S.IOCTL.BYTECNT+1
|
2018-06-08 14:42:11 +00:00
|
|
|
|
|
|
|
|
|
.8 ply
|
2018-05-31 15:54:00 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-10-09 15:30:48 +00:00
|
|
|
|
*/--------------------------------------
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* # GetChar
|
|
|
|
|
* Get char from StdIn
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* none.
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
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
|
|
|
|
|
lda (pPs),y
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # GetC
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Get char from Node
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int getc ( FILE * stream );`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* A = hNODE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CC = success
|
|
|
|
|
* A = char
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-22 14:59:24 +00:00
|
|
|
|
K.GetC jsr K.GetMemPtr
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>STYA pDev
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.T
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda (pDev),y
|
|
|
|
|
asl
|
|
|
|
|
tax
|
|
|
|
|
jmp (.1,x)
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 .DA K.GetC.REG
|
|
|
|
|
.DA STDIO.IOERR DIR
|
|
|
|
|
.DA K.GetC.CDEV
|
|
|
|
|
.DA STDIO.IOERR BDEV
|
|
|
|
|
.DA STDIO.IOERR LNK
|
|
|
|
|
.DA STDIO.IOERR DSOCK
|
|
|
|
|
.DA K.GetC.SSOCK
|
|
|
|
|
.DA K.GetC.FIFO
|
|
|
|
|
*--------------------------------------
|
2018-06-08 14:42:11 +00:00
|
|
|
|
K.GetC.REG >PUSHWI K.IOBuf
|
|
|
|
|
>PUSHWI 1
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.REG.REF
|
2018-06-08 14:42:11 +00:00
|
|
|
|
>PUSHB (pDev),y
|
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
jsr K.FRead
|
|
|
|
|
bcs .9
|
|
|
|
|
lda K.Buf256
|
|
|
|
|
.9 rts
|
2018-05-22 06:01:05 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-22 14:59:24 +00:00
|
|
|
|
K.GetC.CDEV ldx #IOCTL.READ
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.DEV.DRVPTR
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda (pDev),y
|
|
|
|
|
sta .1+1
|
|
|
|
|
iny
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
sta .1+2
|
|
|
|
|
.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
2018-07-10 15:33:13 +00:00
|
|
|
|
K.GetC.SSOCK lda (pDev) #S.FD.HANDLER
|
2018-06-21 15:12:10 +00:00
|
|
|
|
* jsr K.GetMemPtr
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* >STYA .1+1
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
* ldy #S.FD.SSOCK.READ
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* lda (pDev),y
|
|
|
|
|
* tax Function Offset for READ
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
* ldy #S.FD.SSOCK.HSKT
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* lda (pDev),y
|
|
|
|
|
|
|
|
|
|
*.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.GetC.FIFO
|
|
|
|
|
bra *
|
|
|
|
|
*--------------------------------------
|
2018-05-25 15:09:14 +00:00
|
|
|
|
*K.PrintF.PadL .BS 1
|
|
|
|
|
*K.PrintF.PadC .BS 1
|
2018-05-22 06:01:05 +00:00
|
|
|
|
*HEXBUF .BS 4
|
|
|
|
|
*BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
2018-05-25 15:09:14 +00:00
|
|
|
|
*--------------------------------------
|
2018-05-22 06:01:05 +00:00
|
|
|
|
HEXBUF .EQ FAC
|
2018-05-25 15:09:14 +00:00
|
|
|
|
K.PrintF.PadL .EQ FAC+4
|
|
|
|
|
K.PrintF.PadC .EQ FAC+5
|
2018-05-22 06:01:05 +00:00
|
|
|
|
BCDBUF .EQ ARG
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # SScanF
|
|
|
|
|
* Read formatted data from string
|
|
|
|
|
* ## C
|
|
|
|
|
* `int sscanf ( const char * s, const char * format, ...);`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* `>PUSHBI Argument Byte count`
|
|
|
|
|
* `>PUSHWI format`
|
|
|
|
|
* + %i : short int
|
|
|
|
|
* + %d : byte
|
|
|
|
|
* + %I : int
|
|
|
|
|
* + %D : word
|
|
|
|
|
* + %L : long int
|
|
|
|
|
* + %U : dword
|
|
|
|
|
* + %h : HEX byte
|
|
|
|
|
* + %H : HEX word
|
|
|
|
|
* `>LDYA s`
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* Y,A = Number of arguments filled.
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
K.SScanF >STYA ZPPtr2 String to Scan
|
|
|
|
|
>PULLW ZPPtr1 format
|
|
|
|
|
>PULLB K.SScanF.ByteCnt
|
|
|
|
|
stz K.SScanF.ByteIdx
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
.1 lda (ZPPtr1) End Of format?
|
2018-05-23 15:27:37 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
inc ZPPtr1
|
2018-05-23 15:27:37 +00:00
|
|
|
|
bne .11
|
2017-08-24 06:47:31 +00:00
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
|
2018-05-23 15:27:37 +00:00
|
|
|
|
.11 cmp #'%' Escape?
|
2017-08-24 06:47:31 +00:00
|
|
|
|
beq .2
|
|
|
|
|
|
2018-05-23 15:27:37 +00:00
|
|
|
|
cmp (ZPPtr2) Same char in string?
|
|
|
|
|
bne .9
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-23 15:27:37 +00:00
|
|
|
|
inc ZPPtr2
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bne .1
|
2018-05-23 15:27:37 +00:00
|
|
|
|
inc ZPPtr2+1
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2018-05-23 15:27:37 +00:00
|
|
|
|
.2 lda (ZPPtr1) Get specifier after %
|
2018-06-18 06:22:50 +00:00
|
|
|
|
beq .9 unexpected End of format after "%" ?
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-23 15:27:37 +00:00
|
|
|
|
inc ZPPtr1
|
|
|
|
|
bne .21
|
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
.21 ldx #K.SScanFJMP-K.SScanFTBL-2
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-23 15:27:37 +00:00
|
|
|
|
.3 cmp K.SScanFTBL,x
|
|
|
|
|
beq .4
|
|
|
|
|
dex
|
|
|
|
|
dex
|
|
|
|
|
bpl .3
|
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
.9 jsr .8
|
|
|
|
|
lda #MLI.E.EOF
|
2018-05-23 15:27:37 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.4 jsr .5
|
2018-06-18 06:22:50 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2018-06-18 06:22:50 +00:00
|
|
|
|
.8 lda pStack
|
|
|
|
|
clc
|
|
|
|
|
adc K.SScanF.ByteCnt
|
|
|
|
|
sta pStack CC
|
|
|
|
|
.99 rts
|
2018-05-23 15:27:37 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
.5 ldy K.SScanF.ByteIdx
|
|
|
|
|
cpy K.SScanF.ByteCnt
|
|
|
|
|
beq .99 CS
|
|
|
|
|
|
|
|
|
|
lda (pStack),y
|
|
|
|
|
sta ZPPtr3
|
|
|
|
|
iny
|
|
|
|
|
lda (pStack),y
|
|
|
|
|
sta ZPPtr3+1 get VAR Ptr
|
|
|
|
|
iny
|
|
|
|
|
sty K.SScanF.ByteIdx
|
|
|
|
|
|
2018-05-24 15:21:38 +00:00
|
|
|
|
lda K.SScanFTBL+1,x Get VAR size
|
2018-05-23 15:27:37 +00:00
|
|
|
|
jmp (K.SScanFJMP,x)
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
K.SScanF.ByteCnt .BS 1
|
|
|
|
|
K.SScanF.ByteIdx .BS 1
|
|
|
|
|
*--------------------------------------
|
2018-05-25 15:09:14 +00:00
|
|
|
|
K.SScanFTBL .DA #'i,#1,#'d,#1,#'I,#2,#'D,#2,#'l,#4,#'u,#4,#'h,#1,#'H,#2
|
2018-05-23 15:27:37 +00:00
|
|
|
|
K.SScanFJMP .DA K.SScanF.I
|
|
|
|
|
.DA K.SScanF.D
|
|
|
|
|
.DA K.SScanF.II
|
|
|
|
|
.DA K.SScanF.DD
|
|
|
|
|
.DA K.SScanF.L
|
|
|
|
|
.DA K.SScanF.U
|
2018-05-25 15:09:14 +00:00
|
|
|
|
.DA K.SScanF.H
|
|
|
|
|
.DA K.SScanF.HH
|
2018-05-23 15:27:37 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.SScanF.I
|
|
|
|
|
K.SScanF.D
|
|
|
|
|
K.SScanF.II
|
|
|
|
|
K.SScanF.DD
|
|
|
|
|
K.SScanF.L
|
2018-05-24 15:21:38 +00:00
|
|
|
|
K.SScanF.U pha Save VAL size
|
2018-05-23 15:27:37 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
jsr STDLIB.GetDec
|
|
|
|
|
bra K.SScanF.GetVAL
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.SScanF.HH
|
|
|
|
|
K.SScanF.H pha
|
2018-05-28 06:00:45 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
jsr STDLIB.GetHex
|
|
|
|
|
|
|
|
|
|
K.SScanF.GetVAL tya Y=char count parsed
|
2018-05-24 15:21:38 +00:00
|
|
|
|
clc
|
|
|
|
|
adc ZPPtr2
|
|
|
|
|
sta ZPPtr2
|
|
|
|
|
bcc .1
|
|
|
|
|
inc ZPPtr2+1
|
2018-05-23 15:27:37 +00:00
|
|
|
|
|
2018-05-24 15:21:38 +00:00
|
|
|
|
.1 ply get back VAL size
|
|
|
|
|
|
|
|
|
|
.2 lda STDLIB.32-1,y
|
2018-05-23 15:27:37 +00:00
|
|
|
|
dey
|
|
|
|
|
sta (ZPPtr3),y
|
2018-05-25 15:09:14 +00:00
|
|
|
|
bne .2
|
2018-05-23 15:27:37 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*/--------------------------------------
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* # FOpen
|
|
|
|
|
* Open a file
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `hFILE fopen ( const char * filename, short int mode, short int ftype, int auxtype );`
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## ASM
|
|
|
|
|
* `>PUSHWI auxtype`
|
|
|
|
|
* `>PUSHBI ftype`
|
|
|
|
|
* `>PUSHBI mode`
|
|
|
|
|
* + SYS.FOpen.R : if R and !exists -> ERROR
|
|
|
|
|
* + SYS.FOpen.W : if W and !exists -> CREATE
|
|
|
|
|
* + SYS.FOpen.A : Append
|
|
|
|
|
* + SYS.FOpen.T : Open/Append in Text mode
|
|
|
|
|
* + SYS.FOpen.X : Create if not exists
|
|
|
|
|
* `>LDYAI filename`
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **Out:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CC : A = hFILE
|
|
|
|
|
* CS : A = EC
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*\--------------------------------------
|
2018-05-31 15:54:00 +00:00
|
|
|
|
K.FOpen jsr PFT.CheckPathSTK
|
|
|
|
|
jsr STDIO.PullMLIPath
|
|
|
|
|
>PULLB K.FOpen.MODE
|
|
|
|
|
>PULLB K.FOpen.TYPE
|
|
|
|
|
>PULLW K.FOpen.AUXTYPE
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLIGETFILEINFO
|
|
|
|
|
bcc K.FOpen.10 Already Exists
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bit K.FOpen.MODE Create if not exists ?
|
|
|
|
|
bpl K.FOpen.9 No, return MLI error
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
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
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldx #3
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 lda DATELO,x
|
|
|
|
|
sta K.MLI.PARAMS+8,x
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLICREATE
|
|
|
|
|
bcc K.FOpen.10
|
|
|
|
|
K.FOpen.9 rts
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
K.FOpen.10 >LDYAI S.FD.REG
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMem0
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bcs K.FOpen.9
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
stx .8+1
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
* ldy #S.FD.T Done by GetMem0
|
|
|
|
|
* lda #S.FD.T.REG
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* sta (ZPPtr1),y
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
jsr STDIO.SetIOBUF
|
|
|
|
|
bcs .98
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLIOPEN
|
|
|
|
|
bcs .98
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda K.MLI.PARAMS+5 get ref_num
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.REG.REF
|
2018-05-31 15:54:00 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda K.FOpen.MODE
|
|
|
|
|
bit #SYS.FOpen.W
|
|
|
|
|
beq .20 Write mode ?
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
and #SYS.FOpen.A Append ?
|
|
|
|
|
bne .11 yes, go to end of file
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
stz K.MLI.PARAMS+2
|
|
|
|
|
stz K.MLI.PARAMS+3
|
|
|
|
|
stz K.MLI.PARAMS+4
|
|
|
|
|
>MLICALL MLISETEOF no, reset size to 0
|
|
|
|
|
bra .21
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.11 >MLICALL MLIGETEOF
|
|
|
|
|
bcs .98
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLISETMARK
|
|
|
|
|
.21 bcs .98
|
|
|
|
|
|
|
|
|
|
.20 lda K.FOpen.MODE
|
|
|
|
|
and #SYS.FOpen.T Text Mode ?
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda #$FF
|
|
|
|
|
sta K.MLI.PARAMS+2
|
|
|
|
|
lda #$0D
|
|
|
|
|
sta K.MLI.PARAMS+3
|
|
|
|
|
>MLICALL MLINEWLINE
|
|
|
|
|
|
|
|
|
|
.8 lda #$ff Self Modified
|
|
|
|
|
clc
|
|
|
|
|
rts CC
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.98 pha save MLI error
|
|
|
|
|
lda .8+1
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jsr K.FClose
|
2018-05-31 15:54:00 +00:00
|
|
|
|
pla get back MLI error
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.FOpen.MODE .BS 1
|
|
|
|
|
K.FOpen.TYPE .BS 1
|
|
|
|
|
K.FOpen.AUXTYPE .BS 2
|
|
|
|
|
*/--------------------------------------
|
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
|
|
|
|
|
* int fclose ( FILE * stream );
|
|
|
|
|
* ## ASM
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* A = hFILE
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **Out:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.FClose jsr PFT.CheckNodeA
|
2018-07-10 15:33:13 +00:00
|
|
|
|
sta .8+1
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.REG.REF
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .1
|
|
|
|
|
sta K.MLI.PARAMS+1
|
|
|
|
|
>MLICALL MLICLOSE
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
.1 ldy #S.FD.REG.IOBUF
|
2018-05-31 15:54:00 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2018-07-10 15:33:13 +00:00
|
|
|
|
beq .8
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jsr K.FreeMem
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-07-10 15:33:13 +00:00
|
|
|
|
.8 lda #$ff Self Modified
|
2018-06-22 06:24:35 +00:00
|
|
|
|
jmp K.FreeMem
|
2018-07-10 15:33:13 +00:00
|
|
|
|
.9 rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FRead
|
|
|
|
|
* int fread ( void * ptr, int count, FILE * stream );
|
|
|
|
|
* Read bytes from file
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* PUSHW = Dest Ptr
|
|
|
|
|
* PUSHW = Bytes To Read
|
|
|
|
|
* PUSHB = hFILE
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **Out:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Y,A = Bytes Read
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FRead jsr PFT.CheckNodeSTK
|
|
|
|
|
ldx #MLIREAD
|
|
|
|
|
bra K.FReadWrite.1
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FWrite
|
|
|
|
|
* Write bytes to file
|
2018-06-19 15:08:22 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `int fwrite ( const void * ptr, int count, hFILE stream );`
|
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-19 15:08:22 +00:00
|
|
|
|
* `>PUSHB = hFILE`
|
|
|
|
|
* `>PUSHWI ptr`
|
|
|
|
|
* `>LDYA count`
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* # Out:
|
|
|
|
|
* Y,A = Bytes Written
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FWrite jsr PFT.CheckNodeSTK
|
|
|
|
|
ldx #MLIWRITE
|
|
|
|
|
K.FReadWrite.1 >PULLA
|
|
|
|
|
jsr STDIO.GetRefNum
|
|
|
|
|
>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
|
|
|
|
|
*/--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
* # FFlush
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* A = hFILE
|
|
|
|
|
*\--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.FFlush jsr PFT.CheckNodeA
|
2018-05-31 15:54:00 +00:00
|
|
|
|
jsr STDIO.GetRefNum
|
|
|
|
|
>MLICALL MLIFLUSH
|
|
|
|
|
rts
|
|
|
|
|
*/-------------------------------------
|
|
|
|
|
* # FSeek
|
|
|
|
|
* Set the file-position indicator for hFILE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* PUSHW = Ptr to Offset (DWORD)
|
|
|
|
|
* PUSHB = From
|
|
|
|
|
* PUSHB = hFILE
|
|
|
|
|
*\-------------------------------------
|
|
|
|
|
K.FSeek jsr PFT.CheckNodeSTK
|
|
|
|
|
>PULLA
|
|
|
|
|
jsr STDIO.GetRefNum
|
|
|
|
|
>PULLA FROM
|
|
|
|
|
tax
|
|
|
|
|
>PULLW ZPPtr1
|
|
|
|
|
cpx #SYS.FSeek.END+1
|
|
|
|
|
bcs .98
|
|
|
|
|
txa
|
|
|
|
|
asl
|
|
|
|
|
tax
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
jmp (.1,x)
|
2018-05-22 06:01:05 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 .DA .10
|
|
|
|
|
.DA .20
|
|
|
|
|
.DA .30
|
|
|
|
|
* K.FSeek.SET
|
|
|
|
|
.10 stz K.MLI.PARAMS+2
|
|
|
|
|
stz K.MLI.PARAMS+3
|
|
|
|
|
stz K.MLI.PARAMS+4
|
2018-05-22 06:01:05 +00:00
|
|
|
|
bra .8
|
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* K.FSeek.CUR
|
|
|
|
|
.20 >MLICALL MLIGETMARK
|
|
|
|
|
bcc .8
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
* K.FSeek.END
|
|
|
|
|
.30 >MLICALL MLIGETEOF
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
.8 ldy #0
|
|
|
|
|
ldx #3 3 bytes, 24 bits!!!
|
2017-10-16 15:41:48 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
clc
|
2017-10-16 15:41:48 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.81 lda K.MLI.PARAMS+2,y
|
|
|
|
|
adc (ZPPtr1),y
|
|
|
|
|
sta K.MLI.PARAMS+2,y
|
2018-05-25 15:09:14 +00:00
|
|
|
|
|
|
|
|
|
iny
|
2018-05-31 15:54:00 +00:00
|
|
|
|
dex
|
|
|
|
|
bne .81
|
2017-10-16 15:41:48 +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
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
|
|
|
|
|
.98 lda #K.E.SYN
|
2017-08-24 06:47:31 +00:00
|
|
|
|
.HS 2C bit abs
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.99 lda #K.E.FTB
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
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-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* A = hFILE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* CC :
|
|
|
|
|
* A=0 EOF
|
|
|
|
|
* A !=0 NOT EOF
|
|
|
|
|
* CS :
|
|
|
|
|
*\--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.FEOF jsr PFT.CheckNodeA
|
2018-05-31 15:54:00 +00:00
|
|
|
|
jsr STDIO.GetRefNum
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
>MLICALL MLIGETMARK
|
|
|
|
|
bcs .9
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldy #2
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 lda K.MLI.PARAMS+2,y
|
2018-06-22 06:24:35 +00:00
|
|
|
|
sta K.FEOF.MARK,y
|
2018-05-31 15:54:00 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
>MLICALL MLIGETEOF
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
ldy #2
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.2 lda K.MLI.PARAMS+2,y
|
2018-06-22 06:24:35 +00:00
|
|
|
|
eor K.FEOF.MARK,y
|
2018-05-31 15:54:00 +00:00
|
|
|
|
bne .8
|
|
|
|
|
dey
|
|
|
|
|
bpl .2
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
|
|
|
|
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.FEOF.MARK .BS 3
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FTell
|
|
|
|
|
* Return the current value of the file-position indicator
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* PUSHW = Ptr to Offset (DWORD)
|
|
|
|
|
* PUSHB = hFILE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **Out:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* Offset = Offset
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FTell jsr PFT.CheckNodeSTK
|
|
|
|
|
>PULLA
|
|
|
|
|
jsr STDIO.GetRefNum
|
|
|
|
|
>PULLW ZPPtr1
|
|
|
|
|
>MLICALL MLIGETMARK
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bcs .9
|
2018-05-31 15:54:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #3
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
|
|
|
|
|
dey
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 lda K.MLI.PARAMS+2,y
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
* # Remove
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-22 06:24:35 +00:00
|
|
|
|
K.Remove jsr PFT.CheckPathYA
|
2018-05-31 15:54:00 +00:00
|
|
|
|
jsr STDIO.SetMLIPathYA
|
|
|
|
|
>MLICALL MLIDESTROY
|
2017-08-24 06:47:31 +00:00
|
|
|
|
rts
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # Rename
|
|
|
|
|
* Rename a file
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
* PUSHW = New Name
|
|
|
|
|
* PUSHW = Old Name
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **Out:**
|
2018-05-31 15:54:00 +00:00
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.Rename jsr PFT.CheckPathSTK
|
|
|
|
|
jsr STDIO.PullMLIPath
|
|
|
|
|
>PULLW .1+1
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
ldy #0
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.1 lda $ffff,y Self Modified
|
2017-09-21 15:29:45 +00:00
|
|
|
|
beq .8
|
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
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-05-31 15:54:00 +00:00
|
|
|
|
.8 sty K.Buf256
|
|
|
|
|
>LDYAI K.Buf256
|
|
|
|
|
>STYA K.MLI.PARAMS+3
|
|
|
|
|
|
|
|
|
|
>MLICALL MLIRENAME
|
2018-05-29 15:31:44 +00:00
|
|
|
|
rts
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
STDIO.PullMLIPath
|
|
|
|
|
>PULLYA
|
|
|
|
|
STDIO.SetMLIPathYA
|
|
|
|
|
>STYA .1+1
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda $ffff,y Self Modified
|
|
|
|
|
beq .8
|
|
|
|
|
iny
|
|
|
|
|
sta K.MLI.PATH,y
|
|
|
|
|
cpy #MLI.MAXPATH
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.8 sty K.MLI.PATH
|
|
|
|
|
>LDYAI K.MLI.PATH
|
|
|
|
|
>STYA K.MLI.PARAMS+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2018-05-22 06:01:05 +00:00
|
|
|
|
STDIO.SetIOBUF >LDYAI 1024 get a ProDOS IOBUF
|
2018-01-17 16:31:32 +00:00
|
|
|
|
ldx #S.MEM.F.ALIGN+S.MEM.F.NOMOVE
|
|
|
|
|
jsr MEM.GetMem.YAX
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
|
|
|
|
|
txa
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.REG.IOBUF
|
2017-08-25 15:02:16 +00:00
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2018-06-21 15:12:10 +00:00
|
|
|
|
STDIO.GetRefNum jsr K.GetMemPtr
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>STYA ZPPtr1
|
2018-07-10 15:33:13 +00:00
|
|
|
|
ldy #S.FD.REG.REF
|
2017-08-25 15:02:16 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
sta K.MLI.PARAMS+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-10-26 16:01:54 +00:00
|
|
|
|
STDIO.IOERR lda #MLI.E.IO
|
2017-08-25 15:02:16 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-08-23 15:05:29 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.STDIO
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
|
|
|
|
ASM
|