mirror of
https://github.com/A2osX/A2osX.git
synced 2025-01-08 04:29:37 +00:00
Kernel 0.9.1 : Code reorganization & move to CSTR
This commit is contained in:
parent
668412cc17
commit
7cecefb477
@ -50,23 +50,21 @@ A2osX.SaveSX .EQ $101 Aux
|
||||
* Aux $200 -> 3FD : /RAM Driver
|
||||
* Aux $3FE -> 3FF : IRQ Vector
|
||||
*--------------------------------------
|
||||
*D.STACK.BASE .EQ $0300 $03EF...
|
||||
D.STACK.TOP .EQ $03F0 ...Down to $0300
|
||||
K.S.STAT .EQ $0300 S.STAT for internal kernel operations
|
||||
K.S.DEVSTAT .EQ $0340 S.DEVSTAT=25 or higher depends on dev type
|
||||
K.SP.PARAMS .EQ $0380 Max 9 bytes
|
||||
K.MLI.PARAMS .EQ $0390 Main, 18 bytes min for GetFileInfo (ATLK needs MORE!!!...32 max for now)
|
||||
K.MLI.PATH .EQ $03B0 64+1 -> $03D0
|
||||
*--------------------------------------
|
||||
*** $3F0-$3FF IRQ Handler.... ***
|
||||
*--------------------------------------
|
||||
* Main/Aux $400 -> $7FF : Console Screen
|
||||
* Main/Aux $800 -> $BFF : System Screen
|
||||
*--------------------------------------
|
||||
UsrBuf256 .EQ $0C00 Main
|
||||
*UsrBuf256 .EQ $0C00 Main
|
||||
*--------------------------------------
|
||||
KrnBuf256 .EQ $0D00 Main
|
||||
*--------------------------------------
|
||||
K.MLI.PARAMS .EQ $0E00 Main, 18 bytes min for GetFileInfo
|
||||
K.MLI.PATH .EQ K.MLI.PARAMS+32 (ATLK needs MORE!!!...32 max for now
|
||||
K.S.STAT .EQ K.MLI.PATH+64 S.STAT for internal kernel operations (DIR,FIO)
|
||||
K.S.DEVSTAT .EQ K.S.STAT+64
|
||||
K.S.PORTCALL .EQ K.S.DEVSTAT+64 S.DEVSTAT=25 or higher depends on dev type
|
||||
*--------------------------------------
|
||||
*** Z80 Reserved $0F00-10FF***
|
||||
*--------------------------------------
|
||||
@ -432,10 +430,10 @@ S.PS.PID .EQ 2
|
||||
S.PS.CPID .EQ 3
|
||||
S.PS.hCS .EQ 4
|
||||
S.PS.hDS .EQ 5
|
||||
S.PS.hPREFIX .EQ 6
|
||||
S.PS.hSS .EQ 6
|
||||
S.PS.hENV .EQ 7
|
||||
S.PS.hCMDLINE .EQ 8
|
||||
S.PS.UID .EQ 9
|
||||
S.PS.hPREFIX .EQ 9
|
||||
S.PS.hStdIn .EQ 10
|
||||
S.PS.hStdOut .EQ 11
|
||||
S.PS.hStdErr .EQ 12
|
||||
|
@ -50,7 +50,7 @@ AUTO 6
|
||||
.DO ]1=MLIDESTROY
|
||||
lda #1
|
||||
.FIN
|
||||
.DO ]1=MLIRename
|
||||
.DO ]1=MLIRENAME
|
||||
lda #2
|
||||
.FIN
|
||||
.DO ]1=MLISETFILEINFO
|
||||
|
@ -30,7 +30,7 @@ K.GetArgC jsr ARG.InitArgPtr1
|
||||
* A = argument index.
|
||||
* ## Out:
|
||||
* CC : success
|
||||
* Y,A = PStr To Arg[A]
|
||||
* Y,A = CStr To Arg[A]
|
||||
* CS : Out Of Bound
|
||||
*\--------------------------------------
|
||||
K.GetArgA sta .2+1
|
||||
@ -64,11 +64,15 @@ ARG.InitArgPtr1 ldy #S.PS.hCMDLINE
|
||||
>STYA ZPPtr1
|
||||
rts
|
||||
*--------------------------------------
|
||||
ARG.NextArgPtr1 lda ZPPtr1
|
||||
sec
|
||||
adc (ZPPtr1)
|
||||
sta ZPPtr1
|
||||
bcc .8
|
||||
ARG.NextArgPtr1 inc ZPPtr1
|
||||
bne .1
|
||||
inc ZPPtr1+1
|
||||
|
||||
.1 lda (ZPPtr1)
|
||||
bne ARG.NextArgPtr1
|
||||
|
||||
inc ZPPtr1
|
||||
bne .8
|
||||
inc ZPPtr1+1
|
||||
.8 rts
|
||||
*--------------------------------------
|
||||
|
@ -12,11 +12,11 @@ AUTO 6
|
||||
* X = hMem of Code Segment
|
||||
*--------------------------------------
|
||||
K.LoadEXEYA >STYA K.LoadEXEYA.Filename
|
||||
>SYSCALL PStrUprYA Y,A unmodified
|
||||
>SYSCALL StrUprYA Y,A unmodified
|
||||
jsr MEM.GetMemByNameYA
|
||||
bcs K.LoadEXEYA.1 not already loaded
|
||||
|
||||
>STYA ZPPtr1 Save base address
|
||||
>STYA ZPPtr1 Save base address
|
||||
ldy #S.MEM.REFCNT
|
||||
lda (ZPPtr1),y
|
||||
inc
|
||||
@ -41,9 +41,9 @@ K.LoadEXEYA.1 >PUSHWI K.S.STAT
|
||||
jsr K.LoadFile
|
||||
.9 bcs .99 Error Loading file
|
||||
|
||||
stx K.LoadEXEYA.hMem save hMem
|
||||
stx K.LoadEXEYA.hMem save hMem
|
||||
|
||||
pha YA=CODE+DATA size
|
||||
pha YA=CODE+DATA size
|
||||
tya
|
||||
* clc CC from bcs .99
|
||||
|
||||
|
@ -3,235 +3,6 @@ PREFIX /A2OSX.BUILD
|
||||
LOMEM $A00
|
||||
INC 1
|
||||
AUTO 6
|
||||
*/--------------------------------------
|
||||
* # FPutCAY
|
||||
* Print A (char) to File
|
||||
* ## In:
|
||||
* A : char to print
|
||||
* Y = hFILE
|
||||
* ## Out:
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.FPutCAY sta K.PutC.Char
|
||||
sty K.PutC.Node
|
||||
tya
|
||||
phy
|
||||
bne K.PutCharA.1
|
||||
K.PutCharA.8 ply
|
||||
clc
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # PutCharA
|
||||
* Print A (char) to StdOut
|
||||
* ## In:
|
||||
* A : char to print
|
||||
* ## Out:
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.PutCharA sta K.PutC.Char
|
||||
phy
|
||||
ldy #S.PS.hStdOut
|
||||
lda (pPs),y
|
||||
beq K.PutCharA.8 NUL
|
||||
|
||||
phx
|
||||
|
||||
K.PutCharA.1 sta K.PutC.Node
|
||||
jsr K.GetMemPtrA
|
||||
>STYA pDev
|
||||
|
||||
ldy #S.NODE.T
|
||||
lda (pDev),y
|
||||
asl
|
||||
tax
|
||||
jsr K.PutCharA.Jmp
|
||||
|
||||
plx
|
||||
ply
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.PutCharA.Jmp jmp (.1,x)
|
||||
.1 .DA K.PutCharA.REG
|
||||
.DA K.CHR.IOERR DIR
|
||||
.DA K.PutCharA.CDEV
|
||||
.DA K.CHR.IOERR BDEV
|
||||
.DA K.CHR.IOERR LNK
|
||||
.DA K.CHR.IOERR DSOCK
|
||||
.DA K.PutCharA.SSOCK
|
||||
.DA K.PutCharA.FIFO
|
||||
*--------------------------------------
|
||||
K.PutCharA.REG lda K.PutC.Node
|
||||
ldy K.PutC.Char
|
||||
jmp K.FWriteAY
|
||||
*--------------------------------------
|
||||
K.PutCharA.CDEV ldy #S.NODE.DEV.JMP
|
||||
lda (pDev),y
|
||||
sta .1+1
|
||||
iny
|
||||
lda (pDev),y
|
||||
sta .1+2
|
||||
lda K.PutC.Char
|
||||
ldx #DEVMGR.WRITE
|
||||
.1 jmp $ffff
|
||||
*--------------------------------------
|
||||
K.PutCharA.SSOCK
|
||||
lda (pDev) #S.NODE.HANDLER
|
||||
jsr K.GetMemPtrA
|
||||
>STYA .1
|
||||
|
||||
ldy #S.NODE.SSOCK.HSKT
|
||||
>PUSHB (pDev),y
|
||||
>PUSHB K.PutC.Char
|
||||
|
||||
ldy #S.NODE.SSOCK.WRITE
|
||||
lda (pDev),y
|
||||
tax Function Offset for write
|
||||
.1 jmp $ffff
|
||||
*--------------------------------------
|
||||
K.PutCharA.FIFO ldy #S.NODE.FIFO.S
|
||||
lda (pDev),y
|
||||
beq .9 Remote PS did not opened yet the pipe
|
||||
cmp #S.NODE.FIFO.S.Closed
|
||||
beq .99 Remote PS closed the Pipe
|
||||
|
||||
ldy #S.NODE.FIFO.hMem
|
||||
lda (pDev),y
|
||||
jsr K.GetMemPtrA
|
||||
>STYA .1+2
|
||||
|
||||
ldy #S.NODE.FIFO.Head
|
||||
lda (pDev),y
|
||||
inc
|
||||
dey #S.NODE.FIFO.Tail
|
||||
cmp (pDev),y
|
||||
beq .9 FIFO is full
|
||||
iny
|
||||
sta (pDev),y
|
||||
tay
|
||||
lda K.PutC.Char
|
||||
.1 sta $ffff,y
|
||||
clc
|
||||
rts
|
||||
|
||||
.9 lda #MLI.ERR.VOLFULL
|
||||
sec
|
||||
rts
|
||||
|
||||
.99 lda #MLI.ERR.EOF
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.PutC.Char .BS 1
|
||||
K.PutC.Node .BS 1
|
||||
*/--------------------------------------
|
||||
* # GetChar
|
||||
* Get char from StdIn
|
||||
* ## In:
|
||||
* none.
|
||||
* ## Out:
|
||||
* CC = success
|
||||
* A = char
|
||||
*\--------------------------------------
|
||||
K.GetChar ldy #S.PS.hStdIn
|
||||
lda (pPs),y
|
||||
*/--------------------------------------
|
||||
* # GetCA
|
||||
* Get char from File
|
||||
* ## In:
|
||||
* A = hFILE
|
||||
* ## Out:
|
||||
* CC = success
|
||||
* A = char
|
||||
*\--------------------------------------
|
||||
K.GetCA sta K.PutC.Node
|
||||
|
||||
jsr K.GetMemPtrA
|
||||
>STYA pDev
|
||||
|
||||
ldy #S.NODE.T
|
||||
lda (pDev),y
|
||||
asl
|
||||
tax
|
||||
jmp (.1,x)
|
||||
|
||||
.1 .DA K.GetC.REG
|
||||
.DA K.CHR.IOERR DIR
|
||||
.DA K.GetC.CDEV
|
||||
.DA K.CHR.IOERR BDEV
|
||||
.DA K.CHR.IOERR LNK
|
||||
.DA K.CHR.IOERR DSOCK
|
||||
.DA K.GetC.SSOCK
|
||||
.DA K.GetC.FIFO
|
||||
*--------------------------------------
|
||||
K.GetC.REG lda K.PutC.Node
|
||||
jmp K.FReadA
|
||||
*--------------------------------------
|
||||
K.GetC.CDEV ldx #DEVMGR.READ
|
||||
ldy #S.NODE.DEV.JMP
|
||||
lda (pDev),y
|
||||
sta .1+1
|
||||
iny
|
||||
lda (pDev),y
|
||||
sta .1+2
|
||||
.1 jmp $ffff
|
||||
*--------------------------------------
|
||||
K.GetC.SSOCK lda (pDev) #S.NODE.HANDLER
|
||||
jsr K.GetMemPtrA
|
||||
>STYA .1
|
||||
|
||||
ldy #S.NODE.SSOCK.READ
|
||||
lda (pDev),y
|
||||
tax Function Offset for READ
|
||||
|
||||
ldy #S.NODE.SSOCK.HSKT
|
||||
lda (pDev),y
|
||||
|
||||
.1 jmp $ffff
|
||||
*--------------------------------------
|
||||
K.GetC.FIFO
|
||||
*/--------------------------------------
|
||||
* # FPutS
|
||||
* Write String to FILE
|
||||
* ## In:
|
||||
* PUSHW : CPtr
|
||||
* PUSHB : hFILE
|
||||
* ## Out:
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.FPutS
|
||||
*/--------------------------------------
|
||||
* # PutSYA
|
||||
* Write String to StdOut
|
||||
* ## In:
|
||||
* Y,A : CPtr
|
||||
* ## Out:
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.PutSYA
|
||||
*/--------------------------------------
|
||||
* # FGetS
|
||||
* Read String From FILE
|
||||
* ## In:
|
||||
* PUSHW : CPtr
|
||||
* PUSHB : hFILE
|
||||
* ## Out:
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.FGetS
|
||||
*/--------------------------------------
|
||||
* # GetSYA
|
||||
* Read String From StdIn
|
||||
* ## In:
|
||||
* Y,A : CPtr
|
||||
* ## Out:
|
||||
* CC = success
|
||||
*\--------------------------------------
|
||||
K.GetSYA
|
||||
bra *
|
||||
*--------------------------------------
|
||||
K.CHR.IOERR lda #MLI.ERR.IO
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.CHR
|
||||
|
@ -3,503 +3,6 @@ PREFIX /A2OSX.BUILD
|
||||
LOMEM $A00
|
||||
INC 1
|
||||
AUTO 6
|
||||
*/--------------------------------------
|
||||
* # SScanF
|
||||
* Scan a PStr (in progress)
|
||||
* ## In:
|
||||
* PUSHW PTR to target buffer
|
||||
* PUSHW PSTR pattern (ex: "%d.%d.%d.%d")
|
||||
* %d : byte
|
||||
* PUSHW PSTR to scan (ex: "192.168.1.5")
|
||||
* ## Out:
|
||||
*\--------------------------------------
|
||||
K.SScanF jsr PullPtr1Ptr2Ptr3
|
||||
|
||||
ldy #0 Y = PTR in pattern
|
||||
|
||||
lda (ZPPtr1)
|
||||
beq .9
|
||||
tax X = COUNT to scan
|
||||
inc ZPPtr1
|
||||
bne .1
|
||||
inc ZPPtr1+1
|
||||
|
||||
.1 txa End Of String?
|
||||
beq .8
|
||||
tya
|
||||
cmp (ZPPtr2) End of pattern?
|
||||
beq .8
|
||||
iny
|
||||
lda (ZPPtr2),y
|
||||
cmp #'%' Escape?
|
||||
beq .2
|
||||
cmp (ZPPtr1) Same char?
|
||||
bne .9
|
||||
jsr K.SScanF.IncPtr1
|
||||
bne .1
|
||||
clc
|
||||
rts
|
||||
|
||||
.2 tya
|
||||
cmp (ZPPtr2) unexpected End of pattern after "%" ?
|
||||
beq .9
|
||||
|
||||
iny
|
||||
lda (ZPPtr2),y
|
||||
cmp #'d' BYTE ?
|
||||
bne .3
|
||||
|
||||
stz ASCBUF
|
||||
.20 lda (ZPPtr1)
|
||||
jsr K.SScanF.IsDigit
|
||||
bcs .21
|
||||
phx
|
||||
inc ASCBUF
|
||||
ldx ASCBUF
|
||||
sta ASCBUF,x
|
||||
plx
|
||||
jsr K.SScanF.IncPtr1
|
||||
bne .20 end of string ?
|
||||
|
||||
.21 jsr DEC2HEX
|
||||
lda HEXBUF
|
||||
sta (ZPPtr3)
|
||||
inc ZPPtr3
|
||||
bne .1
|
||||
inc ZPPtr3+1
|
||||
bra .1
|
||||
|
||||
.3 cmp #'D' WORD ?
|
||||
bne .4
|
||||
|
||||
bra .1
|
||||
|
||||
.4 cmp #'s' STRING ?
|
||||
bne .9
|
||||
|
||||
bra .1
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
|
||||
.9 sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.SScanF.IncPtr1
|
||||
dex
|
||||
beq .1
|
||||
inc ZPPtr1
|
||||
bne .1
|
||||
inc ZPPtr1+1 never Zero
|
||||
.1 rts
|
||||
*--------------------------------------
|
||||
K.SScanF.IsDigit
|
||||
cmp #'0'
|
||||
bcc .1
|
||||
cmp #'9'+1
|
||||
bcs .1
|
||||
rts
|
||||
.1 sec
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # PrintFYA/SPrintFYA/FPrintFYA
|
||||
* Prints C-Style String
|
||||
* ## In:
|
||||
* PrintFYA :
|
||||
* Y,A = PTR to CStr
|
||||
* SPrintFYA :
|
||||
* Y,A = PTR to CStr
|
||||
* PULLW = Ptr to Dst Buffer
|
||||
* FPrintFYA :
|
||||
* Y,A = PTR to CStr
|
||||
* PULLB = hNode
|
||||
* ## Out:
|
||||
* CC : success
|
||||
* CS : error code from Output
|
||||
* Specifiers :
|
||||
* %a : pull 2 bytes to Print Access right String 'drwxrwxrwx'
|
||||
* %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 2 bytes PTR to 4 bytes long unsigned DEC 0..4294967295
|
||||
* %e : pull 2 bytes PTR to 6 Bytes Real +1.23456789e+12
|
||||
* %f : pull 2 bytes PTR to 6 Bytes Real 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 2 bytes PTR to 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 %
|
||||
* Modifiers for len and padding :
|
||||
* %d : '9' '12'
|
||||
* %2d : ' 9' '12'
|
||||
* %02d : '09' '12'
|
||||
* %11s : 'ABCDEFGH '
|
||||
* %011s : 'ABCDEFGH000'
|
||||
* %2f : '3.14'
|
||||
*\--------------------------------------
|
||||
K.SPrintFYA >STYA ZPPtr1
|
||||
>PULLW Printf.Cout.Ptr+1
|
||||
|
||||
K.FPrintFYA >STYA ZPPtr1
|
||||
|
||||
K.PrintFYA >STYA ZPPtr1
|
||||
|
||||
ldy #0
|
||||
|
||||
.1 lda (ZPPtr1),y
|
||||
beq .99
|
||||
iny
|
||||
cmp #'%'
|
||||
bne .10
|
||||
|
||||
stz PADLEN
|
||||
lda #' '
|
||||
sta PADCHAR
|
||||
|
||||
.2 ldx #PrintFTBL2-PrintFTBL1-1
|
||||
lda (ZPPtr1),y
|
||||
beq .99
|
||||
iny
|
||||
|
||||
.3 cmp PrintFTBL1,x do we have a %x command?
|
||||
beq .8 yes, jmp to it!
|
||||
dex
|
||||
bpl .3 no valid letter...
|
||||
|
||||
cmp #'0' ...a 0...mmm... padding char?
|
||||
bne .4
|
||||
|
||||
ldx PADLEN PADLEN is not nul, so this 0 is second digit
|
||||
bne .5
|
||||
|
||||
lda #'0'
|
||||
sta PADCHAR no, this is the first 0, so make it PADCHAR
|
||||
bra .2
|
||||
|
||||
.4 bcc .99 less than '0'....error
|
||||
cmp #'9'+1
|
||||
bcs .99 more than '9' ....error
|
||||
|
||||
.5 and #$0F we have a digit
|
||||
pha save it...
|
||||
lda PADLEN starts PADLEN * 10
|
||||
asl
|
||||
asl A=times 4
|
||||
adc PADLEN CC by ASL, A=times 5
|
||||
asl times 10
|
||||
sta PADLEN
|
||||
|
||||
pla get back digit
|
||||
adc PADLEN
|
||||
sta PADLEN
|
||||
bra .2 go get next char...
|
||||
|
||||
.8 phy
|
||||
txa
|
||||
asl
|
||||
tax
|
||||
jsr PrintFESC
|
||||
ply
|
||||
bcc .1
|
||||
rts
|
||||
|
||||
.10 cmp #'\'
|
||||
bne .20
|
||||
|
||||
ldx #PrintFTBL2.OUT-PrintFTBL2-1
|
||||
lda (ZPPtr1),y
|
||||
beq .99
|
||||
iny
|
||||
|
||||
.12 cmp PrintFTBL2,x
|
||||
beq .13
|
||||
dex
|
||||
bpl .12
|
||||
bra .1
|
||||
|
||||
.13 lda PrintFTBL2.OUT,x
|
||||
|
||||
.20 jsr Printf.Cout
|
||||
bcc .1
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
PrintFESC jmp (PrintFJMP,x)
|
||||
*--------------------------------------
|
||||
PrintFTBL1 .AS "abBdDuefhHiILnNsS"
|
||||
PrintFTBL2 .AS "befnr\%"
|
||||
PrintFTBL2.OUT .HS 08.1B.0C.0A.0D \b\e\f\n\r
|
||||
.DA #'\' \\
|
||||
.DA #'%' \%
|
||||
PrintFJMP .DA PrintF.A
|
||||
.DA PrintF.B,PrintF.BB
|
||||
.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
|
||||
*--------------------------------------
|
||||
PrintF.A >PULLW HEXBUF
|
||||
|
||||
lda HEXBUF+1
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
tax
|
||||
lda TYPES,x
|
||||
jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
ldx #0
|
||||
|
||||
.1 lda #'-'
|
||||
lsr HEXBUF
|
||||
bcc .2
|
||||
lda ACCESS,x
|
||||
|
||||
.2 jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
inx
|
||||
cpx #8
|
||||
bne .1
|
||||
|
||||
.3 lda #'-'
|
||||
lsr HEXBUF+1
|
||||
bcc .4
|
||||
lda ACCESS,x
|
||||
|
||||
.4 jmp Printf.Cout
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
PrintF.BB >PULLA
|
||||
pha
|
||||
jsr PrintF.B
|
||||
pla
|
||||
bcc PrintF.B.1
|
||||
PrintF.BB.RTS rts
|
||||
*--------------------------------------
|
||||
PrintF.B >PULLA
|
||||
|
||||
PrintF.B.1 ldx #8
|
||||
|
||||
.1 asl
|
||||
pha
|
||||
lda #'0'
|
||||
adc #0 add Carry
|
||||
jsr Printf.Cout
|
||||
pla
|
||||
bcs PrintF.BB.RTS
|
||||
dex
|
||||
bne .1
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.D >PULLB HEXBUF
|
||||
stz HEXBUF+1
|
||||
bra PrintF.DD.1
|
||||
|
||||
PrintF.DD >PULLW HEXBUF
|
||||
PrintF.DD.1 stz HEXBUF+2
|
||||
stz HEXBUF+3
|
||||
bra PrintF.U.1
|
||||
|
||||
PrintF.U >PULLW ZPPtr2
|
||||
ldy #3
|
||||
|
||||
.1 lda (ZPPtr2),y
|
||||
sta HEXBUF,y
|
||||
dey
|
||||
bpl .1
|
||||
|
||||
PrintF.U.1 stz SIGN
|
||||
jsr HEX2DEC
|
||||
jmp PrintDEC
|
||||
*--------------------------------------
|
||||
PrintF.E >PULLW ZPPtr2
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.F >PULLW ZPPtr2
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.HH >PULLA
|
||||
pha
|
||||
jsr PrintF.H
|
||||
pla
|
||||
bra PrintF.H.1
|
||||
*--------------------------------------
|
||||
PrintF.H >PULLA
|
||||
PrintF.H.1 pha
|
||||
jsr PrintF.NN.1
|
||||
pla
|
||||
jmp PrintF.N.1
|
||||
*--------------------------------------
|
||||
PrintF.I >PULLB HEXBUF
|
||||
eor #$ff if positive, it becomes neg so branch if....minus!
|
||||
clc
|
||||
bmi .1
|
||||
sec
|
||||
inc 2s complement...
|
||||
sta HEXBUF
|
||||
|
||||
|
||||
.1 stz HEXBUF+1
|
||||
bra PrintF.II.1
|
||||
|
||||
PrintF.II >PULLW HEXBUF A=HI
|
||||
eor #$ff
|
||||
clc
|
||||
bmi PrintF.II.1
|
||||
sec
|
||||
tax
|
||||
lda HEXBUF
|
||||
eor #$ff
|
||||
inc 2s complement...
|
||||
sta HEXBUF
|
||||
bne .1
|
||||
inx
|
||||
.1 sta HEXBUF
|
||||
stx HEXBUF+1
|
||||
|
||||
PrintF.II.1 stz HEXBUF+2
|
||||
stz HEXBUF+3
|
||||
bra PrintF.L.1
|
||||
|
||||
PrintF.L >PULLW ZPPtr2
|
||||
ldy #3
|
||||
|
||||
.1 lda (ZPPtr2),y
|
||||
sta HEXBUF,y
|
||||
dey
|
||||
bpl .1
|
||||
|
||||
|
||||
PrintF.L.1 ror SIGN
|
||||
jsr HEX2DEC
|
||||
*--------------------------------------
|
||||
PRINTDEC lda PADLEN any Len format ?
|
||||
beq .1 no
|
||||
|
||||
lda #10
|
||||
sec yes, Print only digits starting at pos 10-padlen
|
||||
sbc PADLEN
|
||||
|
||||
.1 tax x=0 if no padlen, or x=10-padlen
|
||||
|
||||
.2 lda ASCBUF,x
|
||||
cmp #'0' a zero?
|
||||
beq .3
|
||||
|
||||
inc PADLEN found a non zero, Print all digits, even if 0, next time
|
||||
ldy #'0'
|
||||
sty PADCHAR
|
||||
bra .4
|
||||
|
||||
.3 cpx #9 last digit ?
|
||||
beq .4 Print always
|
||||
|
||||
ldy PADLEN no pad to fill, do not Print 0
|
||||
beq .6
|
||||
|
||||
lda PADCHAR fill with PADCHAR
|
||||
|
||||
.4 bit SIGN a sign to print before digits ?
|
||||
bpl .5
|
||||
pha yes, save whatever we have to print....
|
||||
lda #'-'
|
||||
jsr Printf.Cout
|
||||
stz SIGN reset flag for next char...
|
||||
pla
|
||||
|
||||
.5 jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
.6 inx
|
||||
cpx #10
|
||||
bne .2
|
||||
|
||||
clc
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
PrintF.N >PULLA
|
||||
PrintF.N.1 and #$0F
|
||||
bra PrintF.NN.2
|
||||
|
||||
PrintF.NN >PULLA
|
||||
PrintF.NN.1 lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
|
||||
PrintF.NN.2 ora #$30
|
||||
cmp #$3A
|
||||
bcc .1
|
||||
adc #6
|
||||
.1 jmp Printf.Cout
|
||||
*--------------------------------------
|
||||
PrintF.S ldy #$ff CSTR
|
||||
.HS 2C bit abs
|
||||
PrintF.SS ldy #$00 PSTR
|
||||
|
||||
>PULLW ZPPtr2
|
||||
|
||||
lda (ZPPtr2) if CSTR:last char=0, if PSTR:len=0
|
||||
beq .8
|
||||
|
||||
sty .1+1
|
||||
|
||||
.1 lda #$ff Self Modified
|
||||
bne .11 CSTR
|
||||
|
||||
tya PSTR
|
||||
cmp (ZPPtr2) len check
|
||||
beq .2
|
||||
|
||||
.11 iny
|
||||
|
||||
lda (ZPPtr2),y
|
||||
beq .2
|
||||
|
||||
jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
lda PADLEN
|
||||
beq .1
|
||||
|
||||
cpy PADLEN
|
||||
bne .1
|
||||
clc
|
||||
rts
|
||||
|
||||
.2 lda PADLEN
|
||||
beq .8
|
||||
|
||||
.3 lda PADCHAR
|
||||
jsr Printf.Cout
|
||||
bcs .9
|
||||
iny
|
||||
cpy PADLEN
|
||||
bne .3
|
||||
|
||||
.8 clc
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
Printf.Cout jmp K.PutCharA
|
||||
|
||||
Printf.Cout.Ptr sta $ffff Self modified
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.CIO
|
||||
|
@ -4,133 +4,6 @@ LOMEM $A00
|
||||
INC 1
|
||||
AUTO 6
|
||||
*--------------------------------------
|
||||
* Convert HEXBUF to ASCBUF decimal padded with 0
|
||||
*--------------------------------------
|
||||
HEX2DEC ldx #4
|
||||
|
||||
.1 stz BCDBUF,x Clear all 5 bytes
|
||||
dex
|
||||
bpl .1
|
||||
|
||||
sed switch to BCD mode
|
||||
|
||||
ldx #32 let's roll 32 bits
|
||||
|
||||
.2 jsr HEXBUF.ROL
|
||||
|
||||
ldy #4
|
||||
|
||||
.3 lda BCDBUF,y
|
||||
adc BCDBUF,y
|
||||
sta BCDBUF,y
|
||||
dey
|
||||
bpl .3
|
||||
|
||||
dex
|
||||
bne .2
|
||||
|
||||
cld
|
||||
|
||||
ldy #4
|
||||
ldx #9
|
||||
|
||||
.4 lda BCDBUF,y
|
||||
pha
|
||||
and #$0F
|
||||
ora #$30
|
||||
sta ASCBUF,x
|
||||
dex
|
||||
pla
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ora #$30
|
||||
sta ASCBUF,x
|
||||
dey
|
||||
dex
|
||||
bpl .4
|
||||
|
||||
rts
|
||||
*--------------------------------------
|
||||
* Convert ASCBUF decimal to HEXBUF
|
||||
*--------------------------------------
|
||||
DEC2HEX stz HEXBUF
|
||||
stz HEXBUF+1
|
||||
stz HEXBUF+2
|
||||
stz HEXBUF+3
|
||||
|
||||
lda ASCBUF
|
||||
beq .8
|
||||
|
||||
ldx #0
|
||||
|
||||
.1 lda HEXBUF+3 save HEXBUF for 4+1
|
||||
pha
|
||||
lda HEXBUF+2
|
||||
pha
|
||||
lda HEXBUF+1
|
||||
pha
|
||||
lda HEXBUF
|
||||
pha
|
||||
|
||||
jsr HEXBUF.ROL HEXBUF * 2 -> HEXBUF
|
||||
* bcs .9 overflow!!!
|
||||
|
||||
jsr HEXBUF.ROL HEXBUF * 4 -> HEXBUF
|
||||
* bcs .9 overflow!!!
|
||||
|
||||
pla HEXBUF * 4 + HEXBUF -> HEXBUF
|
||||
adc HEXBUF
|
||||
sta HEXBUF
|
||||
pla
|
||||
adc HEXBUF+1
|
||||
sta HEXBUF+1
|
||||
pla
|
||||
adc HEXBUF+2
|
||||
sta HEXBUF+2
|
||||
pla
|
||||
adc HEXBUF+3
|
||||
sta HEXBUF+3
|
||||
* bcs .99 overflow!!!
|
||||
|
||||
jsr HEXBUF.ROL HEXBUF * 10 -> HEXBUF
|
||||
* bcs .99 overflow!!!
|
||||
|
||||
inx
|
||||
lda ASCBUF,x
|
||||
and #$0F
|
||||
|
||||
adc HEXBUF
|
||||
sta HEXBUF
|
||||
bcc .2
|
||||
inc HEXBUF+1
|
||||
bne .2
|
||||
inc HEXBUF+2
|
||||
bne .2
|
||||
inc HEXBUF+3
|
||||
|
||||
.2 cpx ASCBUF
|
||||
bne .1
|
||||
|
||||
.8 rts
|
||||
|
||||
*.9 pla discard saved HEXBUF
|
||||
* pla
|
||||
* pla
|
||||
* pla
|
||||
*.99 rts
|
||||
*--------------------------------------
|
||||
HEXBUF.ROL asl HEXBUF
|
||||
rol HEXBUF+1
|
||||
rol HEXBUF+2
|
||||
rol HEXBUF+3
|
||||
rts
|
||||
*--------------------------------------
|
||||
HEXBUF .BS 4 32 bits max
|
||||
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
||||
ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295)
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.CNV
|
||||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||||
|
@ -19,9 +19,9 @@ A2osX.PrtDrv .DA A2osX.PrtDrv.S STATUS
|
||||
*--------------------------------------
|
||||
A2osX.PrtDrv.S jsr A2osX.PrtDrv.GetDev
|
||||
>LDYAI K.S.DEVSTAT
|
||||
>STYA K.S.PORTCALL+2
|
||||
>STYA K.SP.PARAMS+2
|
||||
lda #3
|
||||
sta K.S.PORTCALL+4
|
||||
sta K.SP.PARAMS+4
|
||||
jsr A2osX.PrtDrv.Go
|
||||
bcs .9
|
||||
>LDYAI K.S.DEVSTAT
|
||||
@ -41,7 +41,7 @@ A2osX.PrtDrv.Go ldy #S.DEV.ROM.JMP
|
||||
.8 jsr $ffff
|
||||
A2osX.PrtDrv.Go.Cmd
|
||||
.BS 1
|
||||
.DA K.S.PORTCALL
|
||||
.DA K.SP.PARAMS
|
||||
rts
|
||||
*--------------------------------------
|
||||
A2osX.PrtDrv.GetParam
|
||||
@ -51,7 +51,7 @@ A2osX.PrtDrv.GetParam
|
||||
ldy #7
|
||||
|
||||
.1 lda (ZPDRV),y
|
||||
sta K.S.PORTCALL+2,y
|
||||
sta K.SP.PARAMS+2,y
|
||||
dey
|
||||
bpl .1
|
||||
rts
|
||||
@ -62,10 +62,10 @@ A2osX.PrtDrv.GetDev
|
||||
sta A2osX.PrtDrv.Go.Cmd
|
||||
tax
|
||||
lda A2osX.PrtDrv.Cnt,x
|
||||
sta K.S.PORTCALL
|
||||
sta K.SP.PARAMS
|
||||
ldy #S.DEV.DEVID
|
||||
lda (pDev),y
|
||||
sta K.S.PORTCALL+1
|
||||
sta K.SP.PARAMS+1
|
||||
rts
|
||||
A2osX.PrtDrv.Cnt
|
||||
.HS 03030301030101010404
|
||||
|
@ -4,450 +4,6 @@ LOMEM $A00
|
||||
INC 1
|
||||
AUTO 6
|
||||
*--------------------------------------
|
||||
* For All SYS.xxxx calls, X = #SYSCall
|
||||
* Must be kept in X before calling
|
||||
* PFT.Check
|
||||
*/--------------------------------------
|
||||
* # FOpen
|
||||
* Open a file
|
||||
* ## In :
|
||||
* PUSHW = AUXTYPE
|
||||
* PUSHB = TYPE
|
||||
* PUSHB = 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
|
||||
* PUSHW = PATH (PSTR)
|
||||
* ## Out :
|
||||
* CC : A = hFILE
|
||||
* CS : A = EC
|
||||
*\--------------------------------------
|
||||
K.FOpen jsr PFT.CheckPathSTK
|
||||
>PULLW K.MLI.PARAMS+1
|
||||
>PULLB K.FOpen.MODE
|
||||
>PULLB K.FOpen.TYPE
|
||||
>PULLW K.FOpen.AUXTYPE
|
||||
|
||||
>MLICALL MLIGETFILEINFO
|
||||
bcc K.FOpen.10 Already Exists
|
||||
|
||||
bit K.FOpen.MODE Create if not exists ?
|
||||
bpl K.FOpen.9 No, return MLI error
|
||||
|
||||
lda #S.FILEINFO.ACCESS.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.FILEINFO.STORETYPE.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.NODE.REG
|
||||
jsr K.GetMem0YA
|
||||
bcs K.FOpen.9
|
||||
|
||||
>STYA ZPPtr1
|
||||
stx hFILE
|
||||
|
||||
jsr FILE.SetIOBUF
|
||||
bcs .98
|
||||
|
||||
>MLICALL MLIOPEN
|
||||
bcs .98
|
||||
|
||||
lda K.MLI.PARAMS+5 get ref_num
|
||||
ldy #S.NODE.REG.REF
|
||||
sta (ZPPtr1),y
|
||||
|
||||
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
|
||||
|
||||
lda K.FOpen.MODE
|
||||
bit #SYS.FOpen.W
|
||||
beq .20 Write mode ?
|
||||
|
||||
and #SYS.FOpen.A 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
|
||||
bcs .98
|
||||
bra .20
|
||||
|
||||
.11 >MLICALL MLIGETEOF
|
||||
bcs .98
|
||||
|
||||
>MLICALL MLISETMARK
|
||||
bcs .98
|
||||
|
||||
.20 lda K.FOpen.MODE
|
||||
and #SYS.FOpen.T Text Mode ?
|
||||
beq .30
|
||||
|
||||
lda #$FF
|
||||
sta K.MLI.PARAMS+2
|
||||
lda #$0D
|
||||
sta K.MLI.PARAMS+3
|
||||
>MLICALL MLINEWLINE
|
||||
|
||||
.30 ldy #S.NODE.T
|
||||
lda #S.NODE.T.REG
|
||||
sta (ZPPtr1),y
|
||||
lda hFILE
|
||||
clc
|
||||
rts CC
|
||||
|
||||
.98 pha save MLI error
|
||||
lda hFILE
|
||||
jsr K.FCloseA.1
|
||||
pla get back MLI error
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.FOpen.MODE .BS 1
|
||||
K.FOpen.TYPE .BS 1
|
||||
K.FOpen.AUXTYPE .BS 2
|
||||
hFILE .BS 1
|
||||
*/--------------------------------------
|
||||
* # FCloseA
|
||||
* Close a file
|
||||
* ## In :
|
||||
* A = hFILE
|
||||
* ## Out :
|
||||
*\--------------------------------------
|
||||
K.FCloseA jsr PFT.CheckNodeA
|
||||
pha
|
||||
jsr K.GetMemPtrA
|
||||
>STYA ZPPtr1
|
||||
pla
|
||||
|
||||
K.FCloseA.1 sta K.FCloseA.2+1
|
||||
ldy #S.NODE.REG.REF
|
||||
lda (ZPPtr1),y
|
||||
beq .1
|
||||
sta K.MLI.PARAMS+1
|
||||
>MLICALL MLICLOSE
|
||||
|
||||
.1 ldy #S.NODE.REG.IOBUF
|
||||
lda (ZPPtr1),y
|
||||
beq K.FCloseA.2
|
||||
jsr K.FreeMemA
|
||||
|
||||
K.FCloseA.2 lda #$ff Self Modified
|
||||
jmp K.FreeMemA
|
||||
*/--------------------------------------
|
||||
* # FReadA
|
||||
* Read ONE byte from file
|
||||
* ## In :
|
||||
* A = hFILE
|
||||
* ## Out :
|
||||
* A = Byte Read
|
||||
*\--------------------------------------
|
||||
K.FReadA jsr PFT.CheckNodeA
|
||||
ldx #MLIREAD
|
||||
bra K.FReadWrite.0
|
||||
*/--------------------------------------
|
||||
* # FWriteAY
|
||||
* ## In:
|
||||
* A = hFILE
|
||||
* Y = char
|
||||
* # Out:
|
||||
* Y,A = Bytes Written
|
||||
*\--------------------------------------
|
||||
K.FWriteAY jsr PFT.CheckNodeA
|
||||
sty K.FWriteAY.Buf
|
||||
ldx #MLIWRITE
|
||||
K.FReadWrite.0 jsr FILE.SetupPrt1A
|
||||
>LDYAI K.FWriteAY.Buf
|
||||
>STYA K.MLI.PARAMS+2
|
||||
lda #1
|
||||
sta K.MLI.PARAMS+4
|
||||
stz K.MLI.PARAMS+5
|
||||
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
|
||||
jsr A2osX.MLICALL
|
||||
bcs .9
|
||||
lda K.FWriteAY.Buf
|
||||
.9 rts
|
||||
K.FWriteAY.Buf .BS 1
|
||||
*/--------------------------------------
|
||||
* # FRead
|
||||
* Read bytes from file
|
||||
* ## In :
|
||||
* PUSHW = Dest Ptr
|
||||
* PUSHW = Bytes To Read
|
||||
* PUSHB = hFILE
|
||||
* ## Out :
|
||||
* Y,A = Bytes Read
|
||||
*\--------------------------------------
|
||||
K.FRead jsr PFT.CheckNodeSTK
|
||||
ldx #MLIREAD
|
||||
bra K.FReadWrite.1
|
||||
*/--------------------------------------
|
||||
* # FWrite
|
||||
* ## In:
|
||||
* PUSHW = Src Ptr
|
||||
* PUSHW = Bytes To Write
|
||||
* PUSHB = hFILE
|
||||
* # Out:
|
||||
* Y,A = Bytes Written
|
||||
*\--------------------------------------
|
||||
K.FWrite jsr PFT.CheckNodeSTK
|
||||
ldx #MLIWRITE
|
||||
K.FReadWrite.1 >PULLA
|
||||
jsr FILE.SetupPrt1A
|
||||
>PULLW K.MLI.PARAMS+4
|
||||
>PULLW K.MLI.PARAMS+2
|
||||
|
||||
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
|
||||
jsr A2osX.MLICALL
|
||||
bcs .9
|
||||
>LDYA K.MLI.PARAMS+6
|
||||
.9 rts
|
||||
*/--------------------------------------
|
||||
* # FFlushA
|
||||
* ## In:
|
||||
* A = hFILE
|
||||
*\--------------------------------------
|
||||
K.FFlushA jsr PFT.CheckNodeA
|
||||
jsr FILE.SetupPrt1A
|
||||
>MLICALL MLIFLUSH
|
||||
rts
|
||||
*/-------------------------------------
|
||||
* # FSeek
|
||||
* ## In:
|
||||
* PUSHW = OffsetHi
|
||||
* PUSHW = OffsetLo
|
||||
* PUSHB = From
|
||||
* PUSHB = hFILE
|
||||
*\-------------------------------------
|
||||
K.FSeek jsr PFT.CheckNodeSTK
|
||||
>PULLA
|
||||
jsr FILE.SetupPrt1A
|
||||
>PULLA FROM
|
||||
tax
|
||||
>PULLW K.FSeek.OFFSET
|
||||
>PULLW K.FSeek.OFFSET+2
|
||||
|
||||
cpx #SYS.FSeek.SET
|
||||
|
||||
bne .1
|
||||
stz K.MLI.PARAMS+2
|
||||
stz K.MLI.PARAMS+3
|
||||
stz K.MLI.PARAMS+4
|
||||
bra .8
|
||||
|
||||
.1 cpx #SYS.FSeek.CUR
|
||||
bne .2
|
||||
>MLICALL MLIGETMARK
|
||||
bcc .8
|
||||
rts
|
||||
|
||||
.2 cpx #SYS.FSeek.END
|
||||
bne .98
|
||||
>MLICALL MLIGETEOF
|
||||
bcs .9
|
||||
|
||||
.8 ldx #0
|
||||
ldy #3
|
||||
|
||||
clc
|
||||
|
||||
.81 lda K.MLI.PARAMS+2,x
|
||||
adc K.FSeek.OFFSET,x
|
||||
sta K.MLI.PARAMS+2,x
|
||||
|
||||
inx
|
||||
dey
|
||||
bne .81
|
||||
|
||||
bcs .99 Offset out of range!
|
||||
|
||||
>MLICALL MLISETMARK
|
||||
|
||||
.9 rts
|
||||
|
||||
.98 lda #SYSMGR.ERRSYN
|
||||
.HS 2C bit abs
|
||||
.99 lda #SYSMGR.ERRFTB
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.FSeek.OFFSET .BS 4
|
||||
*/--------------------------------------
|
||||
* # FTellA
|
||||
* ## In:
|
||||
* A = hFILE
|
||||
* ## Out:
|
||||
* Y,A,X = Offset
|
||||
*\--------------------------------------
|
||||
K.FTellA jsr PFT.CheckNodeA
|
||||
K.FTellA.1 jsr FILE.SetupPrt1A
|
||||
>MLICALL MLIGETMARK
|
||||
bcs .9
|
||||
>LDYA K.MLI.PARAMS+2
|
||||
ldx K.MLI.PARAMS+4
|
||||
.9 rts
|
||||
*/--------------------------------------
|
||||
* # FEOFA
|
||||
* ## In:
|
||||
* A = hFILE
|
||||
* ## Out:
|
||||
* CC :
|
||||
* A=0 EOF
|
||||
* A !=0 NOT EOF
|
||||
* CS :
|
||||
*\--------------------------------------
|
||||
K.FEOFA jsr PFT.CheckNodeA
|
||||
jsr FILE.SetupPrt1A
|
||||
jsr K.FTellA.1
|
||||
bcs .9
|
||||
>STYA K.FEOFA.MARK
|
||||
stx K.FEOFA.MARK+2
|
||||
|
||||
>MLICALL MLIGETEOF
|
||||
bcs .9
|
||||
|
||||
sec
|
||||
lda K.MLI.PARAMS+2
|
||||
sbc K.FEOFA.MARK
|
||||
bne .8
|
||||
lda K.MLI.PARAMS+3
|
||||
sbc K.FEOFA.MARK+1
|
||||
bne .8
|
||||
lda K.MLI.PARAMS+4
|
||||
sbc K.FEOFA.MARK+2
|
||||
.8 clc
|
||||
.9 rts
|
||||
K.FEOFA.MARK .BS 3
|
||||
*/--------------------------------------
|
||||
* # RemoveYA
|
||||
*\--------------------------------------
|
||||
K.RemoveYA jsr PFT.CheckPathYA
|
||||
>STYA K.MLI.PARAMS+1
|
||||
>MLICALL MLIDESTROY
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # Rename
|
||||
* Rename a file
|
||||
* ## In :
|
||||
* PUSHW = New Name
|
||||
* PUSHW = Old Name
|
||||
* ## Out :
|
||||
*\--------------------------------------
|
||||
K.Rename jsr PFT.CheckPathSTK
|
||||
>PULLW K.MLI.PARAMS+1
|
||||
>PULLW K.MLI.PARAMS+3
|
||||
>MLICALL MLIRename
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # Stat
|
||||
* Return information about a file
|
||||
* ## In :
|
||||
* PUSHW = PTR to S.STAT buffer
|
||||
* PUSHW = PTR to Filename (PSTR)
|
||||
* ## Out :
|
||||
*\--------------------------------------
|
||||
K.Stat jsr PFT.CheckPathSTK
|
||||
>PULLW K.MLI.PARAMS+1
|
||||
>PULLW K.Stat.StoreY+1
|
||||
>MLICALL MLIGETFILEINFO
|
||||
bcs .9
|
||||
|
||||
ldx K.MLI.PARAMS+S.FILEINFO.ACCESS
|
||||
|
||||
lda #S.STAT.MODE.XO+S.STAT.MODE.WO+S.STAT.MODE.RO
|
||||
cpx #S.FILEINFO.ACCESS.FULL
|
||||
beq .2
|
||||
|
||||
lda #S.STAT.MODE.XO+S.STAT.MODE.RO
|
||||
cpx #S.FILEINFO.ACCESS.R
|
||||
beq .2
|
||||
|
||||
lda #0
|
||||
|
||||
.2 ldy #S.STAT.MODE
|
||||
jsr K.Stat.StoreY
|
||||
|
||||
ldx #K.Stat.DST-K.Stat.SRC
|
||||
|
||||
.3 ldy K.Stat.SRC-1,x
|
||||
lda K.MLI.PARAMS,y
|
||||
ldy K.Stat.DST-1,x
|
||||
jsr K.Stat.StoreY
|
||||
dex
|
||||
bne .3
|
||||
|
||||
ldy #S.STAT.SIZE
|
||||
lda #0
|
||||
jsr K.Stat.StoreY
|
||||
|
||||
iny
|
||||
|
||||
lda K.MLI.PARAMS+S.FILEINFO.BLOCKSUSED
|
||||
asl
|
||||
jsr K.Stat.StoreY
|
||||
|
||||
iny
|
||||
|
||||
lda K.MLI.PARAMS+S.FILEINFO.BLOCKSUSED+1
|
||||
rol
|
||||
jsr K.Stat.StoreY
|
||||
|
||||
iny
|
||||
|
||||
lda #0
|
||||
rol
|
||||
jsr K.Stat.StoreY
|
||||
|
||||
clc
|
||||
.9 rts
|
||||
|
||||
K.Stat.StoreY sta $ffff,y
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.Stat.SRC .DA #S.FILEINFO.TYPE
|
||||
.DA #S.FILEINFO.AUXTYPE,#S.FILEINFO.AUXTYPE+1
|
||||
.DA #S.FILEINFO.BLOCKSUSED,#S.FILEINFO.BLOCKSUSED+1
|
||||
|
||||
K.Stat.DST .DA #S.STAT.P.TYPE
|
||||
.DA #S.STAT.P.AUXTYPE,#S.STAT.P.AUXTYPE+1
|
||||
.DA #S.STAT.BLOCKS,#S.STAT.BLOCKS+1
|
||||
* .DA #S.STAT.SIZE+1,#S.STAT.SIZE+2
|
||||
|
||||
*--------------------------------------
|
||||
FILE.SetIOBUF >PUSHWI 1024 get a ProDOS IOBUF
|
||||
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
|
||||
jsr K.GetMem
|
||||
bcs .9
|
||||
|
||||
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
|
||||
txa
|
||||
ldy #S.NODE.REG.IOBUF
|
||||
sta (ZPPtr1),y
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
FILE.SetupPrt1A jsr K.GetMemPtrA
|
||||
>STYA ZPPtr1
|
||||
ldy #S.NODE.REG.REF
|
||||
lda (ZPPtr1),y
|
||||
sta K.MLI.PARAMS+1
|
||||
rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.FILE
|
||||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||||
|
@ -353,8 +353,8 @@ PS.DupEnvA jsr K.GetMemPtrA
|
||||
clc
|
||||
.9 rts
|
||||
*/--------------------------------------
|
||||
* # PStr2StrArrayYA
|
||||
* Convert a PSTR (e.g. : command Line) to a Array of PSTRs (Args[])
|
||||
* # Str2StrArrayYA
|
||||
* Convert a CSTR (e.g. : command Line) to a Array of CSTRs (Args[])
|
||||
* ## In:
|
||||
* Y,A = PTR to String
|
||||
* ## Out:
|
||||
@ -364,7 +364,7 @@ PS.DupEnvA jsr K.GetMemPtrA
|
||||
* CS : error
|
||||
* A = SYS error code
|
||||
*\--------------------------------------
|
||||
PS.PStr2StrArrayYA
|
||||
PS.Str2StrArrayYA
|
||||
>STYA ZPPtr1
|
||||
lda (ZPPtr1) Get mem size STRLEN+1
|
||||
inc
|
||||
|
@ -232,6 +232,521 @@ K.GetSYA
|
||||
K.CHR.IOERR lda #MLI.ERR.IO
|
||||
sec
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # SScanF
|
||||
* Scan a PStr (in progress)
|
||||
* ## In:
|
||||
* PUSHW PTR to target buffer
|
||||
* PUSHW PSTR pattern (ex: "%d.%d.%d.%d")
|
||||
* %d : byte
|
||||
* PUSHW PSTR to scan (ex: "192.168.1.5")
|
||||
* ## Out:
|
||||
*\--------------------------------------
|
||||
K.SScanF jsr PullPtr1Ptr2Ptr3
|
||||
|
||||
ldy #0 Y = PTR in pattern
|
||||
|
||||
lda (ZPPtr1)
|
||||
beq .9
|
||||
tax X = COUNT to scan
|
||||
inc ZPPtr1
|
||||
bne .1
|
||||
inc ZPPtr1+1
|
||||
|
||||
.1 txa End Of String?
|
||||
beq .8
|
||||
tya
|
||||
cmp (ZPPtr2) End of pattern?
|
||||
beq .8
|
||||
iny
|
||||
lda (ZPPtr2),y
|
||||
cmp #'%' Escape?
|
||||
beq .2
|
||||
cmp (ZPPtr1) Same char?
|
||||
bne .9
|
||||
jsr K.SScanF.IncPtr1
|
||||
bne .1
|
||||
clc
|
||||
rts
|
||||
|
||||
.2 tya
|
||||
cmp (ZPPtr2) unexpected End of pattern after "%" ?
|
||||
beq .9
|
||||
|
||||
iny
|
||||
lda (ZPPtr2),y
|
||||
cmp #'d' BYTE ?
|
||||
bne .3
|
||||
|
||||
stz ASCBUF
|
||||
.20 lda (ZPPtr1)
|
||||
jsr K.SScanF.IsDigit
|
||||
bcs .21
|
||||
phx
|
||||
inc ASCBUF
|
||||
ldx ASCBUF
|
||||
sta ASCBUF,x
|
||||
plx
|
||||
jsr K.SScanF.IncPtr1
|
||||
bne .20 end of string ?
|
||||
|
||||
.21 jsr DEC2HEX
|
||||
lda HEXBUF
|
||||
sta (ZPPtr3)
|
||||
inc ZPPtr3
|
||||
bne .1
|
||||
inc ZPPtr3+1
|
||||
bra .1
|
||||
|
||||
.3 cmp #'D' WORD ?
|
||||
bne .4
|
||||
|
||||
bra .1
|
||||
|
||||
.4 cmp #'s' STRING ?
|
||||
bne .9
|
||||
|
||||
bra .1
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
|
||||
.9 sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.SScanF.IncPtr1
|
||||
dex
|
||||
beq .1
|
||||
inc ZPPtr1
|
||||
bne .1
|
||||
inc ZPPtr1+1 never Zero
|
||||
.1 rts
|
||||
*--------------------------------------
|
||||
K.SScanF.IsDigit
|
||||
cmp #'0'
|
||||
bcc .1
|
||||
cmp #'9'+1
|
||||
bcs .1
|
||||
rts
|
||||
.1 sec
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # PrintFYA/SPrintFYA/FPrintFYA
|
||||
* Prints C-Style String
|
||||
* ## In:
|
||||
* PrintFYA :
|
||||
* Y,A = PTR to CStr
|
||||
* SPrintFYA :
|
||||
* Y,A = PTR to CStr
|
||||
* PULLW = Ptr to Dst Buffer
|
||||
* FPrintFYA :
|
||||
* Y,A = PTR to CStr
|
||||
* PULLB = hNode
|
||||
* ## Out:
|
||||
* CC : success
|
||||
* CS : error code from Output
|
||||
* Specifiers :
|
||||
* %a : pull 2 bytes to Print Access right String 'drwxrwxrwx'
|
||||
* %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 2 bytes PTR to 4 bytes long unsigned DEC 0..4294967295
|
||||
* %e : pull 2 bytes PTR to 6 Bytes Real +1.23456789e+12
|
||||
* %f : pull 2 bytes PTR to 6 Bytes Real 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 2 bytes PTR to 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 %
|
||||
* Modifiers for len and padding :
|
||||
* %d : '9' '12'
|
||||
* %2d : ' 9' '12'
|
||||
* %02d : '09' '12'
|
||||
* %11s : 'ABCDEFGH '
|
||||
* %011s : 'ABCDEFGH000'
|
||||
* %2f : '3.14'
|
||||
*\--------------------------------------
|
||||
K.SPrintFYA >STYA ZPPtr1
|
||||
>PULLW Printf.Cout.Ptr+1
|
||||
|
||||
K.FPrintFYA >STYA ZPPtr1
|
||||
|
||||
K.PrintFYA >STYA ZPPtr1
|
||||
|
||||
ldy #0
|
||||
|
||||
.1 lda (ZPPtr1),y
|
||||
beq .99
|
||||
iny
|
||||
cmp #'%'
|
||||
bne .10
|
||||
|
||||
stz PADLEN
|
||||
lda #' '
|
||||
sta PADCHAR
|
||||
|
||||
.2 ldx #PrintFTBL2-PrintFTBL1-1
|
||||
lda (ZPPtr1),y
|
||||
beq .99
|
||||
iny
|
||||
|
||||
.3 cmp PrintFTBL1,x do we have a %x command?
|
||||
beq .8 yes, jmp to it!
|
||||
dex
|
||||
bpl .3 no valid letter...
|
||||
|
||||
cmp #'0' ...a 0...mmm... padding char?
|
||||
bne .4
|
||||
|
||||
ldx PADLEN PADLEN is not nul, so this 0 is second digit
|
||||
bne .5
|
||||
|
||||
lda #'0'
|
||||
sta PADCHAR no, this is the first 0, so make it PADCHAR
|
||||
bra .2
|
||||
|
||||
.4 bcc .99 less than '0'....error
|
||||
cmp #'9'+1
|
||||
bcs .99 more than '9' ....error
|
||||
|
||||
.5 and #$0F we have a digit
|
||||
pha save it...
|
||||
lda PADLEN starts PADLEN * 10
|
||||
asl
|
||||
asl A=times 4
|
||||
adc PADLEN CC by ASL, A=times 5
|
||||
asl times 10
|
||||
sta PADLEN
|
||||
|
||||
pla get back digit
|
||||
adc PADLEN
|
||||
sta PADLEN
|
||||
bra .2 go get next char...
|
||||
|
||||
.8 phy
|
||||
txa
|
||||
asl
|
||||
tax
|
||||
jsr PrintFESC
|
||||
ply
|
||||
bcc .1
|
||||
rts
|
||||
|
||||
.10 cmp #'\'
|
||||
bne .20
|
||||
|
||||
ldx #PrintFTBL2.OUT-PrintFTBL2-1
|
||||
lda (ZPPtr1),y
|
||||
beq .99
|
||||
iny
|
||||
|
||||
.12 cmp PrintFTBL2,x
|
||||
beq .13
|
||||
dex
|
||||
bpl .12
|
||||
bra .1
|
||||
|
||||
.13 lda PrintFTBL2.OUT,x
|
||||
|
||||
.20 jsr Printf.Cout
|
||||
bcc .1
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
PrintFESC jmp (PrintFJMP,x)
|
||||
*--------------------------------------
|
||||
PrintFTBL1 .AS "abBdDuefhHiILnNsS"
|
||||
PrintFTBL2 .AS "befnr\%"
|
||||
PrintFTBL2.OUT .HS 08.1B.0C.0A.0D \b\e\f\n\r
|
||||
.DA #'\' \\
|
||||
.DA #'%' \%
|
||||
PrintFJMP .DA PrintF.A
|
||||
.DA PrintF.B,PrintF.BB
|
||||
.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
|
||||
*--------------------------------------
|
||||
PrintF.A >PULLW HEXBUF
|
||||
|
||||
lda HEXBUF+1
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
tax
|
||||
lda TYPES,x
|
||||
jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
ldx #0
|
||||
|
||||
.1 lda #'-'
|
||||
lsr HEXBUF
|
||||
bcc .2
|
||||
lda ACCESS,x
|
||||
|
||||
.2 jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
inx
|
||||
cpx #8
|
||||
bne .1
|
||||
|
||||
.3 lda #'-'
|
||||
lsr HEXBUF+1
|
||||
bcc .4
|
||||
lda ACCESS,x
|
||||
|
||||
.4 jmp Printf.Cout
|
||||
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
PrintF.BB >PULLA
|
||||
pha
|
||||
jsr PrintF.B
|
||||
pla
|
||||
bcc PrintF.B.1
|
||||
PrintF.BB.RTS rts
|
||||
*--------------------------------------
|
||||
PrintF.B >PULLA
|
||||
|
||||
PrintF.B.1 ldx #8
|
||||
|
||||
.1 asl
|
||||
pha
|
||||
lda #'0'
|
||||
adc #0 add Carry
|
||||
jsr Printf.Cout
|
||||
pla
|
||||
bcs PrintF.BB.RTS
|
||||
dex
|
||||
bne .1
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.D >PULLB HEXBUF
|
||||
stz HEXBUF+1
|
||||
bra PrintF.DD.1
|
||||
|
||||
PrintF.DD >PULLW HEXBUF
|
||||
PrintF.DD.1 stz HEXBUF+2
|
||||
stz HEXBUF+3
|
||||
bra PrintF.U.1
|
||||
|
||||
PrintF.U >PULLW ZPPtr2
|
||||
ldy #3
|
||||
|
||||
.1 lda (ZPPtr2),y
|
||||
sta HEXBUF,y
|
||||
dey
|
||||
bpl .1
|
||||
|
||||
PrintF.U.1 stz SIGN
|
||||
jsr HEX2DEC
|
||||
jmp PrintDEC
|
||||
*--------------------------------------
|
||||
PrintF.E >PULLW ZPPtr2
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.F >PULLW ZPPtr2
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.HH >PULLA
|
||||
pha
|
||||
jsr PrintF.H
|
||||
pla
|
||||
bra PrintF.H.1
|
||||
*--------------------------------------
|
||||
PrintF.H >PULLA
|
||||
PrintF.H.1 pha
|
||||
jsr PrintF.NN.1
|
||||
pla
|
||||
jmp PrintF.N.1
|
||||
*--------------------------------------
|
||||
PrintF.I >PULLB HEXBUF
|
||||
eor #$ff if positive, it becomes neg so branch if....minus!
|
||||
clc
|
||||
bmi .1
|
||||
sec
|
||||
inc 2s complement...
|
||||
sta HEXBUF
|
||||
|
||||
|
||||
.1 stz HEXBUF+1
|
||||
bra PrintF.II.1
|
||||
|
||||
PrintF.II >PULLW HEXBUF A=HI
|
||||
eor #$ff
|
||||
clc
|
||||
bmi PrintF.II.1
|
||||
sec
|
||||
tax
|
||||
lda HEXBUF
|
||||
eor #$ff
|
||||
inc 2s complement...
|
||||
sta HEXBUF
|
||||
bne .1
|
||||
inx
|
||||
.1 sta HEXBUF
|
||||
stx HEXBUF+1
|
||||
|
||||
PrintF.II.1 stz HEXBUF+2
|
||||
stz HEXBUF+3
|
||||
bra PrintF.L.1
|
||||
|
||||
PrintF.L >PULLW ZPPtr2
|
||||
ldy #3
|
||||
|
||||
.1 lda (ZPPtr2),y
|
||||
sta HEXBUF,y
|
||||
dey
|
||||
bpl .1
|
||||
|
||||
|
||||
PrintF.L.1 ror SIGN
|
||||
jsr HEX2DEC
|
||||
*--------------------------------------
|
||||
PRINTDEC lda PADLEN any Len format ?
|
||||
beq .1 no
|
||||
|
||||
lda #10
|
||||
sec yes, Print only digits starting at pos 10-padlen
|
||||
sbc PADLEN
|
||||
|
||||
.1 tax x=0 if no padlen, or x=10-padlen
|
||||
|
||||
.2 lda ASCBUF,x
|
||||
cmp #'0' a zero?
|
||||
beq .3
|
||||
|
||||
inc PADLEN found a non zero, Print all digits, even if 0, next time
|
||||
ldy #'0'
|
||||
sty PADCHAR
|
||||
bra .4
|
||||
|
||||
.3 cpx #9 last digit ?
|
||||
beq .4 Print always
|
||||
|
||||
ldy PADLEN no pad to fill, do not Print 0
|
||||
beq .6
|
||||
|
||||
lda PADCHAR fill with PADCHAR
|
||||
|
||||
.4 bit SIGN a sign to print before digits ?
|
||||
bpl .5
|
||||
pha yes, save whatever we have to print....
|
||||
lda #'-'
|
||||
jsr Printf.Cout
|
||||
stz SIGN reset flag for next char...
|
||||
pla
|
||||
|
||||
.5 jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
.6 inx
|
||||
cpx #10
|
||||
bne .2
|
||||
|
||||
clc
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
PrintF.N >PULLA
|
||||
PrintF.N.1 and #$0F
|
||||
bra PrintF.NN.2
|
||||
|
||||
PrintF.NN >PULLA
|
||||
PrintF.NN.1 lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
|
||||
PrintF.NN.2 ora #$30
|
||||
cmp #$3A
|
||||
bcc .1
|
||||
adc #6
|
||||
.1 jmp Printf.Cout
|
||||
*--------------------------------------
|
||||
PrintF.S ldy #$ff CSTR
|
||||
.HS 2C bit abs
|
||||
PrintF.SS ldy #$00 PSTR
|
||||
|
||||
>PULLW ZPPtr2
|
||||
|
||||
lda (ZPPtr2) if CSTR:last char=0, if PSTR:len=0
|
||||
beq .8
|
||||
|
||||
sty .1+1
|
||||
|
||||
.1 lda #$ff Self Modified
|
||||
bne .11 CSTR
|
||||
|
||||
tya PSTR
|
||||
cmp (ZPPtr2) len check
|
||||
beq .2
|
||||
|
||||
.11 iny
|
||||
|
||||
lda (ZPPtr2),y
|
||||
beq .2
|
||||
|
||||
jsr Printf.Cout
|
||||
bcs .9
|
||||
|
||||
lda PADLEN
|
||||
beq .1
|
||||
|
||||
cpy PADLEN
|
||||
bne .1
|
||||
clc
|
||||
rts
|
||||
|
||||
.2 lda PADLEN
|
||||
beq .8
|
||||
|
||||
.3 lda PADCHAR
|
||||
jsr Printf.Cout
|
||||
bcs .9
|
||||
iny
|
||||
cpy PADLEN
|
||||
bne .3
|
||||
|
||||
.8 clc
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
Printf.Cout jmp K.PutCharA
|
||||
|
||||
Printf.Cout.Ptr sta $ffff Self modified
|
||||
*--------------------------------------
|
||||
FILE.SetIOBUF >PUSHWI 1024 get a ProDOS IOBUF
|
||||
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
|
||||
jsr K.GetMem
|
||||
bcs .9
|
||||
|
||||
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
|
||||
txa
|
||||
ldy #S.NODE.REG.IOBUF
|
||||
sta (ZPPtr1),y
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
FILE.SetupPrt1A jsr K.GetMemPtrA
|
||||
>STYA ZPPtr1
|
||||
ldy #S.NODE.REG.REF
|
||||
lda (ZPPtr1),y
|
||||
sta K.MLI.PARAMS+1
|
||||
rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.STDIO
|
||||
|
@ -57,6 +57,133 @@ SIGN .BS 1
|
||||
PADLEN .BS 1
|
||||
PADCHAR .BS 1
|
||||
*--------------------------------------
|
||||
* Convert HEXBUF to ASCBUF decimal padded with 0
|
||||
*--------------------------------------
|
||||
HEX2DEC ldx #4
|
||||
|
||||
.1 stz BCDBUF,x Clear all 5 bytes
|
||||
dex
|
||||
bpl .1
|
||||
|
||||
sed switch to BCD mode
|
||||
|
||||
ldx #32 let's roll 32 bits
|
||||
|
||||
.2 jsr HEXBUF.ROL
|
||||
|
||||
ldy #4
|
||||
|
||||
.3 lda BCDBUF,y
|
||||
adc BCDBUF,y
|
||||
sta BCDBUF,y
|
||||
dey
|
||||
bpl .3
|
||||
|
||||
dex
|
||||
bne .2
|
||||
|
||||
cld
|
||||
|
||||
ldy #4
|
||||
ldx #9
|
||||
|
||||
.4 lda BCDBUF,y
|
||||
pha
|
||||
and #$0F
|
||||
ora #$30
|
||||
sta ASCBUF,x
|
||||
dex
|
||||
pla
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ora #$30
|
||||
sta ASCBUF,x
|
||||
dey
|
||||
dex
|
||||
bpl .4
|
||||
|
||||
rts
|
||||
*--------------------------------------
|
||||
* Convert ASCBUF decimal to HEXBUF
|
||||
*--------------------------------------
|
||||
DEC2HEX stz HEXBUF
|
||||
stz HEXBUF+1
|
||||
stz HEXBUF+2
|
||||
stz HEXBUF+3
|
||||
|
||||
lda ASCBUF
|
||||
beq .8
|
||||
|
||||
ldx #0
|
||||
|
||||
.1 lda HEXBUF+3 save HEXBUF for 4+1
|
||||
pha
|
||||
lda HEXBUF+2
|
||||
pha
|
||||
lda HEXBUF+1
|
||||
pha
|
||||
lda HEXBUF
|
||||
pha
|
||||
|
||||
jsr HEXBUF.ROL HEXBUF * 2 -> HEXBUF
|
||||
* bcs .9 overflow!!!
|
||||
|
||||
jsr HEXBUF.ROL HEXBUF * 4 -> HEXBUF
|
||||
* bcs .9 overflow!!!
|
||||
|
||||
pla HEXBUF * 4 + HEXBUF -> HEXBUF
|
||||
adc HEXBUF
|
||||
sta HEXBUF
|
||||
pla
|
||||
adc HEXBUF+1
|
||||
sta HEXBUF+1
|
||||
pla
|
||||
adc HEXBUF+2
|
||||
sta HEXBUF+2
|
||||
pla
|
||||
adc HEXBUF+3
|
||||
sta HEXBUF+3
|
||||
* bcs .99 overflow!!!
|
||||
|
||||
jsr HEXBUF.ROL HEXBUF * 10 -> HEXBUF
|
||||
* bcs .99 overflow!!!
|
||||
|
||||
inx
|
||||
lda ASCBUF,x
|
||||
and #$0F
|
||||
|
||||
adc HEXBUF
|
||||
sta HEXBUF
|
||||
bcc .2
|
||||
inc HEXBUF+1
|
||||
bne .2
|
||||
inc HEXBUF+2
|
||||
bne .2
|
||||
inc HEXBUF+3
|
||||
|
||||
.2 cpx ASCBUF
|
||||
bne .1
|
||||
|
||||
.8 rts
|
||||
|
||||
*.9 pla discard saved HEXBUF
|
||||
* pla
|
||||
* pla
|
||||
* pla
|
||||
*.99 rts
|
||||
*--------------------------------------
|
||||
HEXBUF.ROL asl HEXBUF
|
||||
rol HEXBUF+1
|
||||
rol HEXBUF+2
|
||||
rol HEXBUF+3
|
||||
rts
|
||||
*--------------------------------------
|
||||
HEXBUF .BS 4 32 bits max
|
||||
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
||||
ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295)
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.STDLIB
|
||||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||||
|
@ -3,239 +3,6 @@ PREFIX /A2OSX.BUILD
|
||||
LOMEM $A00
|
||||
INC 1
|
||||
AUTO 6
|
||||
*/--------------------------------------
|
||||
* # NewPStrYA
|
||||
* Create a new copy of PSTR
|
||||
* ## In:
|
||||
* Y,A = PTR to buffer
|
||||
* ## Out:
|
||||
* CC : success
|
||||
* Y,A = PTR to String
|
||||
* X = hMem (PSTR)
|
||||
* CS : error
|
||||
* A = SYS error code
|
||||
*\--------------------------------------
|
||||
K.NewPStrYA >STYA ZPPtr2
|
||||
lda (ZPPtr2)
|
||||
inc
|
||||
tay
|
||||
lda #0 Y,A = len of new string
|
||||
jsr K.GetMemYA
|
||||
bcs .9
|
||||
|
||||
>STYA ZPPtr1
|
||||
|
||||
jsr K.PStrCpyPtr2Ptr1
|
||||
|
||||
>LDYA ZPPtr1
|
||||
|
||||
clc
|
||||
.9 rts
|
||||
*/--------------------------------------
|
||||
* # PStrCpy
|
||||
* Copy string
|
||||
* ## In:
|
||||
* PUSHW = Ptr to SRC (PSTR)
|
||||
* PUSHW = Ptr to DST (PSTR)
|
||||
* ## Out:
|
||||
* DST = SRC (PSTR)
|
||||
*\--------------------------------------
|
||||
K.PStrCpy jsr PullPtr1Ptr2
|
||||
|
||||
K.PStrCpyPtr2Ptr1
|
||||
lda (ZPPtr2)
|
||||
sta (ZPPtr1)
|
||||
tay
|
||||
beq .2
|
||||
|
||||
.1 lda (ZPPtr2),y
|
||||
sta (ZPPtr1),y
|
||||
dey
|
||||
bne .1
|
||||
|
||||
.2 clc
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # PStrCat
|
||||
* Append SRC to DST
|
||||
* ## In:
|
||||
* PUSHW = Ptr to SRC (PSTR)
|
||||
* PUSHW = Ptr to DST (PSTR)
|
||||
* ## Out:
|
||||
* DST = DST+SRC (PSTR)
|
||||
*\--------------------------------------
|
||||
K.PStrCat jsr PullPtr1Ptr2
|
||||
|
||||
lda (ZPPtr2)
|
||||
tax
|
||||
|
||||
lda (ZPPtr1)
|
||||
tay
|
||||
|
||||
.1 cpy #255
|
||||
beq .8
|
||||
|
||||
iny
|
||||
|
||||
inc ZPPtr2
|
||||
bne .2
|
||||
inc ZPPtr2+1
|
||||
|
||||
.2 lda (ZPPtr2)
|
||||
sta (ZPPtr1),y
|
||||
dex
|
||||
bne .1
|
||||
|
||||
.8 tya
|
||||
sta (ZPPtr1)
|
||||
clc
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # PStrMatch
|
||||
* Compare a String against pattern
|
||||
* ## In:
|
||||
* PUSHW = PTR to Pattern (e.g. '*test?.txt')
|
||||
* PUSHW = PTR to Src String
|
||||
* ## Out:
|
||||
* CC : match
|
||||
* CS : no match
|
||||
*\--------------------------------------
|
||||
K.PStrMatch jsr PullPtr1Ptr2
|
||||
|
||||
lda (ZPPtr2) Keep Pattern Length in X
|
||||
tax
|
||||
beq .8 Match always if empty
|
||||
ldy #0
|
||||
|
||||
.1 inc ZPPtr2 Make PTR1 advance to next char
|
||||
bne .2
|
||||
inc ZPPtr2+1
|
||||
|
||||
.2 lda (ZPPtr2) get pattern char
|
||||
cmp #'*'
|
||||
beq .5
|
||||
|
||||
.3 tya we must match ? or regular char
|
||||
cmp (ZPPtr1) check if at end of string
|
||||
beq .9 yes, no char left, exit with error
|
||||
|
||||
iny advance to next char to compare
|
||||
|
||||
lda (ZPPtr2) get back pattern char
|
||||
cmp #'?'
|
||||
beq .4 no need to compare, any char will match
|
||||
cmp (ZPPtr1),y Regular Char, compare with string at Y
|
||||
bne .9 no match, exit
|
||||
|
||||
.4 dex char matched, check if end of pattern
|
||||
bne .1 continue if remaining char in pattern
|
||||
|
||||
tya end of pattern, but end of string ?
|
||||
cmp (ZPPtr1) end of string ?
|
||||
beq .8 yes, string matched entirely
|
||||
bra .9 no, remaining char in string, no match
|
||||
|
||||
.5 dex we have '*', last char of pattern ?
|
||||
beq .8 yes, match everything, including empty string
|
||||
|
||||
inc ZPPtr2 Make PTR1 advance to next char
|
||||
bne .6
|
||||
inc ZPPtr2+1
|
||||
|
||||
.6 lda (ZPPtr2) get next char of pattern
|
||||
cmp #'*' another '*' ?
|
||||
beq .5 yes, '**' = '*', go next char
|
||||
cmp #'?' '*?' ??? we must match a least one char
|
||||
beq .3
|
||||
|
||||
.7 tya we need at least one remaining char in string,
|
||||
cmp (ZPPtr1) check if at end of string
|
||||
beq .9 no chance to match ? or regular char
|
||||
|
||||
iny
|
||||
lda (ZPPtr2) get again char in pattern
|
||||
cmp (ZPPtr1),y compare with char in string
|
||||
bne .7 not equal to next non wildcard in pattern
|
||||
|
||||
bra .4 go check remaining char in pattern...
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
|
||||
.9 sec
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # PStrUprYA/PStrLwrYA
|
||||
* Convert string to UPPERCASE/lowercase
|
||||
* ## In:
|
||||
* Y,A = PTR to String (PSTR)
|
||||
* ## Out:
|
||||
* Uppercased/lowercased String in Buffer
|
||||
*\--------------------------------------
|
||||
K.PStrUprYA ldx #0
|
||||
.HS 2C bit abs
|
||||
K.PStrLwrYA ldx #2
|
||||
>STYA ZPPtr1
|
||||
|
||||
pha save Y,A to restore them at exit
|
||||
phy
|
||||
|
||||
lda (ZPPtr1)
|
||||
tay
|
||||
|
||||
.1 lda (ZPPtr1),y
|
||||
cmp K.PStrUprLwr,x
|
||||
bcc .2
|
||||
cmp K.PStrUprLwr+1,x
|
||||
bcs .2
|
||||
eor #$20
|
||||
sta (ZPPtr1),y
|
||||
.2 dey
|
||||
bne .1
|
||||
|
||||
ply
|
||||
pla
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.PStrUprLwr .AS "azAZ"
|
||||
*--------------------------------------
|
||||
K.PStr2CStrYA >STYA ZPPtr1
|
||||
lda (ZPPtr1)
|
||||
beq .8
|
||||
pha
|
||||
|
||||
tay
|
||||
|
||||
.1 lda (ZPPtr1),y
|
||||
dey
|
||||
sta (ZPPtr1),y
|
||||
tya
|
||||
bne .1
|
||||
ply
|
||||
sta (ZPPtr1),y Ending 0
|
||||
|
||||
.8 rts
|
||||
*--------------------------------------
|
||||
K.CStr2PStrYA >STYA ZPPtr1
|
||||
|
||||
ldy #0
|
||||
|
||||
.1 lda (ZPPtr1),y
|
||||
beq .9
|
||||
|
||||
.2 pha
|
||||
iny
|
||||
lda (ZPPtr1),y
|
||||
tax
|
||||
pla
|
||||
sta (ZPPtr1),y
|
||||
txa
|
||||
bne .2
|
||||
|
||||
.8 tya
|
||||
sta (ZPPtr1)
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.STR
|
||||
|
@ -4,6 +4,29 @@ LOMEM $A00
|
||||
INC 1
|
||||
AUTO 6
|
||||
*/--------------------------------------
|
||||
* # StrLen.YA
|
||||
* Returns Length of C-String
|
||||
* ## In:
|
||||
* Y,A = Ptr to CSTR
|
||||
* ## Out:
|
||||
* Y,A = String length
|
||||
*\--------------------------------------
|
||||
K.StrLen.YA >STYA ZPPtr1
|
||||
|
||||
ldy #0
|
||||
ldx #0
|
||||
|
||||
.1 lda (ZPPtr1),y
|
||||
beq .8
|
||||
iny
|
||||
bne .1
|
||||
inx
|
||||
inc ZPPtr1+1
|
||||
bra .1
|
||||
|
||||
.8 txa
|
||||
rts
|
||||
*/--------------------------------------
|
||||
* # StrCat
|
||||
* Append SRC to DST
|
||||
* ## In:
|
||||
@ -156,248 +179,6 @@ K.StrLwrYA ldx #2
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.PStrUprLwr .AS "azAZ"
|
||||
*/--------------------------------------
|
||||
* # StrFTime
|
||||
* Convert S.TIME struct to CSTR
|
||||
* ## In:
|
||||
* PUSHW = Dst PTR To CSTR Buf
|
||||
* PUSHW = Src PTR To Format String
|
||||
* %a : Abbreviated weekday name : Thu
|
||||
* %A : Full weekday name : Thursday
|
||||
* %b : Abbreviated month name : Aug
|
||||
* %B : Full month name : August
|
||||
* %d : Day of the month, zero-padded (01-31)
|
||||
* %H : Hour in 24h format (00-23) 14
|
||||
* %I : Hour in 12h format (01-12) 02
|
||||
* %m : Month as a decimal number (01-12) 08
|
||||
* %M : Minute (00-59) 55
|
||||
* %p : AM or PM designation PM
|
||||
* %S : Second (00-61) 02
|
||||
* %w : Weekday as a decimal number with Sunday as 0 (0-6)
|
||||
* %y : Year, last two digits (00-99)
|
||||
* %Y : Year four digits 2001
|
||||
* PUSHW = Src PTR To S.Time
|
||||
* ## Out:
|
||||
* none. always succeed.
|
||||
*\--------------------------------------
|
||||
K.StrFTime jsr PullPtr1Ptr2Ptr3
|
||||
|
||||
ldy #0
|
||||
|
||||
.1 lda (ZPPtr2),y
|
||||
beq .8
|
||||
|
||||
iny
|
||||
|
||||
cmp #'%'
|
||||
beq .2
|
||||
|
||||
jsr K.StrFTime.addChar
|
||||
bra .1
|
||||
|
||||
.2 ldx #K.StrFTime.JMPL-K.StrFTime.Tbl-1
|
||||
|
||||
lda (ZPPtr2),y
|
||||
beq .8
|
||||
iny
|
||||
|
||||
.3 cmp K.StrFTime.Tbl,x
|
||||
beq .4
|
||||
dex
|
||||
bpl .3
|
||||
bra .1
|
||||
|
||||
.4 lda K.StrFTime.JMPL,x
|
||||
sta .5+1
|
||||
lda K.StrFTime.JMPH,x
|
||||
sta .5+2
|
||||
phy
|
||||
.5 jsr $ffff
|
||||
ply
|
||||
bra .1
|
||||
|
||||
.8 lda #0 Terminate C string
|
||||
sta (ZPPtr3)
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.StrFTime.TBL .AS "aAbBdHImMpSwyY"
|
||||
K.StrFTime.JMPL .DA #K.StrFTime.A
|
||||
.DA #K.StrFTime.AA
|
||||
.DA #K.StrFTime.B
|
||||
.DA #K.StrFTime.BB
|
||||
.DA #K.StrFTime.D
|
||||
.DA #K.StrFTime.HH
|
||||
.DA #K.StrFTime.II
|
||||
.DA #K.StrFTime.M
|
||||
.DA #K.StrFTime.MM
|
||||
.DA #K.StrFTime.P
|
||||
.DA #K.StrFTime.SS
|
||||
.DA #K.StrFTime.W
|
||||
.DA #K.StrFTime.Y
|
||||
.DA #K.StrFTime.YY
|
||||
*--------------------------------------
|
||||
K.StrFTime.JMPH .DA /K.StrFTime.A
|
||||
.DA /K.StrFTime.AA
|
||||
.DA /K.StrFTime.B
|
||||
.DA /K.StrFTime.BB
|
||||
.DA /K.StrFTime.D
|
||||
.DA /K.StrFTime.HH
|
||||
.DA /K.StrFTime.II
|
||||
.DA /K.StrFTime.M
|
||||
.DA /K.StrFTime.MM
|
||||
.DA /K.StrFTime.P
|
||||
.DA /K.StrFTime.SS
|
||||
.DA /K.StrFTime.W
|
||||
.DA /K.StrFTime.Y
|
||||
.DA /K.StrFTime.YY
|
||||
*--------------------------------------
|
||||
K.StrFTime.A ldx #3 Short day of week, 3 chars...
|
||||
.HS 2C Bit abs
|
||||
|
||||
K.StrFTime.AA ldx #15 full DoW
|
||||
>LDYAI K.StrFTime.DAY
|
||||
>STYA ZPPtr4
|
||||
ldy #S.Time.WDAY
|
||||
bra K.StrFTime.STR
|
||||
|
||||
K.StrFTime.B ldx #3 Short Month, 3 chars....
|
||||
.HS 2C Bit abs
|
||||
|
||||
K.StrFTime.BB ldx #15 full Month....
|
||||
>LDYAI K.StrFTime.MON
|
||||
>STYA ZPPtr4
|
||||
ldy #S.Time.MONTH
|
||||
|
||||
K.StrFTime.STR lda (ZPPtr1),y get required S.Time field value
|
||||
tay
|
||||
beq .9 Illegal value
|
||||
|
||||
.1 dey range 0..x
|
||||
beq .2
|
||||
lda (ZPPtr4)
|
||||
sec
|
||||
adc ZPPtr4
|
||||
sta ZPPtr4
|
||||
bcc .1
|
||||
inc ZPPtr4+1
|
||||
bra .1
|
||||
|
||||
.2 ldy #0
|
||||
|
||||
.3 iny
|
||||
lda (ZPPtr4),y
|
||||
phy
|
||||
jsr K.StrFTime.addChar
|
||||
pla
|
||||
cmp (ZPPtr4)
|
||||
beq .8
|
||||
|
||||
tay
|
||||
dex
|
||||
bne .3
|
||||
.8 rts
|
||||
|
||||
.9 ldx #3
|
||||
lda #'?'
|
||||
.99 jsr K.StrFTime.addChar
|
||||
dex
|
||||
bne .99
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.StrFTime.D ldy #S.Time.DAY
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.HH ldy #S.Time.HOUR
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.II ldy #S.Time.HOUR
|
||||
lda (ZPPtr1),y
|
||||
cmp #12
|
||||
bcc .1
|
||||
sbc #12
|
||||
.1 bra K.StrFTime.addDecA
|
||||
K.StrFTime.M ldy #S.Time.MONTH
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.MM ldy #S.Time.MINUTE
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.P ldy #S.Time.HOUR
|
||||
lda (ZPPtr1),y
|
||||
cmp #12
|
||||
bcc .1
|
||||
lda #'p'
|
||||
.HS 2C bit abs
|
||||
.1 lda #'a'
|
||||
jsr K.StrFTime.addChar
|
||||
lda #'m'
|
||||
bra K.StrFTime.addChar
|
||||
K.StrFTime.SS ldy #S.Time.SECOND
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.W ldy #S.Time.WDAY
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.YY ldy #S.Time.CENTURY
|
||||
jsr K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.Y ldy #S.Time.YEAR
|
||||
*--------------------------------------
|
||||
K.StrFTime.addDecPtr1Y
|
||||
lda (ZPPtr1),y
|
||||
K.StrFTime.addDecA
|
||||
sta K.StrFTime.BIN
|
||||
stz K.StrFTime.DEC
|
||||
|
||||
sed
|
||||
ldx #8
|
||||
|
||||
.1 asl K.StrFTime.BIN
|
||||
|
||||
lda K.StrFTime.DEC
|
||||
adc K.StrFTime.DEC
|
||||
sta K.StrFTime.DEC
|
||||
|
||||
dex
|
||||
bne .1
|
||||
|
||||
cld
|
||||
|
||||
* lda K.StrFTime.DEC already in A
|
||||
pha
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ora #$30
|
||||
jsr K.StrFTime.addChar
|
||||
pla
|
||||
and #$0f
|
||||
ora #$30
|
||||
*--------------------------------------
|
||||
K.StrFTime.addChar
|
||||
sta (ZPPtr3)
|
||||
inc ZPPtr3
|
||||
bne .8
|
||||
inc ZPPtr3+1
|
||||
.8 rts
|
||||
*--------------------------------------
|
||||
K.StrFTime.DAY >PSTR "Monday"
|
||||
>PSTR "Tuesday"
|
||||
>PSTR "Wednesday"
|
||||
>PSTR "Thursday"
|
||||
>PSTR "Friday"
|
||||
>PSTR "Saturday"
|
||||
>PSTR "Sunday"
|
||||
*--------------------------------------
|
||||
K.StrFTime.MON >PSTR "January"
|
||||
>PSTR "February"
|
||||
>PSTR "March"
|
||||
>PSTR "April"
|
||||
>PSTR "May"
|
||||
>PSTR "June"
|
||||
>PSTR "July"
|
||||
>PSTR "August"
|
||||
>PSTR "September"
|
||||
>PSTR "October"
|
||||
>PSTR "November"
|
||||
>PSTR "December"
|
||||
*--------------------------------------
|
||||
K.StrFTime.BIN .BS 1
|
||||
K.StrFTime.DEC .BS 1 always < 100
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.STRING
|
||||
|
@ -374,6 +374,249 @@ K.CTime.Div3600 .BS 1
|
||||
K.CTime.Mod .BS 1
|
||||
K.CTime.Century .BS 1
|
||||
K.CTime.Year .BS 1
|
||||
*/--------------------------------------
|
||||
* # StrFTime
|
||||
* Convert S.TIME struct to CSTR
|
||||
* ## In:
|
||||
* PUSHW = Dst PTR To CSTR Buf
|
||||
* PUSHW = Src PTR To Format String
|
||||
* %a : Abbreviated weekday name : Thu
|
||||
* %A : Full weekday name : Thursday
|
||||
* %b : Abbreviated month name : Aug
|
||||
* %B : Full month name : August
|
||||
* %d : Day of the month, zero-padded (01-31)
|
||||
* %H : Hour in 24h format (00-23) 14
|
||||
* %I : Hour in 12h format (01-12) 02
|
||||
* %m : Month as a decimal number (01-12) 08
|
||||
* %M : Minute (00-59) 55
|
||||
* %p : AM or PM designation PM
|
||||
* %S : Second (00-61) 02
|
||||
* %w : Weekday as a decimal number with Sunday as 0 (0-6)
|
||||
* %y : Year, last two digits (00-99)
|
||||
* %Y : Year four digits 2001
|
||||
* PUSHW = Src PTR To S.Time
|
||||
* ## Out:
|
||||
* none. always succeed.
|
||||
*\--------------------------------------
|
||||
K.StrFTime jsr PullPtr1Ptr2Ptr3
|
||||
|
||||
ldy #0
|
||||
|
||||
.1 lda (ZPPtr2),y
|
||||
beq .8
|
||||
|
||||
iny
|
||||
|
||||
cmp #'%'
|
||||
beq .2
|
||||
|
||||
jsr K.StrFTime.addChar
|
||||
bra .1
|
||||
|
||||
.2 ldx #K.StrFTime.JMPL-K.StrFTime.Tbl-1
|
||||
|
||||
lda (ZPPtr2),y
|
||||
beq .8
|
||||
iny
|
||||
|
||||
.3 cmp K.StrFTime.Tbl,x
|
||||
beq .4
|
||||
dex
|
||||
bpl .3
|
||||
bra .1
|
||||
|
||||
.4 lda K.StrFTime.JMPL,x
|
||||
sta .5+1
|
||||
lda K.StrFTime.JMPH,x
|
||||
sta .5+2
|
||||
phy
|
||||
.5 jsr $ffff
|
||||
ply
|
||||
bra .1
|
||||
|
||||
.8 lda #0 Terminate C string
|
||||
sta (ZPPtr3)
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.StrFTime.TBL .AS "aAbBdHImMpSwyY"
|
||||
K.StrFTime.JMPL .DA #K.StrFTime.A
|
||||
.DA #K.StrFTime.AA
|
||||
.DA #K.StrFTime.B
|
||||
.DA #K.StrFTime.BB
|
||||
.DA #K.StrFTime.D
|
||||
.DA #K.StrFTime.HH
|
||||
.DA #K.StrFTime.II
|
||||
.DA #K.StrFTime.M
|
||||
.DA #K.StrFTime.MM
|
||||
.DA #K.StrFTime.P
|
||||
.DA #K.StrFTime.SS
|
||||
.DA #K.StrFTime.W
|
||||
.DA #K.StrFTime.Y
|
||||
.DA #K.StrFTime.YY
|
||||
*--------------------------------------
|
||||
K.StrFTime.JMPH .DA /K.StrFTime.A
|
||||
.DA /K.StrFTime.AA
|
||||
.DA /K.StrFTime.B
|
||||
.DA /K.StrFTime.BB
|
||||
.DA /K.StrFTime.D
|
||||
.DA /K.StrFTime.HH
|
||||
.DA /K.StrFTime.II
|
||||
.DA /K.StrFTime.M
|
||||
.DA /K.StrFTime.MM
|
||||
.DA /K.StrFTime.P
|
||||
.DA /K.StrFTime.SS
|
||||
.DA /K.StrFTime.W
|
||||
.DA /K.StrFTime.Y
|
||||
.DA /K.StrFTime.YY
|
||||
*--------------------------------------
|
||||
K.StrFTime.A ldx #3 Short day of week, 3 chars...
|
||||
.HS 2C Bit abs
|
||||
|
||||
K.StrFTime.AA ldx #15 full DoW
|
||||
>LDYAI K.StrFTime.DAY
|
||||
>STYA ZPPtr4
|
||||
ldy #S.Time.WDAY
|
||||
bra K.StrFTime.STR
|
||||
|
||||
K.StrFTime.B ldx #3 Short Month, 3 chars....
|
||||
.HS 2C Bit abs
|
||||
|
||||
K.StrFTime.BB ldx #15 full Month....
|
||||
>LDYAI K.StrFTime.MON
|
||||
>STYA ZPPtr4
|
||||
ldy #S.Time.MONTH
|
||||
|
||||
K.StrFTime.STR lda (ZPPtr1),y get required S.Time field value
|
||||
tay
|
||||
beq .9 Illegal value
|
||||
|
||||
.1 dey range 0..x
|
||||
beq .2
|
||||
lda (ZPPtr4)
|
||||
sec
|
||||
adc ZPPtr4
|
||||
sta ZPPtr4
|
||||
bcc .1
|
||||
inc ZPPtr4+1
|
||||
bra .1
|
||||
|
||||
.2 ldy #0
|
||||
|
||||
.3 iny
|
||||
lda (ZPPtr4),y
|
||||
phy
|
||||
jsr K.StrFTime.addChar
|
||||
pla
|
||||
cmp (ZPPtr4)
|
||||
beq .8
|
||||
|
||||
tay
|
||||
dex
|
||||
bne .3
|
||||
.8 rts
|
||||
|
||||
.9 ldx #3
|
||||
lda #'?'
|
||||
.99 jsr K.StrFTime.addChar
|
||||
dex
|
||||
bne .99
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.StrFTime.D ldy #S.Time.DAY
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.HH ldy #S.Time.HOUR
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.II ldy #S.Time.HOUR
|
||||
lda (ZPPtr1),y
|
||||
cmp #12
|
||||
bcc .1
|
||||
sbc #12
|
||||
.1 bra K.StrFTime.addDecA
|
||||
K.StrFTime.M ldy #S.Time.MONTH
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.MM ldy #S.Time.MINUTE
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.P ldy #S.Time.HOUR
|
||||
lda (ZPPtr1),y
|
||||
cmp #12
|
||||
bcc .1
|
||||
lda #'p'
|
||||
.HS 2C bit abs
|
||||
.1 lda #'a'
|
||||
jsr K.StrFTime.addChar
|
||||
lda #'m'
|
||||
bra K.StrFTime.addChar
|
||||
K.StrFTime.SS ldy #S.Time.SECOND
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.W ldy #S.Time.WDAY
|
||||
bra K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.YY ldy #S.Time.CENTURY
|
||||
jsr K.StrFTime.addDecPtr1Y
|
||||
K.StrFTime.Y ldy #S.Time.YEAR
|
||||
*--------------------------------------
|
||||
K.StrFTime.addDecPtr1Y
|
||||
lda (ZPPtr1),y
|
||||
K.StrFTime.addDecA
|
||||
sta K.StrFTime.BIN
|
||||
stz K.StrFTime.DEC
|
||||
|
||||
sed
|
||||
ldx #8
|
||||
|
||||
.1 asl K.StrFTime.BIN
|
||||
|
||||
lda K.StrFTime.DEC
|
||||
adc K.StrFTime.DEC
|
||||
sta K.StrFTime.DEC
|
||||
|
||||
dex
|
||||
bne .1
|
||||
|
||||
cld
|
||||
|
||||
* lda K.StrFTime.DEC already in A
|
||||
pha
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
ora #$30
|
||||
jsr K.StrFTime.addChar
|
||||
pla
|
||||
and #$0f
|
||||
ora #$30
|
||||
*--------------------------------------
|
||||
K.StrFTime.addChar
|
||||
sta (ZPPtr3)
|
||||
inc ZPPtr3
|
||||
bne .8
|
||||
inc ZPPtr3+1
|
||||
.8 rts
|
||||
*--------------------------------------
|
||||
K.StrFTime.DAY >PSTR "Monday"
|
||||
>PSTR "Tuesday"
|
||||
>PSTR "Wednesday"
|
||||
>PSTR "Thursday"
|
||||
>PSTR "Friday"
|
||||
>PSTR "Saturday"
|
||||
>PSTR "Sunday"
|
||||
*--------------------------------------
|
||||
K.StrFTime.MON >PSTR "January"
|
||||
>PSTR "February"
|
||||
>PSTR "March"
|
||||
>PSTR "April"
|
||||
>PSTR "May"
|
||||
>PSTR "June"
|
||||
>PSTR "July"
|
||||
>PSTR "August"
|
||||
>PSTR "September"
|
||||
>PSTR "October"
|
||||
>PSTR "November"
|
||||
>PSTR "December"
|
||||
*--------------------------------------
|
||||
K.StrFTime.BIN .BS 1
|
||||
K.StrFTime.DEC .BS 1 always < 100
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.Time
|
||||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||||
|
Loading…
Reference in New Issue
Block a user