diff --git a/SANDBOX.PO b/SANDBOX.PO index bd87b65..3a38286 100644 Binary files a/SANDBOX.PO and b/SANDBOX.PO differ diff --git a/src/inc/stdlib.plh b/src/inc/stdlib.plh index cc5104c..e9f7e7d 100644 --- a/src/inc/stdlib.plh +++ b/src/inc/stdlib.plh @@ -11,8 +11,15 @@ import stdlib // const restxt1 = $0001 const restxt2 = $0002 - const reshgr1 = $0004 - const reshgr2 = $0008 - const resxhgr1 = $0010 - const resxhgr2 = $0020 + const resxtxt1 = $0004 + const resxtxt2 = $0008 + const reshgr1 = $0010 + const reshgr2 = $0020 + const resxhgr1 = $0040 + const resxhgr2 = $0080 + // + // Module don't free memory + // + const modkeep = $1000 + const modinitkeep = $2000 end diff --git a/src/toolsrc/sb.pla b/src/toolsrc/sb.pla index cba1293..65757cd 100644 --- a/src/toolsrc/sb.pla +++ b/src/toolsrc/sb.pla @@ -62,12 +62,12 @@ const iobuffer = $0800 const databuff = $0C00 const strlinbuf = $1000 const strheapmap = $1500 -const strheapmsz = $40 // = memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map +const strheapmsz = $80 // = memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map const maxlnlen = 79 const strheap = $6800 -const strheasz = $2000 -const codebuff = $8800 -const codebuffsz = $3000 +const strheasz = $4000 +const codebuff = $A800 +const codebuffsz = $1000 const pgjmp = 16 const changed = 1 const insmode = 2 diff --git a/src/vmsrc/a1cmd.pla b/src/vmsrc/a1cmd.pla index bf87ae0..dc47944 100644 --- a/src/vmsrc/a1cmd.pla +++ b/src/vmsrc/a1cmd.pla @@ -2,6 +2,22 @@ const MODADDR = $1000 const inbuff = $200 const freemem = $0006 // +// System flags: memory allocator screen holes. +// +const restxt1 = $0001 +const restxt2 = $0002 +const resxtxt1 = $0004 +const resxtxt2 = $0008 +const reshgr1 = $0010 +const reshgr2 = $0020 +const resxhgr1 = $0040 +const resxhgr2 = $0080 +// +// Module don't free memory +// +const modkeep = $1000 +const modinitkeep = $2000 +// // CFFA1 addresses. // const CFFADest = $00 @@ -882,17 +898,18 @@ def loadmod(mod) // // Call init routine if it exists. // + fixup = 0 if init - fixup = adddef(init - defofst + bytecode, @deflast)() - modend = init - defofst + bytecode - else - fixup = 0 + fixup = adddef(init - defofst + bytecode, @deflast)() + if !(systemflags & modinitkeep) + modend = init - defofst + bytecode + fin fin // // Free up the end-of-module in main memory. // releaseheap(modend) - return fixup + return fixup | (systemflags & modkeep) end // // Command mode @@ -942,13 +959,17 @@ def execmod(modfile) if stodci(modfile, @moddci) saveheap = heap - savesym = lastsym - saveflags = systemflags - ^lastsym = 0 - perr = loadmod(@moddci) + savesym = lastsym + saveflags = systemflags + ^lastsym = 0 + perr = loadmod(@moddci) + if perr >= modkeep + perr = perr & ~modkeep + else + lastsym = savesym + heap = saveheap + fin systemflags = saveflags - lastsym = savesym - heap = saveheap fin end // diff --git a/src/vmsrc/cmd.pla b/src/vmsrc/cmd.pla index bc8be77..cd7b647 100644 --- a/src/vmsrc/cmd.pla +++ b/src/vmsrc/cmd.pla @@ -9,10 +9,17 @@ const freemem = $0006 // const restxt1 = $0001 const restxt2 = $0002 -const reshgr1 = $0004 -const reshgr2 = $0008 -const resxhgr1 = $0010 -const resxhgr2 = $0020 +const resxtxt1 = $0004 +const resxtxt2 = $0008 +const reshgr1 = $0010 +const reshgr2 = $0020 +const resxhgr1 = $0040 +const resxhgr2 = $0080 +// +// Module don't free memory +// +const modkeep = $1000 +const modinitkeep = $2000 // // Pedefined functions. // @@ -317,8 +324,8 @@ asm memxcpy end asm crout DEX - LDA #$8D - STA ESTKL,X + LDA #$0D + BNE + ; FALL THROUGH TO COUT end // @@ -984,7 +991,7 @@ def loadmod(mod) // // This is a bytcode def entry - add it to the def directory. // - adddef(defbank, rld=>1 - defofst + defaddr, @deflast) + adddef(defbank, rld=>1 - defofst + defaddr, @deflast) else addr = rld=>1 + modfix if uword_isge(addr, modaddr) // Skip fixups to header @@ -1047,21 +1054,25 @@ def loadmod(mod) // // Call init routine if it exists. // + fixup = 0 // This is repurposed for the return code if init fixup = adddef(defbank, init - defofst + defaddr, @deflast)() - if defbank - xheap = init - defofst + defaddr - else - modend = init - defofst + defaddr + if !(systemflags & modinitkeep) + // + // Free init routine unless initkeep + // + if defbank + xheap = init - defofst + defaddr + else + modend = init - defofst + defaddr + fin fin - else - fixup = 0 fin // // Free up the end-of-module in main memory. // releaseheap(modend) - return fixup + return fixup | (systemflags & modkeep) end // // Command mode @@ -1230,15 +1241,19 @@ def execmod(modfile) if stodci(modfile, @moddci) saveheap = heap - savexheap = xheap - savesym = lastsym - saveflags = systemflags - ^lastsym = 0 - perr = loadmod(@moddci) + savexheap = xheap + savesym = lastsym + saveflags = systemflags + ^lastsym = 0 + perr = loadmod(@moddci) + if perr >= modkeep + perr = perr & ~modkeep + else + lastsym = savesym + xheap = savexheap + heap = saveheap + fin systemflags = saveflags - lastsym = savesym - xheap = savexheap - heap = saveheap fin end // diff --git a/src/vmsrc/soscmd.pla b/src/vmsrc/soscmd.pla index aa3d00a..c5319e9 100644 --- a/src/vmsrc/soscmd.pla +++ b/src/vmsrc/soscmd.pla @@ -1,6 +1,22 @@ const membank = $FFEF const MODADDR = $1000 // +// System flags: memory allocator screen holes. +// +const restxt1 = $0001 +const restxt2 = $0002 +const resxtxt1 = $0004 +const resxtxt2 = $0008 +const reshgr1 = $0010 +const reshgr2 = $0020 +const resxhgr1 = $0040 +const resxhgr2 = $0080 +// +// Module don't free memory +// +const modkeep = $1000 +const modinitkeep = $2000 +// // SOS flags // const O_READ = 1 @@ -1084,12 +1100,11 @@ def loadmod(mod) // // Call init routine if it exists. // + fixup = 0 if init fixup = adddef(defext, init - defofst + defaddr, @deflast)() - else - fixup = 0 fin - return fixup + return fixup | (systemflags & modkeep) end // // Command mode @@ -1224,13 +1239,17 @@ def execmod(modfile) savesym = lastsym saveflags = systemflags perr = loadmod(@moddci) + if perr >= modkeep + perr = perr & ~modkeep + else + lastsym = savesym + heap = saveheap + while modid + modid = modid - 1 + seg_release(modseg[modid]) + loop + fin systemflags = saveflags - lastsym = savesym - heap = saveheap - while modid - modid = modid - 1 - seg_release(modseg[modid]) - loop fin end //