1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-10-18 22:24:28 +00:00

Still lingering TEST problem

This commit is contained in:
David Schmenk 2018-01-08 21:41:28 -08:00
parent 71f5f061ee
commit dbc02bc1b6
4 changed files with 47 additions and 39 deletions

View File

@ -259,7 +259,7 @@ end
// Emit the pending sequence // Emit the pending sequence
// //
def emit_pending_seq#0 def emit_pending_seq#0
word lcl_pending, op word op, pending
// //
// This is called by some of the emit_*() functions to ensure that any // This is called by some of the emit_*() functions to ensure that any
// pending ops are emitted before they emit their own op when they are // pending ops are emitted before they emit their own op when they are
@ -270,16 +270,15 @@ def emit_pending_seq#0
// function calls back into itself it is a no-op. // function calls back into itself it is a no-op.
// //
if not pending_seq; return; fin if not pending_seq; return; fin
lcl_pending = pending_seq pending = pending_seq; pending_seq = NULL
pending_seq = NULL
if outflags & OPTIMIZE if outflags & OPTIMIZE
while optimize_seq(@lcl_pending, 0); loop while optimize_seq(@pending, 0); loop
if outflags & OPTIMIZE2 if outflags & OPTIMIZE2
while optimize_seq(@lcl_pending, 1); loop while optimize_seq(@pending, 1); loop
fin fin
fin fin
while lcl_pending while pending
op = lcl_pending op = pending
when op->opgroup when op->opgroup
// //
// Constant value // Constant value
@ -287,54 +286,61 @@ def emit_pending_seq#0
is CONST_GROUP is CONST_GROUP
if op->opcode == CONST_CODE if op->opcode == CONST_CODE
if op=>opval == $0000 // ZERO if op=>opval == $0000 // ZERO
emit_byte($00) ^codeptr = $00
codeptr++
elsif op=>opval & $FF00 == $0000 // Constant BYTE elsif op=>opval & $FF00 == $0000 // Constant BYTE
emit_byte($2A) *codeptr = $2A | (op->opval << 8)
emit_byte(op->opval) codeptr = codeptr + 2
elsif op=>opval & $FF00 == $FF00 // Constant $FF00 | BYTE elsif op=>opval & $FF00 == $FF00 // Constant $FF00 | BYTE
emit_byte($5E) *codeptr = $5E | (op->opval << 8)
emit_byte(op->opval) codeptr = codeptr + 2
else // Constant WORD else // Constant WORD
emit_byte($2C) codeptr->0 = $2C
emit_word(op=>opval) codeptr=>1 = op=>opval
codeptr = codeptr + 3
fin fin
else // Constant LOAD/STORE/CALL else // Constant LOAD/STORE/CALL
emit_byte(op->opcode) codeptr->0 = op->opcode
emit_word(op=>opval) codeptr=>1 = op=>opval
codeptr = codeptr + 3
fin fin
break break
// //
// Constant string // Constant string
// //
is CONSTR_GROUP is CONSTR_GROUP
emit_byte($2E) ^codeptr = $2E
codeptr++
emit_data(0, STR_TYPE, op=>opval, 0) emit_data(0, STR_TYPE, op=>opval, 0)
break break
// //
// Single op codes // Single op codes
// //
is STACK_GROUP is STACK_GROUP
emit_byte(op->opcode) ^codeptr = op->opcode
codeptr++
break break
// //
// Local address codes // Local address codes
// //
is LOCAL_GROUP is LOCAL_GROUP
emit_byte(op->opcode) *codeptr = op->opcode | (op->opoffset << 8)
emit_byte(op->opoffset) codeptr = codeptr + 2
break break
// //
// Global address codes // Global address codes
// //
is GLOBAL_GROUP is GLOBAL_GROUP
emit_byte(op->opcode) ^codeptr = op->opcode
codeptr++
emit_addr(op=>optag, op=>opoffset) emit_addr(op=>optag, op=>opoffset)
break break
// //
// Relative address codes // Relative address codes
// //
is RELATIVE_GROUP is RELATIVE_GROUP
emit_byte(op->opcode) ^codeptr = op->opcode
codeptr++
emit_reladdr(op=>optag) emit_reladdr(op=>optag)
break break
// //
@ -346,13 +352,14 @@ def emit_pending_seq#0
otherwise otherwise
return return
wend wend
lcl_pending = lcl_pending=>opnext; pending = pending=>opnext;
// //
// Free this op // Free this op
// //
op=>opnext = freeop_lst op=>opnext = freeop_lst
freeop_lst = op freeop_lst = op
loop loop
if codeptr - codebuff > codebufsz; exit_err(ERR_OVER|ERR_CODE|ERR_TABLE); fin
end end
// //
// Emit a sequence of ops (into the pending sequence) // Emit a sequence of ops (into the pending sequence)
@ -896,7 +903,7 @@ def writeRLD(refnum, modofst)#0
if not (type & RELATIVE_FIXUP) if not (type & RELATIVE_FIXUP)
if rldlen == 64 // Write out blocks of entries if rldlen == 64 // Write out blocks of entries
fileio:write(refnum, heapmark, rld - heapmark) fileio:write(refnum, heapmark, rld - heapmark)
rld = heapmark rld = heapmark
rldlen = 0 rldlen = 0
fin fin
if type & EXTERN_FIXUP if type & EXTERN_FIXUP
@ -925,6 +932,7 @@ end
// //
def writemodule(refnum)#0 def writemodule(refnum)#0
word hdrlen, esd, esdlen, modfix, modadj, modofst, fixups, updtptr word hdrlen, esd, esdlen, modfix, modadj, modofst, fixups, updtptr
// //
// Write module header // Write module header
// //

