mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-04-05 03:37:43 +00:00
Apple /// JITC
This commit is contained in:
parent
574911e389
commit
d4f15e3a90
@ -31,6 +31,8 @@ JMPTMPX = XPAGE+JMPTMP
|
||||
TMPX = XPAGE+TMPH
|
||||
SRCX = XPAGE+SRCH
|
||||
DSTX = XPAGE+DSTH
|
||||
JITCOMP = $B7F0 ; JIT VARS AT THE END OF INTER
|
||||
JITCODE = $B7F2
|
||||
;*
|
||||
;* SOS
|
||||
;*
|
||||
@ -49,10 +51,6 @@ SEGSTART = $2000
|
||||
!WORD SEGSTART
|
||||
!WORD SEGEND-SEGSTART
|
||||
|
||||
; +SOS $40, SEGREQ ; ALLOCATE SEG 1 AND MAP IT
|
||||
; BNE FAIL ; PRHEX
|
||||
; LDA #$00
|
||||
; STA MEMBANK
|
||||
LDY #$0F ; INSTALL PAGE 0 FETCHOP ROUTINE
|
||||
LDA #$00
|
||||
- LDX PAGE0,Y
|
||||
@ -65,15 +63,8 @@ SEGSTART = $2000
|
||||
STA TMPX ; CLEAR ALL EXTENDED POINTERS
|
||||
STA SRCX
|
||||
STA DSTX
|
||||
STA PPX ; INIT FRAME & POOL POINTERS
|
||||
STA PPX
|
||||
STA IFPX
|
||||
LDA #$00
|
||||
STA PPL
|
||||
STA IFPL
|
||||
LDA #$A0
|
||||
STA PPH
|
||||
STA IFPH
|
||||
!IF 1 {
|
||||
LDA #<VMCORE ; COPY VM+SYS INTO SBANK
|
||||
STA SRCL
|
||||
LDA #>VMCORE
|
||||
@ -91,7 +82,16 @@ SEGSTART = $2000
|
||||
LDA DSTH
|
||||
CMP #$B8
|
||||
BNE -
|
||||
}
|
||||
LDA #$00 ; INIT JIT, FRAME & POOL POINTERS
|
||||
STA JITCOMP
|
||||
STA JITCOMP+1
|
||||
STA JITCODE
|
||||
STA PPL
|
||||
STA IFPL
|
||||
LDA #$90 ; RESERVE 4K FOR JITCODE
|
||||
STA JITCODE+1
|
||||
STA PPH
|
||||
STA IFPH
|
||||
LDX #$FF ; INIT STACK POINTER
|
||||
TXS
|
||||
LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX
|
||||
@ -230,7 +230,6 @@ RUNJIT LDA JITCOMP
|
||||
PLA
|
||||
STA TMPL
|
||||
JMP JMPTMP ; RE-CALL ORIGINAL DEF ENTRY
|
||||
JITCOMP !WORD 0
|
||||
;*
|
||||
;* INTERNAL DIVIDE ALGORITHM
|
||||
;*
|
||||
@ -1432,5 +1431,6 @@ NATV TYA ; FLATTEN IP
|
||||
JMP JMPTMP
|
||||
SOSCMD = *
|
||||
!SOURCE "vmsrc/apple/sossys.a"
|
||||
|
||||
}
|
||||
SEGEND = *
|
||||
|
@ -14,46 +14,39 @@ struc t_defentry
|
||||
byte bytecodesize
|
||||
end
|
||||
//
|
||||
// JIT compiler constants
|
||||
// JIT compiler values
|
||||
//
|
||||
const jitcomp = $03E2
|
||||
const jitcomp = $B7F0
|
||||
const jitcodeptr = $B7F2
|
||||
const codemax = $A000
|
||||
word interpentry
|
||||
//
|
||||
// AUX bytecode interpreter entrypoint
|
||||
//
|
||||
word jitcodeptr
|
||||
word codeptr
|
||||
word interpentry
|
||||
//
|
||||
// COPY FROM EXT MEM TO MAIN MEM.
|
||||
//
|
||||
// XMEMCPY(DST, XSRC, SIZE)
|
||||
//
|
||||
asm defcpy(dst,defentry)#0
|
||||
asm xmemcpy(dst, src, srcx, size)#0
|
||||
!SOURCE "vmsrc/plvmzp.inc"
|
||||
XPAGE = $1600
|
||||
SRCX = XPAGE+SRCH
|
||||
DSTX = XPAGE+DSTH
|
||||
|
||||
//asm memxcpy(dst,src,size)#0
|
||||
LDA ESTKL,X
|
||||
ORA ESTKH,X
|
||||
BEQ CPYXMEX
|
||||
LDY #$00
|
||||
LDA ESTKL+3,X
|
||||
STY DSTL
|
||||
LDA ESTKH+2,X
|
||||
CLC
|
||||
ADC #$60
|
||||
LDA ESTKH+3,X
|
||||
STA DSTH
|
||||
LDA ESTKL+2,X
|
||||
CLC
|
||||
ADC #$7F
|
||||
STA DSTX
|
||||
LDA ESTKL+1,X
|
||||
STA SRCL
|
||||
LDA ESTKH+1,X
|
||||
LDA ESTKH+2,X
|
||||
STA SRCH
|
||||
INC ESTKH,X
|
||||
LDA ESTKL+1,X
|
||||
STA SRCX
|
||||
CPYXLP LDA (SRC),Y
|
||||
STA (DST),Y
|
||||
INY
|
||||
@ -65,12 +58,16 @@ CPYXLP LDA (SRC),Y
|
||||
DEC ESTKH,X
|
||||
BNE CPYXLP
|
||||
LDA #$00
|
||||
STA DSTX
|
||||
STA SRCX
|
||||
CPYXMEX INX
|
||||
INX
|
||||
INX
|
||||
INX
|
||||
RTS
|
||||
end
|
||||
def defcpy(dst, defentry)#0
|
||||
xmemcpy(dst, defentry=>bytecodeaddr, defentry->bytecodexbyte, defentry->bytecodesize)
|
||||
end
|
||||
include "libsrc/jitcore.pla"
|
||||
//
|
||||
// SOS routines
|
||||
@ -316,5 +313,7 @@ cmdsys:cmdparser = @shell
|
||||
//
|
||||
// Install JIT compiler
|
||||
//
|
||||
puts("JITC 1.0\n")
|
||||
cmdsys:jitc = @compiler
|
||||
interpentry = compiler:interpaddr
|
||||
done
|
||||
|
@ -17,6 +17,17 @@ const resxhgr2 = $0080
|
||||
const modkeep = $2000
|
||||
const modinitkeep = $4000
|
||||
//
|
||||
// Indirect interpreter DEFinition entrypoint
|
||||
//
|
||||
struc t_defentry
|
||||
byte interpjsr
|
||||
word interpaddr
|
||||
word bytecodeaddr
|
||||
byte bytecodexbyte
|
||||
byte callcount
|
||||
byte bytecodesize
|
||||
end
|
||||
//
|
||||
// Pedefined functions.
|
||||
//
|
||||
predef syscall(cmd,params)#1, call(addr,areg,xreg,yreg,status)#1
|
||||
@ -449,6 +460,14 @@ asm interp()#1
|
||||
STA ESTKH,X
|
||||
RTS
|
||||
end
|
||||
asm jitinterp()#1
|
||||
DEX
|
||||
LDA #<JITINTRP
|
||||
STA ESTKL,X
|
||||
LDA #>JITINTRP
|
||||
STA ESTKH,X
|
||||
RTS
|
||||
end
|
||||
//
|
||||
// A DCI string is one that has the high bit set for every character except the last.
|
||||
// More efficient than C or Pascal strings.
|
||||
@ -662,7 +681,7 @@ end
|
||||
// if deftbl=>3 == addr
|
||||
// return deftbl
|
||||
// fin
|
||||
// deftbl = deftbl + 6
|
||||
// deftbl = deftbl + t_defentry
|
||||
// loop
|
||||
// return 0
|
||||
//end
|
||||
@ -689,7 +708,7 @@ asm lookupdef(addr, deftbl)#1
|
||||
LDA SRCH
|
||||
STA ESTKH,X
|
||||
RTS
|
||||
+ LDA #$06
|
||||
+ LDA #$08 ; T_DEFENTRY
|
||||
CLC
|
||||
ADC SRCL
|
||||
STA SRCL
|
||||
@ -1014,18 +1033,28 @@ def lookupextern(esd, index)#1
|
||||
fin
|
||||
return 0
|
||||
end
|
||||
def adddef(ext, addr, deflast)#1
|
||||
word defentry
|
||||
def adddef(isfirst, ext, addr, deflast)#1
|
||||
word preventry, defentry, defsize
|
||||
defentry = *deflast
|
||||
*deflast = defentry + 6
|
||||
defentry->0 = $20
|
||||
defentry=>1 = interp
|
||||
defentry=>3 = addr
|
||||
defentry=>5 = ext // ext is byte, so this nulls out next entry
|
||||
*deflast = defentry + t_defentry
|
||||
if not isfirst
|
||||
preventry = defentry - t_defentry
|
||||
defsize = addr - preventry=>bytecodeaddr
|
||||
if *jitcomp and defsize <= jitsize
|
||||
preventry=>interpaddr = jitinterp // JSR JITINTRP
|
||||
preventry->callcount = jitcount // Set JIT countdown
|
||||
preventry->bytecodesize = defsize // Set size
|
||||
fin
|
||||
fin
|
||||
defentry->interpjsr = $20
|
||||
defentry=>interpaddr = interp
|
||||
defentry=>bytecodeaddr = addr
|
||||
defentry->bytecodexbyte = ext
|
||||
defentry->t_defentry = 0
|
||||
return defentry
|
||||
end
|
||||
def loadmod(mod)#1
|
||||
word refnum, rdlen, modsize, bytecode, codefix, defofst, defcnt, init, fixup
|
||||
word refnum[], deffirst, rdlen, modsize, bytecode, codefix, defofst, defcnt, init, fixup
|
||||
word addr, defaddr, modaddr, modfix, modofst, modend
|
||||
word deftbl, deflast, codeseg
|
||||
word moddep, rld, esd, sym
|
||||
@ -1149,11 +1178,13 @@ def loadmod(mod)#1
|
||||
//
|
||||
// Run through the DeFinition Dictionary.
|
||||
//
|
||||
deffirst = 1
|
||||
while ^rld == $02
|
||||
//
|
||||
// This is a bytcode def entry - add it to the def directory.
|
||||
//
|
||||
adddef(defext, rld=>1 + defofst, @deflast)
|
||||
adddef(deffirst, defext, rld=>1 + defofst, @deflast)
|
||||
deffirst = 0
|
||||
rld = rld + 4
|
||||
loop
|
||||
//
|
||||
@ -1231,7 +1262,7 @@ def loadmod(mod)#1
|
||||
//
|
||||
fixup = 0
|
||||
if init
|
||||
fixup = adddef(defext, init + defofst, @deflast)()
|
||||
fixup = adddef(deffirst, defext, init + defofst, @deflast)()
|
||||
if fixup < 0
|
||||
perr = -fixup
|
||||
fin
|
||||
|
Loading…
x
Reference in New Issue
Block a user