A2osX/SYS/KERNEL.S.MEM.txt

784 lines
16 KiB
Plaintext
Raw Normal View History

2017-12-22 21:24:30 +00:00
NEW
2018-11-17 17:17:13 +00:00
PREFIX
2017-12-22 21:24:30 +00:00
AUTO 4,1
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-08-17 06:25:58 +00:00
ZPMemMgrSPtr .EQ ZPMEMMGR Pointer To Slot selected
ZPMemMgrTmp1 .EQ ZPMEMMGR+2
ZPMemMgrSize .EQ ZPMEMMGR+4
*/--------------------------------------
2018-06-18 06:22:50 +00:00
* # GetMem0
* Y,A = Size Requested
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* CC : success
* YA = PTR to Mem (ZERO Initialised)
* X = hMem
* CS :
* A = EC
2019-01-21 14:51:10 +00:00
*\--------------------------------------
MEM.ReqFlags .BS 1 store requested Flags
MEM.BestSlot .BS 1
2019-02-01 20:01:54 +00:00
*MEM.BestScore .BS 2
MEM.BestScore .EQ ZPMemMgrTmp1
2019-01-21 14:51:10 +00:00
*--------------------------------------
2018-06-18 06:22:50 +00:00
K.GetMem0 ldx #S.MEM.F.INIT0
.HS 2C bit abs
*/--------------------------------------
2018-06-18 06:22:50 +00:00
* # GetMem
* Y,A = Size Requested
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* CC : success
* YA = PTR to Mem (Uninitialised)
* X = hMem
* CS :
* A = EC
*\--------------------------------------
2018-06-18 06:22:50 +00:00
K.GetMem ldx #0
2019-01-21 14:51:10 +00:00
MEM.GetMem.YAX stx MEM.ReqFlags
sta ZPMemMgrSize+1
tya
2019-01-17 20:43:29 +00:00
bit #K.MEM.ALIGN-1 aligned ?
beq .10 yes, request it
2019-01-17 20:43:29 +00:00
and #K.MEM.nALIGNm1 align on boundary
clc
2019-01-17 20:43:29 +00:00
adc #K.MEM.ALIGN
bcc .10
inc ZPMemMgrSize+1
.10 sta ZPMemMgrSize
>LDYAI Mem.Table
2015-06-03 18:30:57 +00:00
>STYA ZPMemMgrSPtr
2019-01-21 14:51:10 +00:00
stz MEM.BestSlot
ldx #$ff
stx MEM.BestScore
stx MEM.BestScore+1
2015-06-03 18:30:57 +00:00
ldx #0 Current slot=0
2015-03-15 22:00:40 +00:00
bra .4 skip slot 0, Check if some free slot to reuse first
2015-06-03 18:30:57 +00:00
.1 inx move to next slot
jsr Mem.NextSlot
2015-03-14 21:48:35 +00:00
lda (ZPMemMgrSPtr) Get Flags
bmi .4 in use ?
2015-06-03 18:30:57 +00:00
2019-01-21 14:51:10 +00:00
.2 lda MEM.ReqFlags Found an empty slot
2015-03-14 21:48:35 +00:00
and #S.MEM.F.ALIGN is request needs a page align ?
beq .3
2015-06-03 18:30:57 +00:00
2015-03-14 21:48:35 +00:00
ldy #S.MEM.PTR
lda (ZPMemMgrSPtr),y get LO of PTR
bne .4 not page-aligned
2015-06-03 18:30:57 +00:00
2015-03-14 21:48:35 +00:00
.3 ldy #S.MEM.LEN
2019-01-21 14:51:10 +00:00
sec
2015-03-14 21:48:35 +00:00
lda (ZPMemMgrSPtr),y get LEN of this block
2019-01-21 14:51:10 +00:00
sbc ZPMemMgrSize compare with requested size
pha
2015-06-03 18:30:57 +00:00
2015-03-14 21:48:35 +00:00
iny
lda (ZPMemMgrSPtr),y
2019-01-21 14:51:10 +00:00
sbc ZPMemMgrSize+1
ply Y,A = SlotLen - ReqSize
bcc .4 req size > slot size
cpy MEM.BestScore
pha
sbc MEM.BestScore+1
pla
bcs .4 Delta is >= BestScore
bne .4 Delta is > 255...
sty MEM.BestScore
sta MEM.BestScore+1
stx MEM.BestSlot
2015-06-03 18:30:57 +00:00
.4 cpx Mem.LastSlot any other slot to check?
2015-06-03 18:30:57 +00:00
bne .1 last one, create a new slot
2019-01-21 14:51:10 +00:00
lda MEM.BestSlot
beq .5
tax
2019-01-30 06:20:13 +00:00
jsr MEM.GetMemByID
2019-01-21 14:51:10 +00:00
bra .7
2015-06-03 18:30:57 +00:00
*-------------- Create a New SLOT
2018-08-20 15:15:37 +00:00
2019-01-21 14:51:10 +00:00
.5 lda MEM.ReqFlags
2015-06-03 18:30:57 +00:00
and #S.MEM.F.ALIGN is request needs a page align ?
beq .6
lda Mem.Free target PTR will be page aligned ?
2015-06-03 18:30:57 +00:00
sec
sbc ZPMemMgrSize
2015-06-03 18:30:57 +00:00
beq .6 yes, allocate
tay no, reserve a free slot to fill gap
lda #0
jsr Mem.AddSlot X = new slot
2015-06-03 18:30:57 +00:00
bcs .9
2018-08-21 13:12:47 +00:00
lda #S.MEM.F.ALIGN Make sure marked FREE
sta (ZPMemMgrSPtr)
.6 >LDYA ZPMemMgrSize
jsr Mem.AddSlot X = new slot
2015-06-03 18:30:57 +00:00
bcs .9
2015-03-14 21:48:35 +00:00
*-------------- Reuse this SLOT
2019-01-21 14:51:10 +00:00
.7 lda MEM.ReqFlags get requested flags
2015-03-14 21:48:35 +00:00
ora #S.MEM.F.INUSE mark as in use
sta (ZPMemMgrSPtr)
2015-03-15 22:00:40 +00:00
2015-06-03 18:30:57 +00:00
and #S.MEM.F.INIT0
beq .8
ldy #S.MEM.PTR
lda (ZPMemMgrSPtr),y ZPMemMgrSPtr already set
sta .12+1
iny
lda (ZPMemMgrSPtr),y
sta .12+2
lda ZPMemMgrSize
eor #$ff
tay y=not lo count
lda ZPMemMgrSize+1
eor #$ff a=not hi count
phx
ldx #0
.11 iny
bne .12
inc
beq .13
.12 stz $ffff,x
inx
bne .11
inc .12+2
bra .11
2015-06-03 18:30:57 +00:00
.13 plx
2015-06-03 18:30:57 +00:00
.8 lda #0
2015-03-14 21:48:35 +00:00
ldy #S.MEM.BIN
sta (ZPMemMgrSPtr),y
2015-06-03 18:30:57 +00:00
inc Mark this slot used by one process
2015-03-14 21:48:35 +00:00
ldy #S.MEM.REFCNT
sta (ZPMemMgrSPtr),y
2015-03-15 22:00:40 +00:00
ldy #S.PS.PID
2015-06-03 18:30:57 +00:00
lda (pPs),y
2015-03-14 21:48:35 +00:00
ldy #S.MEM.OWNERPID
sta (ZPMemMgrSPtr),y
2018-12-20 16:23:43 +00:00
clc
2019-02-03 21:58:26 +00:00
jmp MEM.GetMEMPTR
2018-12-20 16:23:43 +00:00
* A = HI PTR,Y = LO PTR,X = Current hMem
2015-03-15 22:00:40 +00:00
.9 rts
2015-06-03 18:30:57 +00:00
*--------------------------------------
* Mem.AddSlot
2015-06-03 18:30:57 +00:00
* In:
* Y,A = Requested size
* Out:
*--------------------------------------
2017-10-27 14:56:46 +00:00
Mem.AddSlot >STYA ZPMemMgrTmp1 save req size
2018-08-11 10:57:57 +00:00
ldx Mem.LastSlot
2015-06-03 18:30:57 +00:00
inx
beq .99 > 255 ERR:OUT OF SLOT
lda Mem.Free Compute base PTR=FREE-REQ size
2015-03-14 21:48:35 +00:00
sec
2015-06-03 18:30:57 +00:00
sbc ZPMemMgrTmp1
tay save new Mem.Free LO
lda Mem.Free+1
2015-06-03 18:30:57 +00:00
sbc ZPMemMgrTmp1+1
pha save new Mem.Free HI
2015-06-03 18:30:57 +00:00
cpy Mem.LoMem
sbc Mem.LoMem+1
2015-06-03 18:30:57 +00:00
bcc .98 ERR out of mem
jsr Mem.NextSlot X,Y unmodified
tya get back Mem.Free LO
2015-03-15 22:00:40 +00:00
2015-06-03 18:30:57 +00:00
ldy #S.MEM.PTR
sta Mem.Free set as system Mem.Free value
2018-08-11 10:57:57 +00:00
sta (ZPMemMgrSPtr),y store it as base address of new slot
2015-06-03 18:30:57 +00:00
iny
pla get back Mem.Free HI
sta Mem.Free+1
2015-03-14 21:48:35 +00:00
sta (ZPMemMgrSPtr),y
2015-06-03 18:30:57 +00:00
iny
lda ZPMemMgrTmp1 get requested size
sta (ZPMemMgrSPtr),y setup slot LEN
iny
lda ZPMemMgrTmp1+1
2015-03-14 21:48:35 +00:00
sta (ZPMemMgrSPtr),y
2015-06-03 18:30:57 +00:00
stx Mem.LastSlot mark this slot allocated
2015-03-14 21:48:35 +00:00
clc
rts
2015-06-03 18:30:57 +00:00
.98 pla discard new Mem.Free HI
2015-06-03 18:30:57 +00:00
2018-10-21 20:54:07 +00:00
.99 lda #E.OOM
2015-06-03 18:30:57 +00:00
sec
rts
*--------------------------------------
2018-12-20 16:23:43 +00:00
MEM.NextSlot lda ZPMemMgrSPtr
2015-06-03 18:30:57 +00:00
clc
adc #S.MEM
2015-06-03 18:30:57 +00:00
sta ZPMemMgrSPtr
bcc .8
inc ZPMemMgrSPtr+1
.8 rts
*/--------------------------------------
2018-06-18 06:22:50 +00:00
* # FreeMem
2015-03-14 21:48:35 +00:00
* A = hMem To Free
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* none.
2018-08-21 13:12:47 +00:00
* (X unmodified)
*\--------------------------------------
2019-02-11 16:44:56 +00:00
K.FreeMem.MSG .AZ "FreeMem:hMem=$%h,PID=%d\r\n"
2018-11-26 16:36:55 +00:00
*--------------------------------------
2019-02-11 16:44:56 +00:00
K.FreeMem.ERR phx
2018-11-28 14:58:42 +00:00
2019-02-03 21:58:26 +00:00
phy hMem n Y
2019-02-11 16:44:56 +00:00
ldy #S.PS.PID
2018-11-26 16:36:55 +00:00
lda (pPS),y
2019-02-11 16:44:56 +00:00
>PUSHA
2018-10-17 15:31:29 +00:00
2018-11-26 16:36:55 +00:00
pla
>PUSHA
2019-02-11 16:44:56 +00:00
>PUSHBI 2
>LDYAI K.FreeMem.MSG
2018-11-28 14:58:42 +00:00
.1 >SYSCALL printf
2018-12-20 07:33:10 +00:00
plx
2018-12-20 16:23:43 +00:00
2018-11-26 16:36:55 +00:00
sec
rts
*--------------------------------------
K.FreeMem tay
2019-02-11 16:44:56 +00:00
beq K.FreeMem.ERR Slot=0, reserved by Kernel
2018-11-26 16:36:55 +00:00
2018-08-20 15:15:37 +00:00
cmp Mem.LastSlot
bcc .10
2019-02-11 16:44:56 +00:00
bne K.FreeMem.ERR
2018-08-20 15:15:37 +00:00
2019-02-03 21:58:26 +00:00
.10 jsr MEM.GetMemByID X,Y unmodified
2018-11-28 14:58:42 +00:00
lda (ZPMemMgrSPtr) In use ?
2019-02-11 16:44:56 +00:00
bpl K.FreeMem.ERR
2018-11-28 14:58:42 +00:00
2019-02-03 21:58:26 +00:00
ldy #S.MEM.REFCNT
lda (ZPMemMgrSPtr),y
dec
sta (ZPMemMgrSPtr),y only one left ?
2015-06-03 18:30:57 +00:00
bne .8 no, must be a code segment loaded several times
2015-03-14 21:48:35 +00:00
2018-08-21 13:12:47 +00:00
lda (ZPMemMgrSPtr)
and #S.MEM.F.CODE CS: Any BINPATH to discard ?
sta (ZPMemMgrSPtr) Mark as FREE
2015-06-03 18:30:57 +00:00
beq .1
2015-03-14 21:48:35 +00:00
2018-08-21 13:12:47 +00:00
ldy #S.MEM.BIN
lda (ZPMemMgrSPtr),y
2019-01-30 06:20:13 +00:00
jsr MEM.GetMemByID X unmodified
2015-03-14 21:48:35 +00:00
lda (ZPMemMgrSPtr)
2015-06-03 18:30:57 +00:00
bpl * ***MUST BE ALLOCATED***
2015-03-14 21:48:35 +00:00
2015-06-03 18:30:57 +00:00
lda #0 mark BINPATH slot as free
2015-03-14 21:48:35 +00:00
sta (ZPMemMgrSPtr)
.1 lda Mem.LastSlot
2015-06-03 18:30:57 +00:00
beq .8
2019-01-30 06:20:13 +00:00
jsr MEM.GetMemByID X unmodified
2015-03-14 21:48:35 +00:00
lda (ZPMemMgrSPtr)
bmi .8 used, exit
.2 dec Mem.LastSlot free! get previous....
2018-08-21 13:12:47 +00:00
beq .80 empty list: go set Mem.Free=Mem.HiMem
lda Mem.LastSlot
2019-01-30 06:20:13 +00:00
jsr MEM.GetMemByID X unmodified
lda (ZPMemMgrSPtr)
bpl .2 free again! loop
2015-06-03 18:30:57 +00:00
ldy #S.MEM.PTR
lda (ZPMemMgrSPtr),y set Mem.Free...
sta Mem.Free
2015-03-14 21:48:35 +00:00
iny
lda (ZPMemMgrSPtr),y
sta Mem.Free+1
2015-06-03 18:30:57 +00:00
2018-08-21 13:12:47 +00:00
.8 clc
2015-03-14 21:48:35 +00:00
rts
2018-08-21 13:12:47 +00:00
.80 >LDYA Mem.HiMem
>STYA Mem.Free
2018-08-21 13:12:47 +00:00
clc
rts
*/--------------------------------------
2018-06-18 06:22:50 +00:00
* # GetMemPtr
2018-08-21 13:12:47 +00:00
* A = hMem
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2018-08-21 13:12:47 +00:00
* Y,A = PTR to MemBlock
* (X unmodified)
*\--------------------------------------
* Optimized for :
2019-03-14 16:51:02 +00:00
* Mem.Table is page aligned at $800
* S.MEM is 8 bytes
2015-03-14 21:48:35 +00:00
*--------------------------------------
2018-12-17 07:02:03 +00:00
.DO Mem.Table=$800
.ELSE
!!!!!WARNING!!!!!
.FIN
.DO S.MEM=8
.ELSE
!!!!!WARNING!!!!!
.FIN
*--------------------------------------
2019-02-01 20:01:54 +00:00
K.GetMemPtr jsr MEM.GetMemByID
2019-02-03 21:58:26 +00:00
MEM.GetMEMPTR ldy #S.MEM.PTR
2018-08-21 13:12:47 +00:00
lda (ZPMemMgrSPtr),y
pha
iny
lda (ZPMemMgrSPtr),y
ply
rts
2019-02-01 20:01:54 +00:00
*--------------------------------------
2019-01-30 06:20:13 +00:00
MEM.GetMemByID sta ZPMemMgrSPtr
lda /Mem.Table/8
asl ZPMemMgrSPtr
rol
asl ZPMemMgrSPtr
rol
asl ZPMemMgrSPtr
rol
2015-03-14 21:48:35 +00:00
sta ZPMemMgrSPtr+1
rts
2019-03-15 16:20:28 +00:00
*--------------------------------------
ZPSListKeyID .EQ ZPMEMMGR+6
ZPSListDataPtr .EQ ZPMEMMGR+8
ZPSListDataLen .EQ ZPMEMMGR+10
ZPSListIBlkPtr .EQ ZPMEMMGR+12
ZPSListDBlkPtr .EQ ZPMEMMGR+14
*/--------------------------------------
2019-03-15 16:20:28 +00:00
* # SListGetData
2019-01-29 16:42:06 +00:00
* ## ASM
2019-03-15 16:20:28 +00:00
* `PUSHW DataOfs`
* `PUSHW DataLen`
* `PUSHW DataPtr`
2019-03-14 16:51:02 +00:00
* `PUSHW KeyID`
2019-01-29 16:42:06 +00:00
* `lda hSList`
2019-03-15 16:20:28 +00:00
* `>SYSCALL SListGetData`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2019-03-15 16:20:28 +00:00
* Y,A = Byte Count
2019-03-18 06:53:20 +00:00
* X = hMem (if DataPtr = 0)
2018-01-15 06:50:44 +00:00
*\--------------------------------------
2019-03-15 16:20:28 +00:00
K.SListGetData pha
2019-03-18 06:53:20 +00:00
>PULLW ZPSListKeyID
>PULLW ZPSListDataPtr
>PULLW ZPSListDataLen
2019-03-15 16:20:28 +00:00
>PULLW ZPMemMgrSize
pla
2019-03-18 06:53:20 +00:00
bra K.SListFree
pla
*/--------------------------------------
2019-03-15 16:20:28 +00:00
* # SListAddData
2019-01-29 16:42:06 +00:00
* ## ASM
2019-03-15 16:20:28 +00:00
* `PUSHW DataLen`
* `PUSHW DataPtr`
2019-03-14 16:51:02 +00:00
* `PUSHW KeyID`
2019-01-29 16:42:06 +00:00
* `lda hSList`
2019-03-15 16:20:28 +00:00
* `>SYSCALL SListAddData`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2019-01-29 16:42:06 +00:00
*\--------------------------------------
2019-03-18 06:53:20 +00:00
K.SListAddData
2019-01-29 16:42:06 +00:00
*/--------------------------------------
* # SListSetData
* ## ASM
2019-03-15 16:20:28 +00:00
* `PUSHW DataLen`
* `PUSHW DataPtr`
2019-03-14 16:51:02 +00:00
* `PUSHW KeyID`
2019-01-29 16:42:06 +00:00
* `lda hSList`
* `>SYSCALL SListSetData`
* ## RETURN VALUE
*\--------------------------------------
2019-01-30 06:20:13 +00:00
K.SListSetData pha
2019-03-18 06:53:20 +00:00
>PULLW ZPSListKeyID
>PULLW ZPSListDataPtr
2019-03-15 16:20:28 +00:00
>PULLW ZPSListDataLen
pla
2019-03-18 06:53:20 +00:00
bra K.SListFree
2019-01-29 16:42:06 +00:00
*/--------------------------------------
* # SListGetByID
* ## ASM
* `PUSHW KeyPtr`
* `PUSHW KeyID`
* `lda hSList`
* `>SYSCALL SListGetByID`
* ## RETURN VALUE
* Y,A = Next KeyID
*\--------------------------------------
2019-01-29 16:42:06 +00:00
K.SListGetByID pha
2019-03-15 16:20:28 +00:00
>PULLW ZPSListKeyID
2019-03-18 06:53:20 +00:00
>PULLW ZPSListDataPtr
2019-03-15 16:20:28 +00:00
pla
bra K.SListFree
*/--------------------------------------
2019-03-13 16:29:24 +00:00
* # SListNewKey
2019-01-29 16:42:06 +00:00
* ## ASM
* `PUSHW KeyPtr`
* `lda hSList`
2019-03-13 16:29:24 +00:00
* `>SYSCALL SListNewKey`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2019-03-13 16:29:24 +00:00
* Y,A = KeyID
2019-03-14 16:51:02 +00:00
* X = KeyLen
*\--------------------------------------
2019-03-13 16:29:24 +00:00
K.SListNewKey
*/--------------------------------------
* # SListLookup
2019-01-29 16:42:06 +00:00
* ## ASM
* `PUSHW KeyPtr`
* `lda hSList`
* `>SYSCALL SListLookup`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2019-01-29 16:42:06 +00:00
* Y,A = KeyID
2019-03-15 16:20:28 +00:00
* X = Key Length
*\--------------------------------------
2019-01-29 16:42:06 +00:00
K.SListLookup pha
2019-03-18 06:53:20 +00:00
>PULLW ZPSListDataPtr
2019-03-15 16:20:28 +00:00
pla
*/--------------------------------------
* # SListNew
2019-01-29 16:42:06 +00:00
* ## ASM
* `>SYSCALL SListNew`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
2019-01-29 16:42:06 +00:00
* A=hSList
*\--------------------------------------
2019-03-15 16:20:28 +00:00
K.SListNew
*/--------------------------------------
* # SListFree
2019-01-29 16:42:06 +00:00
* ## ASM
* `lda hSList`
* `>SYSCALL SListFree`
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
*\--------------------------------------
2019-03-15 16:20:28 +00:00
K.SListFree sta SETREADAUX
sta SETWRITEAUX
2019-02-01 20:01:54 +00:00
2019-03-15 16:20:28 +00:00
jsr X.SLIST
2019-02-01 20:01:54 +00:00
sta CLRREADAUX
2019-03-15 16:20:28 +00:00
sta CLRWRITEAUX
rts
*/--------------------------------------
2018-06-18 06:22:50 +00:00
* # NewStkObj
* Y,A = Size Requested
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* CC : success
* YA = PTR to Mem (Uninitialised)
* X = hMem
* CS :
* A = EC
*\--------------------------------------
2018-06-18 06:22:50 +00:00
K.NewStkObj ldx #SYS.GetMem
.HS 2C BIT ABS
*/--------------------------------------
2018-06-18 06:22:50 +00:00
* # FreeStkObj
* A = hMem To Free (AUX Memory)
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* none.
* (X,Y unmodified)
*\--------------------------------------
2018-06-18 06:22:50 +00:00
K.FreeStkObj ldx #SYS.FreeMem
2019-03-15 16:20:28 +00:00
sta SETREADAUX
sta SETWRITEAUX
2019-03-15 16:20:28 +00:00
jsr MEM.Kernel.JMP
sta CLRREADAUX
sta CLRWRITEAUX
rts
2019-03-15 16:20:28 +00:00
MEM.Kernel.JMP jmp (SYS.Kernel.JMP,x)
*/--------------------------------------
* # LoadStkObj
* Load a file in AUX memory (Stock Objects)
* PUSHW = AUXTYPE (Handled by....
* PUSHB = TYPE ...
* PUSHB = MODE ...
2019-02-01 20:01:54 +00:00
* LDYA = PATH ...FOpen)
2018-10-11 15:23:06 +00:00
* ## RETURN VALUE
* Y,A = File Length
* X = hMem of Loaded Object in AUX mem
*\--------------------------------------
2019-04-15 05:40:13 +00:00
K.LoadStkObj >SYSCALL LoadTxtFile To get ending \0
bcs .99
2019-04-11 15:59:57 +00:00
sty .81+1
sta .82+1
stx .8+1 Save MAIN hMem
2019-02-03 21:58:26 +00:00
iny
bne .1
inc +1 for ending 0
.1 >STYA A2L Save LEN temporarly
2018-06-22 14:59:24 +00:00
jsr K.NewStkObj
bcs .9
stx .80+1
>STYA A4L Save Destination Address in AUX
lda .8+1
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
>STYA A1L Save MAIN base Ptr
pha Add Allocated LEN
tya
clc
adc A2L
sta A2L
pla
adc A2L+1
sta A2L+1 to get End address in A2L/H
sec Main To Aux
jsr AuxMove
2019-02-03 21:58:26 +00:00
.8 lda #$ff SELF MODIFIED
2018-06-22 14:59:24 +00:00
jsr K.FreeMem release MAIN memory
2019-04-11 15:59:57 +00:00
.80 ldx #$ff Returns AUX hMem
.81 ldy #$ff and file len in Y,A
.82 lda #$ff
* clc
rts
.9 pha
jsr .8
pla
sec
.99 rts
2019-03-15 16:20:28 +00:00
*/--------------------------------------
* # GetStkObjData
* ## ASM
* `PUSHW DataLen`
* `PUSHW DataPtr`
* `lda hStkObj`
* `>SYSCALL GetStkObjData`
* ## RETURN VALUE
*\--------------------------------------
K.GetStkObjData sta SETREADAUX
jsr K.GetMemPtr
>STYA ZPMemMgrTmp1
>PULLW ZPSListDataLen
>PULLW ZPSListDataPtr
lda (ZPMemMgrTmp1),y
pha
iny
lda (ZPMemMgrTmp1),y
ply
sta CLRREADAUX
rts
*--------------------------------------
2019-01-11 16:06:05 +00:00
* in Y,A = buf size
*--------------------------------------
2019-03-18 06:53:20 +00:00
MEM.GetMainBuf sta CLRREADAUX
sta CLRWRITEAUX
jsr K.GetMem
sta SETREADAUX
sta SETWRITEAUX
rts
*--------------------------------------
2019-01-11 16:06:05 +00:00
MEM.GetKrnlBuf pha
tya
clc
adc DevMgr.Free
tax
pla
adc DevMgr.Free+1
bcs .99 we crossed $FFFF, out of mem
cpx #DevMgr.HiMem
pha
sbc /DevMgr.HiMem
bcs .98 No More Room...
ldy DevMgr.Free
stx DevMgr.Free
ldx DevMgr.Free+1
pla
sta DevMgr.Free+1
txa
* clc
rts
.98 pla
.99 lda #E.OOM
* sec
rts
*--------------------------------------
MEM.GetKeyCharY sta CLRREADAUX
2019-03-18 06:53:20 +00:00
lda (ZPSListDataPtr),y
sta SETREADAUX
beq MEM.IsDigit.9
MEM.IsIDValid cmp #'.'
beq MEM.IsDigit.8
cmp #'_'
beq MEM.IsDigit.8
MEM.IsDigitOrL cmp #'z'+1
bcs MEM.IsDigit.RTS
cmp #'a'
bcs MEM.IsDigit.8
MEM.IsDigitOrUC cmp #'Z'+1
bcs MEM.IsDigit.RTS
cmp #'A'
bcs MEM.IsDigit.8
MEM.IsDigit cmp #'9'+1
bcs MEM.IsDigit.RTS
cmp #'0'
bcs MEM.IsDigit.8
MEM.IsDigit.9 sec
MEM.IsDigit.RTS rts
MEM.IsDigit.8 clc
rts
*--------------------------------------
MEM.IsHexDigit jsr MEM.IsDigit
bcc .8
cmp #'A'
bcc MEM.IsDigit.9
cmp #'F'+1
bcc .1
cmp #'a'
bcc MEM.IsDigit.9
cmp #'f'+1
bcs MEM.IsDigit.RTS
eor #$20
.1
* clc
sbc #'A'-11 cc so A->10 (11-CC)
clc
.8 and #$0F
rts
*--------------------------------------
MEM.SetKeyCharY sta CLRWRITEAUX
2019-03-18 06:53:20 +00:00
sta (ZPSListDataPtr),y
sta SETWRITEAUX
rts
*--------------------------------------
MEM.GetDataByte sta CLRREADAUX
lda (ZPSListDataPtr)
sta SETREADAUX
bra MEM.SetDataByte.1
*--------------------------------------
MEM.SetDataByte sta CLRWRITEAUX
sta (ZPSListDataPtr)
sta SETWRITEAUX
MEM.SetDataByte.1
inc ZPSListDataPtr
bne .8
inc ZPSListDataPtr+1
.8 rts
*--------------------------------------
2019-04-11 15:59:57 +00:00
MEM.TXTPTR.GetY sta CLRREADAUX
lda (TXTPTR),y
sta SETREADAUX
rts
*--------------------------------------
MEM.TXTPTR.GetNext
sta CLRREADAUX
lda (TXTPTR)
sta SETREADAUX
beq .9
inc TXTPTR
bne .9
inc TXTPTR+1
.9 rts
*--------------------------------------
2018-09-07 14:12:42 +00:00
MEM.SPtr1PPtr2 >STYA ZPPtr1
>PULLW ZPPtr2
rts
*--------------------------------------
2019-01-26 14:01:05 +00:00
MEM.SPtr2PPtr1 >STYA ZPPtr2
>PULLW ZPPtr1
rts
*--------------------------------------
2018-10-25 15:31:41 +00:00
MEM.GetCharPtr1 lda (ZPPtr1)
beq MEM.GetCharPtr1.8
MEM.NextCharPtr1
inc ZPPtr1
bne MEM.GetCharPtr1.8
inc ZPPtr1+1 never Z
MEM.GetCharPtr1.8
rts
*--------------------------------------
2018-12-20 16:23:43 +00:00
MEM.AddYp1ToPtr1
sec
.HS 90 BCC
MEM.AddYToPtr1 clc
tya
adc ZPPtr1
sta ZPPtr1
bcc .8
inc ZPPtr1+1
.8 rts
*--------------------------------------
2018-10-25 15:31:41 +00:00
MEM.PutCharPtr2 sta (ZPPtr2)
2019-01-04 13:17:31 +00:00
MEM.NextCharPtr2
2018-10-25 15:31:41 +00:00
inc ZPPtr2
bne .8
inc ZPPtr2+1
.8 rts
*--------------------------------------
2019-02-19 14:51:33 +00:00
DevMgr.Stat .DA DevMgr.FreeMem
DevMgr.Free .DA DevMgr.FreeMem
.DA DevMgr.HiMem
2019-02-27 15:00:56 +00:00
DevMgr.DevIdx .DA #1
2019-02-19 14:51:33 +00:00
*--------------------------------------
2015-03-14 21:48:35 +00:00
MAN
2018-11-17 17:17:13 +00:00
SAVE USR/SRC/SYS/KERNEL.S.MEM
LOAD USR/SRC/SYS/KERNEL.S
2015-03-14 21:48:35 +00:00
ASM