View File

@ -737,9 +737,6 @@ end
// //
// Symbol table routines. // Symbol table routines.
// //
def lookupsym(sym)#1
return lookuptbl(sym, symtbl)
end
def addsym(sym, addr)#0 def addsym(sym, addr)#0
while ^sym & $80 while ^sym & $80
^lastsym = ^sym ^lastsym = ^sym
@ -774,7 +771,7 @@ def lookupextern(esd, index)#1
sym = esd sym = esd
esd = esd + dcitos(esd, @str) esd = esd + dcitos(esd, @str)
if esd->0 & $10 and esd->1 == index if esd->0 & $10 and esd->1 == index
addr = lookupsym(sym) addr = lookuptbl(sym, symtbl)
if !addr if !addr
perr = $81 perr = $81
cout('?') cout('?')
@ -808,7 +805,7 @@ def lookupdef(addr, deftbl)#1
end end
def loadmod(mod)#1 def loadmod(mod)#1
word rdlen, modsize, bytecode, defofst, defcnt, init, fixup word rdlen, modsize, bytecode, defofst, defcnt, init, fixup
word addr, modaddr, modfix, modend word addr, modaddr, modfix, modofst, modend
word deftbl, deflast word deftbl, deflast
word moddep, rld, esd, sym word moddep, rld, esd, sym
byte str[17], filename[17] byte str[17], filename[17]
@ -877,8 +874,9 @@ def loadmod(mod)#1
// Apply all fixups and symbol import/export. // Apply all fixups and symbol import/export.
// //
modfix = modaddr - modfix modfix = modaddr - modfix
bytecode = defofst + modfix - MODADDR modofst = modfix - MODADDR
modend = modaddr + modsize modend = modaddr + modsize
bytecode = defofst + modofst
rld = modend // Re-Locatable Directory rld = modend // Re-Locatable Directory
esd = rld // Extern+Entry Symbol Directory esd = rld // Extern+Entry Symbol Directory
while ^esd // Scan to end of ESD while ^esd // Scan to end of ESD
@ -905,7 +903,7 @@ def loadmod(mod)#1
if ^rld & $10 // EXTERN reference. if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3) fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup. else // INTERN fixup.
fixup = fixup + modfix - MODADDR fixup = fixup + modofst
if uword_isge(fixup, bytecode) if uword_isge(fixup, bytecode)
// //
// Bytecode address - replace with call def directory. // Bytecode address - replace with call def directory.
@ -932,7 +930,7 @@ def loadmod(mod)#1
// //
// EXPORT symbol - add it to the global symbol table. // EXPORT symbol - add it to the global symbol table.
// //
addr = esd=>1 + modfix - MODADDR addr = esd=>1 + modofst
if uword_isge(addr, bytecode) if uword_isge(addr, bytecode)
// //
// Use the def directory address for bytecode. // Use the def directory address for bytecode.
@ -956,12 +954,13 @@ def loadmod(mod)#1
// //
fixup = 0 fixup = 0
if init if init
fixup = adddef(init - defofst + bytecode, @deflast)() init = init - defofst + bytecode
fixup = adddef(init, @deflast)()
if fixup < 0 if fixup < 0
perr = -fixup perr = -fixup
fin fin
if !(systemflags & modinitkeep) if !(systemflags & modinitkeep)
releaseheap(init - defofst + bytecode) releaseheap(init)
fin fin
fin fin
return fixup | (systemflags & modkeep) return fixup | (systemflags & modkeep)

