1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2026-04-20 01:16:36 +00:00

Clean up module loading and images

This commit is contained in:
David Schmenk
2024-03-07 18:36:47 -08:00
parent 1d099df299
commit c23cb6d239
8 changed files with 8 additions and 13 deletions
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4 -7
View File
@@ -988,7 +988,6 @@ def loadmod(mod)#1
if loadmod(moddep) < 0
return -perr
fin
prstr("Loaded "); prstr(@str); crout
fin
moddep = moddep + dcitos(moddep, @str)
loop
@@ -1033,12 +1032,10 @@ def loadmod(mod)#1
//
// Run through the DeFinition Dictionary.
//
prstr("Bytecode = "); prword(bytecode); crout
while ^rld == $02
//
// This is a bytcode def entry - add it to the def directory.
//
prstr("Add DEF: "); prword(rld=>1 + defofst); prstr(" -> "); prword(deflast); crout
adddef(rld=>1 + defofst, @deflast)
rld = rld + 4
loop
@@ -1048,7 +1045,7 @@ def loadmod(mod)#1
while ^rld
rld, addr, fixup = reloc(modfix, modofst, bytecode, rld)
if ^rld
*addr = ^rld & $10 ?? *addr + lookupextern(esd, rld->3) :: lookupdef(fixup + defofst, deftbl)
*addr = ^rld & $10 ?? *addr + lookupextern(esd, rld->3) :: lookupdef(fixup, deftbl)
rld = rld + 4
fin
loop
@@ -1062,12 +1059,11 @@ def loadmod(mod)#1
//
// EXPORT symbol - add it to the global symbol table.
//
addr = esd=>1 + defofst // modofst
addr = esd=>1 + modofst
if uword_isge(addr, bytecode)
//
// Use the def directory address for bytecode.
//
//addr = lookupdef(addr + defofst, deftbl)
addr = lookupdef(addr, deftbl)
fin
addsym(sym, addr)
@@ -1087,7 +1083,8 @@ def loadmod(mod)#1
//
fixup = modkeep
if init
fixup = adddef(init + defofst, @deflast)()
init = init + defofst
fixup = adddef(init, @deflast)()
if fixup < 0
perr = -fixup
fin
+4 -6
View File
@@ -979,7 +979,7 @@ def adddef(addr, deflast)#1
return defentry
end
def loadmod(mod)#1
word rdlen, modsize, bytecode, codefix, defofst, defcnt, init, initcode[], fixup
word rdlen, modsize, bytecode, defofst, defcnt, init, initcode[], fixup
word addr, defaddr, modaddr, modfix, modofst, modend
word deftbl, deflast
word moddep, rld, esd, sym
@@ -1074,15 +1074,13 @@ def loadmod(mod)#1
modofst = modfix - RELADDR
modend = modaddr + modsize
bytecode = defofst + modofst
defofst = bytecode - defofst
rld = modend // Re-Locatable Directory
esd = rld // Extern+Entry Symbol Directory
while ^esd // Scan to end of ESD
esd = esd + 4
loop
esd = esd + 1
defaddr = bytecode
codefix = defaddr - bytecode
defofst = defaddr - defofst
//
// Run through the DeFinition Dictionary.
//
@@ -1099,7 +1097,7 @@ def loadmod(mod)#1
while ^rld
rld, addr, fixup = reloc(modfix, modofst, bytecode, rld)
if ^rld
*addr = ^rld & $10 ?? *addr + lookupextern(esd, rld->3) :: lookupdef(fixup + codefix, deftbl)
*addr = ^rld & $10 ?? *addr + lookupextern(esd, rld->3) :: lookupdef(fixup, deftbl)
rld = rld + 4
fin
loop
@@ -1118,7 +1116,7 @@ def loadmod(mod)#1
//
// Use the def directory address for bytecode.
//
addr = lookupdef(addr + codefix, deftbl)
addr = lookupdef(addr, deftbl)
fin
addsym(sym, addr)
fin