mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-06-12 14:29:54 +00:00
68 lines
1.4 KiB
Plaintext
68 lines
1.4 KiB
Plaintext
//
|
|
// PLASMA JIT bytecode compiler
|
|
//
|
|
include "inc/cmdsys.plh"
|
|
//
|
|
// Indirect interpreter DEFinition entrypoint
|
|
//
|
|
struc t_defentry
|
|
byte interpjsr
|
|
word interpaddr
|
|
word bytecodeaddr
|
|
byte callcount
|
|
byte bytecodesize
|
|
end
|
|
//
|
|
// JIT compiler constants
|
|
//
|
|
const jitcomp = $03E2
|
|
const jitcodeptr = $03E4
|
|
const codemax = $BEE0
|
|
const estkh8 = $C000
|
|
const estkh = $00C0
|
|
const estkl8 = $D000
|
|
const estkl = $00D0
|
|
const ifp8 = $E000
|
|
const ifpl8 = $E000
|
|
const ifph8 = $E100
|
|
const jmptmp = $00E6
|
|
const tmp8 = $E700
|
|
const tmpl8 = $E700
|
|
const tmph8 = $E800
|
|
const fetchop = $00F1
|
|
const ip8 = $F200
|
|
const ip = $00F2
|
|
//
|
|
// Bytecode interpreter entrypoints
|
|
//
|
|
const indirectentry = $03DC
|
|
const directentry = $03D0
|
|
//
|
|
// Copy bytecode DEF to main memory
|
|
//
|
|
def defcpy(dst, defptr)#0
|
|
*$003C = defptr=>bytecodeaddr
|
|
*$003E = *$003C + defptr->bytecodesize
|
|
*$0042 = dst
|
|
call($C311, 0, 0, 0, $04) // CALL XMOVE with carry clear (AUX->MAIN) and ints disabled
|
|
end
|
|
//
|
|
// Identify hardware addresses for certain byte sized access operations
|
|
//
|
|
def is_hwaddr(addr)
|
|
return isuge(addr, $C000) and isult(addr, $C100)
|
|
end
|
|
include "libsrc/jit16core.pla"
|
|
//
|
|
// Install JIT compiler
|
|
//
|
|
if *jitcomp
|
|
return 0
|
|
fin
|
|
*jitcomp = @compiler
|
|
cmdsys.jitcount = 48
|
|
cmdsys.jitsize = 128
|
|
puts("16-bit VM/JITC enabled\n")
|
|
return modkeep
|
|
done
|