View File

@ -1021,8 +1021,8 @@ def loadmod(mod)#1
// //
modfix = modaddr - modfix modfix = modaddr - modfix
modofst = modfix - MODADDR modofst = modfix - MODADDR
bytecode = defofst + modofst
modend = modaddr + modsize modend = modaddr + modsize
bytecode = defofst + modofst
rld = modend // Re-Locatable Directory rld = modend // Re-Locatable Directory
esd = rld // Extern+Entry Symbol Directory esd = rld // Extern+Entry Symbol Directory
while ^esd // Scan to end of ESD while ^esd // Scan to end of ESD

View File

@ -969,7 +969,7 @@ def lookupdef(addr, deftbl)#1
end end
def loadmod(mod)#1 def loadmod(mod)#1
word refnum, rdlen, modsize, bytecode, defofst, defcnt, init, fixup word refnum, rdlen, modsize, bytecode, defofst, defcnt, init, fixup
word addr, defaddr, modaddr, modfix, modend word addr, defaddr, modaddr, modfix, modofst, modend
word deftbl, deflast, codeseg word deftbl, deflast, codeseg
word moddep, rld, esd, sym word moddep, rld, esd, sym
byte defext, str[16], filename[33] byte defext, str[16], filename[33]
@ -1052,8 +1052,9 @@ def loadmod(mod)#1
// Apply all fixups and symbol import/export. // Apply all fixups and symbol import/export.
// //
modfix = modaddr - modfix modfix = modaddr - modfix
bytecode = defofst + modfix - MODADDR modofst = modfix - MODADDR
modend = modaddr + modsize modend = modaddr + modsize
bytecode = defofst + modofst
rld = modend // Re-Locatable Directory rld = modend // Re-Locatable Directory
esd = rld // Extern+Entry Symbol Directory esd = rld // Extern+Entry Symbol Directory
while ^esd // Scan to end of ESD while ^esd // Scan to end of ESD
@ -1090,7 +1091,7 @@ def loadmod(mod)#1
if ^rld & $10 // EXTERN reference. if ^rld & $10 // EXTERN reference.
fixup = fixup + lookupextern(esd, rld->3) fixup = fixup + lookupextern(esd, rld->3)
else // INTERN fixup. else // INTERN fixup.
fixup = fixup + modfix - MODADDR fixup = fixup + modofst
if uword_isge(fixup, bytecode) if uword_isge(fixup, bytecode)
// //
// Bytecode address - replace with call def directory. // Bytecode address - replace with call def directory.
@ -1117,7 +1118,7 @@ def loadmod(mod)#1
// //
// EXPORT symbol - add it to the global symbol table. // EXPORT symbol - add it to the global symbol table.
// //
addr = esd=>1 + modfix - MODADDR addr = esd=>1 + modofst
if uword_isge(addr, bytecode) if uword_isge(addr, bytecode)
// //
// Use the def directory address for bytecode. // Use the def directory address for bytecode.