mirror of
https://github.com/A2osX/A2osX.git
synced 2025-01-11 10:29:46 +00:00
Kernel version 0.8 : Code reorg to save few bytes!
This commit is contained in:
parent
83a75b7fef
commit
7021210871
BIN
A2OSX.BOOT.po
BIN
A2OSX.BOOT.po
Binary file not shown.
BIN
A2OSX.SRC.po
BIN
A2OSX.SRC.po
Binary file not shown.
@ -405,14 +405,9 @@ LoadFile >PUSHWI 0 Aux type
|
||||
sec
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
SaveFile >PUSHWI 0 Aux type
|
||||
>PUSHBI 4 S.FILEINFO.TYPE.TXT
|
||||
>PUSHBI SYS.FOPEN.X+SYS.FOPEN.W
|
||||
ldy #hFileName
|
||||
SaveFile ldy #hBuffer
|
||||
lda (pData),y
|
||||
|
||||
>SYSCALL SYS.GetMemPtrA
|
||||
|
||||
>PUSHYA
|
||||
|
||||
ldy #FileLen+1
|
||||
@ -420,9 +415,14 @@ SaveFile >PUSHWI 0 Aux type
|
||||
dey
|
||||
>PUSHB (pData),y
|
||||
|
||||
ldy #hBuffer
|
||||
>PUSHWI 0 Aux type
|
||||
>PUSHBI 4 S.FILEINFO.TYPE.TXT
|
||||
>PUSHBI SYS.FOPEN.X+SYS.FOPEN.W
|
||||
ldy #hFileName
|
||||
lda (pData),y
|
||||
|
||||
>SYSCALL SYS.GetMemPtrA
|
||||
|
||||
>PUSHYA
|
||||
|
||||
>SYSCALL SYS.SaveFile
|
||||
|
@ -215,6 +215,13 @@ AUTO 6
|
||||
sta ]1+1
|
||||
inc pStack
|
||||
.EM
|
||||
*--------------------------------------
|
||||
.MA POP
|
||||
lda pStack
|
||||
clc
|
||||
adc ]1
|
||||
sta pStack
|
||||
.EM
|
||||
*--------------------------------------
|
||||
* General WORD Manipulation Macros
|
||||
*--------------------------------------
|
||||
|
@ -5,11 +5,11 @@ INC 1
|
||||
AUTO 6
|
||||
.LIST OFF
|
||||
*--------------------------------------
|
||||
*
|
||||
* PULLW PString to scan (ex: "192.168.1.5")
|
||||
* PULLW PString pattern (ex: "%d.%d.%d.%d")
|
||||
* PULLW PTR to target buffer
|
||||
*--------------------------------------
|
||||
K.SScanF >PULLW ZPQuickPtr1 get PString to scan (ex: "192.168.1.5")
|
||||
>PULLW ZPQuickPtr2 get PString pattern (ex: "%d.%d.%d.%d")
|
||||
>PULLW ZPQuickPtr3 get target buffer
|
||||
K.SScanF jsr PullPtr1Ptr2Ptr3
|
||||
|
||||
ldy #0 Y = PTR in pattern
|
||||
|
||||
@ -261,8 +261,8 @@ PrintF.A >PULLW HEXBUF
|
||||
.4 jsr K.COutA
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.BB >PULLYA
|
||||
phy
|
||||
PrintF.BB >PULLA
|
||||
pha
|
||||
jsr PrintF.B
|
||||
pla
|
||||
bra PrintF.B.1
|
||||
@ -308,9 +308,9 @@ PrintF.E >PULLW ZPQuickPtr2
|
||||
PrintF.F >PULLW ZPQuickPtr2
|
||||
rts
|
||||
*--------------------------------------
|
||||
PrintF.HH >PULLYA
|
||||
phy
|
||||
jsr PrintF.H.1
|
||||
PrintF.HH >PULLA
|
||||
pha
|
||||
jsr PrintF.H
|
||||
pla
|
||||
bra PrintF.H.1
|
||||
*--------------------------------------
|
||||
|
@ -64,15 +64,13 @@ K.FileSearch >PULLW ZPQuickPtr4 ZPQuickPtr1 trashed by ExpandPStrYA
|
||||
lda K.FileSearch.hSrch Discard Expanded hSrch list
|
||||
jsr K.FreeMemA
|
||||
|
||||
>LDYAI KrnBuf256
|
||||
>SYSCALL SYS.NewPStrYA
|
||||
.99 rts
|
||||
bra K.GetFullPathYA.NewStr
|
||||
|
||||
.98 lda K.FileSearch.hSrch Discard Expanded hSrch list
|
||||
jsr K.FreeMemA
|
||||
lda #SYSMGR.ERRFNF
|
||||
sec
|
||||
rts
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
K.FileSearch.hSrch .BS 1
|
||||
K.FileSearch.Index .BS 1
|
||||
@ -86,7 +84,7 @@ K.FileSearch.Index .BS 1
|
||||
*--------------------------------------
|
||||
K.GetFullPathYA >STYA ZPQuickPtr3 Ptr1 & 2 used by StrCpy
|
||||
lda (ZPQuickPtr3)
|
||||
beq .9
|
||||
beq K.GetFullPathYA.9
|
||||
|
||||
stz KrnBuf256
|
||||
|
||||
@ -105,12 +103,13 @@ K.GetFullPathYA >STYA ZPQuickPtr3 Ptr1 & 2 used by StrCpy
|
||||
.1 >PUSHW ZPQuickPtr3
|
||||
>PUSHWI KrnBuf256
|
||||
>SYSCALL SYS.PStrCat
|
||||
|
||||
K.GetFullPathYA.NewStr
|
||||
>LDYAI KrnBuf256
|
||||
>SYSCALL SYS.NewPStrYA
|
||||
rts
|
||||
|
||||
.9 sec
|
||||
K.GetFullPathYA.9
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
* K.LoadFile
|
||||
@ -186,25 +185,18 @@ K.LoadFile.Seek >PUSHWI 0
|
||||
>PUSHB K.LoadFile.hFile
|
||||
jmp K.FSEEK
|
||||
*--------------------------------------
|
||||
* PULLW = SrcPtr
|
||||
* PULLW = SrcLen
|
||||
* PULLW = PATH (Handled by....
|
||||
* PULLB = MODE ...
|
||||
* PULLB = TYPE ...
|
||||
* PULLW = AUXTYPE ...FOPEN)
|
||||
* PULLW = SrcLen
|
||||
* PULLW = SrcPtr
|
||||
*--------------------------------------
|
||||
K.SaveFile >PULLW K.LoadFile.Mem
|
||||
>PULLW K.LoadFile.Len
|
||||
|
||||
jsr K.FOPEN
|
||||
K.SaveFile jsr K.FOPEN
|
||||
bcs .9
|
||||
|
||||
sta K.LoadFile.hFile
|
||||
|
||||
>PUSHW K.LoadFile.Mem
|
||||
|
||||
>PUSHW K.LoadFile.Len
|
||||
|
||||
>PUSHB K.LoadFile.hFile
|
||||
jsr K.FWRITE
|
||||
bcs .99
|
||||
@ -218,8 +210,12 @@ K.SaveFile >PULLW K.LoadFile.Mem
|
||||
jsr K.FCLOSEA
|
||||
pla
|
||||
sec
|
||||
rts
|
||||
|
||||
.9 rts
|
||||
|
||||
.9 >POP 4 Discard SrcPtr & SrcLen
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
K.LoadFile.hFile .BS 1
|
||||
K.LoadFile.hMem .BS 1
|
||||
|
@ -12,8 +12,8 @@ AUTO 6
|
||||
* Y,A = PTR to String
|
||||
* X = hMem (PSTRING)
|
||||
*--------------------------------------
|
||||
K.NewPStrYA >STYA ZPQuickPtr1
|
||||
lda (ZPQuickPtr1)
|
||||
K.NewPStrYA >STYA ZPQuickPtr2
|
||||
lda (ZPQuickPtr2)
|
||||
inc
|
||||
tay
|
||||
lda #0 Y,A = len of new string
|
||||
@ -22,11 +22,11 @@ K.NewPStrYA >STYA ZPQuickPtr1
|
||||
jsr K.GetMem
|
||||
bcs .9
|
||||
|
||||
>STYA ZPQuickPtr2
|
||||
>STYA ZPQuickPtr1
|
||||
|
||||
jsr K.PStrCpyPtr1Ptr2
|
||||
jsr K.PStrCpyPtr2Ptr1
|
||||
|
||||
>LDYA ZPQuickPtr2
|
||||
>LDYA ZPQuickPtr1
|
||||
|
||||
clc
|
||||
.9 rts
|
||||
@ -38,17 +38,16 @@ K.NewPStrYA >STYA ZPQuickPtr1
|
||||
* OUT:
|
||||
* DST = SRC (PSTRING)
|
||||
*--------------------------------------
|
||||
K.PStrCpy >PULLW ZPQuickPtr2 save DST
|
||||
>PULLW ZPQuickPtr1 save SRC
|
||||
|
||||
K.PStrCpyPtr1Ptr2
|
||||
lda (ZPQuickPtr1)
|
||||
sta (ZPQuickPtr2)
|
||||
K.PStrCpy jsr PullPtr1Ptr2
|
||||
|
||||
K.PStrCpyPtr2Ptr1
|
||||
lda (ZPQuickPtr2)
|
||||
sta (ZPQuickPtr1)
|
||||
tay
|
||||
beq .2
|
||||
|
||||
.1 lda (ZPQuickPtr1),y
|
||||
sta (ZPQuickPtr2),y
|
||||
.1 lda (ZPQuickPtr2),y
|
||||
sta (ZPQuickPtr1),y
|
||||
dey
|
||||
bne .1
|
||||
|
||||
@ -62,13 +61,12 @@ K.PStrCpyPtr1Ptr2
|
||||
* OUT:
|
||||
* DST = DST+SRC (PSTRING)
|
||||
*--------------------------------------
|
||||
K.PStrCat >PULLW ZPQuickPtr2 save DST
|
||||
>PULLW ZPQuickPtr1 save SRC
|
||||
|
||||
lda (ZPQuickPtr1)
|
||||
tax
|
||||
K.PStrCat jsr PullPtr1Ptr2
|
||||
|
||||
lda (ZPQuickPtr2)
|
||||
tax
|
||||
|
||||
lda (ZPQuickPtr1)
|
||||
tay
|
||||
|
||||
.1 cpy #255
|
||||
@ -76,17 +74,17 @@ K.PStrCat >PULLW ZPQuickPtr2 save DST
|
||||
|
||||
iny
|
||||
|
||||
inc ZPQuickPtr1
|
||||
inc ZPQuickPtr2
|
||||
bne .2
|
||||
inc ZPQuickPtr1+1
|
||||
|
||||
.2 lda (ZPQuickPtr1)
|
||||
sta (ZPQuickPtr2),y
|
||||
.2 lda (ZPQuickPtr2)
|
||||
sta (ZPQuickPtr1),y
|
||||
dex
|
||||
bne .1
|
||||
|
||||
.8 tya
|
||||
sta (ZPQuickPtr2)
|
||||
sta (ZPQuickPtr1)
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
@ -98,62 +96,61 @@ K.PStrCat >PULLW ZPQuickPtr2 save DST
|
||||
* cc = match
|
||||
* cs = no match
|
||||
*--------------------------------------
|
||||
K.PStrMatch >PULLW ZPQuickPtr2 pull String
|
||||
>PULLW ZPQuickPtr1 pull Pattern
|
||||
|
||||
lda (ZPQuickPTR1) Keep Pattern Length in X
|
||||
K.PStrMatch jsr PullPtr1Ptr2
|
||||
|
||||
lda (ZPQuickPTR2) Keep Pattern Length in X
|
||||
tax
|
||||
beq .8 Match always if empty
|
||||
ldy #0
|
||||
|
||||
.1 inc ZPQuickPTR1 Make PTR1 advance to next char
|
||||
.1 inc ZPQuickPTR2 Make PTR1 advance to next char
|
||||
bne .2
|
||||
inc ZPQuickPTR1+1
|
||||
inc ZPQuickPTR2+1
|
||||
|
||||
.2 lda (ZPQuickPTR1) get pattern char
|
||||
.2 lda (ZPQuickPTR2) get pattern char
|
||||
cmp #'*'
|
||||
beq .5
|
||||
|
||||
.3 tya we must match ? or regular char
|
||||
cmp (ZPQuickPTR2) check if at end of string
|
||||
cmp (ZPQuickPTR1) check if at end of string
|
||||
beq .9 yes, no char left, exit with error
|
||||
|
||||
iny advance to next char to compare
|
||||
|
||||
lda (ZPQuickPTR1) get back pattern char
|
||||
lda (ZPQuickPTR2) get back pattern char
|
||||
cmp #'?'
|
||||
beq .4 no need to compare, any char will match
|
||||
cmp (ZPQuickPTR2),y Regular Char, compare with string at Y
|
||||
cmp (ZPQuickPTR1),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 (ZPQuickPTR2) end of string ?
|
||||
cmp (ZPQuickPTR1) 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 ZPQuickPTR1 Make PTR1 advance to next char
|
||||
inc ZPQuickPTR2 Make PTR1 advance to next char
|
||||
bne .6
|
||||
inc ZPQuickPTR1+1
|
||||
inc ZPQuickPTR2+1
|
||||
|
||||
.6 lda (ZPQuickPTR1) get next char of pattern
|
||||
.6 lda (ZPQuickPTR2) 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 (ZPQuickPTR2) check if at end of string
|
||||
cmp (ZPQuickPTR1) check if at end of string
|
||||
beq .9 no chance to match ? or regular char
|
||||
|
||||
iny
|
||||
lda (ZPQuickPTR1) get again char in pattern
|
||||
cmp (ZPQuickPTR2),y compare with char in string
|
||||
lda (ZPQuickPTR2) get again char in pattern
|
||||
cmp (ZPQuickPTR1),y compare with char in string
|
||||
bne .7 not equal to next non wildcard in pattern
|
||||
|
||||
bra .4 go check remaining char in pattern...
|
||||
@ -220,9 +217,7 @@ K.PStrUprLwr .AS "azAZ"
|
||||
* %Y Year four digits 2001
|
||||
* PULLW = Dst PSTR Buffer
|
||||
*--------------------------------------
|
||||
K.PStrFTime >PULLW ZPQuickPtr1
|
||||
>PULLW ZPQuickPtr2
|
||||
>PULLW ZPQuickPtr3
|
||||
K.PStrFTime jsr PullPtr1Ptr2Ptr3
|
||||
|
||||
lda #0
|
||||
sta (ZPQuickPtr3) Reset target PSTR length
|
||||
|
@ -28,8 +28,7 @@ K.TimeYA >STYA ZPQuickPtr2
|
||||
* PULLW = Src PDATE/TIME (DWORD)
|
||||
* PULLW = Dst PTR To S.TIME
|
||||
*--------------------------------------
|
||||
K.PTime2Time >PULLW ZPQuickPtr1
|
||||
>PULLW ZPQuickPtr2
|
||||
K.PTime2Time jsr PullPtr1Ptr2
|
||||
|
||||
K.PTime2Time.1 ldy #1
|
||||
lda (ZPQuickPtr1),y Get Year
|
||||
@ -165,8 +164,7 @@ K.ComputeWDAY lda #3 Thursday : 4 (-1 for mod 7)
|
||||
* PULLW = Src CTIME DWORD
|
||||
* PULLW = Dst PTR To S.TIME
|
||||
*--------------------------------------
|
||||
K.CTime2Time >PULLW ZPQuickPtr1
|
||||
>PULLW ZPQuickPtr2
|
||||
K.CTime2Time jsr PullPtr1Ptr2
|
||||
|
||||
ldy #3
|
||||
|
||||
|
@ -99,6 +99,16 @@ A2osX.E000 .EQ *
|
||||
.INB SYS/KERNEL.S.IRQ
|
||||
.INB SYS/KERNEL.S.MEM
|
||||
*--------------------------------------
|
||||
PullPtr1Ptr2Ptr3
|
||||
sec
|
||||
.HS 90 bcc
|
||||
PullPtr1Ptr2 clc
|
||||
>PULLW ZPQuickPtr1
|
||||
>PULLW ZPQuickPtr2
|
||||
bcc .9
|
||||
>PULLW ZPQuickPtr3
|
||||
.9 rts
|
||||
*--------------------------------------
|
||||
* Make sure KERNEL.S.D01 is the last one
|
||||
*--------------------------------------
|
||||
.INB SYS/KERNEL.S.D01
|
||||
|
Loading…
x
Reference in New Issue
Block a user