mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-01-05 17:32:02 +00:00
Still lingering TEST problem
This commit is contained in:
parent
71f5f061ee
commit
dbc02bc1b6
@ -259,7 +259,7 @@ end
|
||||
// Emit the pending sequence
|
||||
//
|
||||
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
|
||||
// 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.
|
||||
//
|
||||
if not pending_seq; return; fin
|
||||
lcl_pending = pending_seq
|
||||
pending_seq = NULL
|
||||
pending = pending_seq; pending_seq = NULL
|
||||
if outflags & OPTIMIZE
|
||||
while optimize_seq(@lcl_pending, 0); loop
|
||||
while optimize_seq(@pending, 0); loop
|
||||
if outflags & OPTIMIZE2
|
||||
while optimize_seq(@lcl_pending, 1); loop
|
||||
while optimize_seq(@pending, 1); loop
|
||||
fin
|
||||
fin
|
||||
while lcl_pending
|
||||
op = lcl_pending
|
||||
while pending
|
||||
op = pending
|
||||
when op->opgroup
|
||||
//
|
||||
// Constant value
|
||||
@ -287,54 +286,61 @@ def emit_pending_seq#0
|
||||
is CONST_GROUP
|
||||
if op->opcode == CONST_CODE
|
||||
if op=>opval == $0000 // ZERO
|
||||
emit_byte($00)
|
||||
^codeptr = $00
|
||||
codeptr++
|
||||
elsif op=>opval & $FF00 == $0000 // Constant BYTE
|
||||
emit_byte($2A)
|
||||
emit_byte(op->opval)
|
||||
*codeptr = $2A | (op->opval << 8)
|
||||
codeptr = codeptr + 2
|
||||
elsif op=>opval & $FF00 == $FF00 // Constant $FF00 | BYTE
|
||||
emit_byte($5E)
|
||||
emit_byte(op->opval)
|
||||
*codeptr = $5E | (op->opval << 8)
|
||||
codeptr = codeptr + 2
|
||||
else // Constant WORD
|
||||
emit_byte($2C)
|
||||
emit_word(op=>opval)
|
||||
codeptr->0 = $2C
|
||||
codeptr=>1 = op=>opval
|
||||
codeptr = codeptr + 3
|
||||
fin
|
||||
else // Constant LOAD/STORE/CALL
|
||||
emit_byte(op->opcode)
|
||||
emit_word(op=>opval)
|
||||
codeptr->0 = op->opcode
|
||||
codeptr=>1 = op=>opval
|
||||
codeptr = codeptr + 3
|
||||
fin
|
||||
break
|
||||
//
|
||||
// Constant string
|
||||
//
|
||||
is CONSTR_GROUP
|
||||
emit_byte($2E)
|
||||
^codeptr = $2E
|
||||
codeptr++
|
||||
emit_data(0, STR_TYPE, op=>opval, 0)
|
||||
break
|
||||
//
|
||||
// Single op codes
|
||||
//
|
||||
is STACK_GROUP
|
||||
emit_byte(op->opcode)
|
||||
^codeptr = op->opcode
|
||||
codeptr++
|
||||
break
|
||||
//
|
||||
// Local address codes
|
||||
//
|
||||
is LOCAL_GROUP
|
||||
emit_byte(op->opcode)
|
||||
emit_byte(op->opoffset)
|
||||
*codeptr = op->opcode | (op->opoffset << 8)
|
||||
codeptr = codeptr + 2
|
||||
break
|
||||
//
|
||||
// Global address codes
|
||||
//
|
||||
is GLOBAL_GROUP
|
||||
emit_byte(op->opcode)
|
||||
^codeptr = op->opcode
|
||||
codeptr++
|
||||
emit_addr(op=>optag, op=>opoffset)
|
||||
break
|
||||
//
|
||||
// Relative address codes
|
||||
//
|
||||
is RELATIVE_GROUP
|
||||
emit_byte(op->opcode)
|
||||
^codeptr = op->opcode
|
||||
codeptr++
|
||||
emit_reladdr(op=>optag)
|
||||
break
|
||||
//
|
||||
@ -346,13 +352,14 @@ def emit_pending_seq#0
|
||||
otherwise
|
||||
return
|
||||
wend
|
||||
lcl_pending = lcl_pending=>opnext;
|
||||
pending = pending=>opnext;
|
||||
//
|
||||
// Free this op
|
||||
//
|
||||
op=>opnext = freeop_lst
|
||||
freeop_lst = op
|
||||
loop
|
||||
if codeptr - codebuff > codebufsz; exit_err(ERR_OVER|ERR_CODE|ERR_TABLE); fin
|
||||
end
|
||||
//
|
||||
// Emit a sequence of ops (into the pending sequence)
|
||||
@ -896,7 +903,7 @@ def writeRLD(refnum, modofst)#0
|
||||
if not (type & RELATIVE_FIXUP)
|
||||
if rldlen == 64 // Write out blocks of entries
|
||||
fileio:write(refnum, heapmark, rld - heapmark)
|
||||
rld = heapmark
|
||||
rld = heapmark
|
||||
rldlen = 0
|
||||
fin
|
||||
if type & EXTERN_FIXUP
|
||||
@ -925,6 +932,7 @@ end
|
||||
//
|
||||
def writemodule(refnum)#0
|
||||
word hdrlen, esd, esdlen, modfix, modadj, modofst, fixups, updtptr
|
||||
|
||||
//
|
||||
// Write module header
|
||||
//
|
||||
|
@ -737,9 +737,6 @@ end
|
||||
//
|
||||
// Symbol table routines.
|
||||
//
|
||||
def lookupsym(sym)#1
|
||||
return lookuptbl(sym, symtbl)
|
||||
end
|
||||
def addsym(sym, addr)#0
|
||||
while ^sym & $80
|
||||
^lastsym = ^sym
|
||||
@ -774,7 +771,7 @@ def lookupextern(esd, index)#1
|
||||
sym = esd
|
||||
esd = esd + dcitos(esd, @str)
|
||||
if esd->0 & $10 and esd->1 == index
|
||||
addr = lookupsym(sym)
|
||||
addr = lookuptbl(sym, symtbl)
|
||||
if !addr
|
||||
perr = $81
|
||||
cout('?')
|
||||
@ -808,7 +805,7 @@ def lookupdef(addr, deftbl)#1
|
||||
end
|
||||
def loadmod(mod)#1
|
||||
word rdlen, modsize, bytecode, defofst, defcnt, init, fixup
|
||||
word addr, modaddr, modfix, modend
|
||||
word addr, modaddr, modfix, modofst, modend
|
||||
word deftbl, deflast
|
||||
word moddep, rld, esd, sym
|
||||
byte str[17], filename[17]
|
||||
@ -877,8 +874,9 @@ def loadmod(mod)#1
|
||||
// Apply all fixups and symbol import/export.
|
||||
//
|
||||
modfix = modaddr - modfix
|
||||
bytecode = defofst + modfix - MODADDR
|
||||
modofst = modfix - MODADDR
|
||||
modend = modaddr + modsize
|
||||
bytecode = defofst + modofst
|
||||
rld = modend // Re-Locatable Directory
|
||||
esd = rld // Extern+Entry Symbol Directory
|
||||
while ^esd // Scan to end of ESD
|
||||
@ -905,7 +903,7 @@ def loadmod(mod)#1
|
||||
if ^rld & $10 // EXTERN reference.
|
||||
fixup = fixup + lookupextern(esd, rld->3)
|
||||
else // INTERN fixup.
|
||||
fixup = fixup + modfix - MODADDR
|
||||
fixup = fixup + modofst
|
||||
if uword_isge(fixup, bytecode)
|
||||
//
|
||||
// Bytecode address - replace with call def directory.
|
||||
@ -932,7 +930,7 @@ def loadmod(mod)#1
|
||||
//
|
||||
// EXPORT symbol - add it to the global symbol table.
|
||||
//
|
||||
addr = esd=>1 + modfix - MODADDR
|
||||
addr = esd=>1 + modofst
|
||||
if uword_isge(addr, bytecode)
|
||||
//
|
||||
// Use the def directory address for bytecode.
|
||||
@ -956,12 +954,13 @@ def loadmod(mod)#1
|
||||
//
|
||||
fixup = 0
|
||||
if init
|
||||
fixup = adddef(init - defofst + bytecode, @deflast)()
|
||||
init = init - defofst + bytecode
|
||||
fixup = adddef(init, @deflast)()
|
||||
if fixup < 0
|
||||
perr = -fixup
|
||||
fin
|
||||
if !(systemflags & modinitkeep)
|
||||
releaseheap(init - defofst + bytecode)
|
||||
releaseheap(init)
|
||||
fin
|
||||
fin
|
||||
return fixup | (systemflags & modkeep)
|
||||
|
@ -1021,8 +1021,8 @@ def loadmod(mod)#1
|
||||
//
|
||||
modfix = modaddr - modfix
|
||||
modofst = modfix - MODADDR
|
||||
bytecode = defofst + modofst
|
||||
modend = modaddr + modsize
|
||||
bytecode = defofst + modofst
|
||||
rld = modend // Re-Locatable Directory
|
||||
esd = rld // Extern+Entry Symbol Directory
|
||||
while ^esd // Scan to end of ESD
|
||||
|
@ -969,7 +969,7 @@ def lookupdef(addr, deftbl)#1
|
||||
end
|
||||
def loadmod(mod)#1
|
||||
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 moddep, rld, esd, sym
|
||||
byte defext, str[16], filename[33]
|
||||
@ -1052,8 +1052,9 @@ def loadmod(mod)#1
|
||||
// Apply all fixups and symbol import/export.
|
||||
//
|
||||
modfix = modaddr - modfix
|
||||
bytecode = defofst + modfix - MODADDR
|
||||
modofst = modfix - MODADDR
|
||||
modend = modaddr + modsize
|
||||
bytecode = defofst + modofst
|
||||
rld = modend // Re-Locatable Directory
|
||||
esd = rld // Extern+Entry Symbol Directory
|
||||
while ^esd // Scan to end of ESD
|
||||
@ -1090,7 +1091,7 @@ def loadmod(mod)#1
|
||||
if ^rld & $10 // EXTERN reference.
|
||||
fixup = fixup + lookupextern(esd, rld->3)
|
||||
else // INTERN fixup.
|
||||
fixup = fixup + modfix - MODADDR
|
||||
fixup = fixup + modofst
|
||||
if uword_isge(fixup, bytecode)
|
||||
//
|
||||
// Bytecode address - replace with call def directory.
|
||||
@ -1117,7 +1118,7 @@ def loadmod(mod)#1
|
||||
//
|
||||
// EXPORT symbol - add it to the global symbol table.
|
||||
//
|
||||
addr = esd=>1 + modfix - MODADDR
|
||||
addr = esd=>1 + modofst
|
||||
if uword_isge(addr, bytecode)
|
||||
//
|
||||
// Use the def directory address for bytecode.
|
||||
|
Loading…
Reference in New Issue
Block a user