mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-11-04 11:07:00 +00:00
Order DFD by address
This commit is contained in:
parent
fa71ec3948
commit
cb7f86a911
@ -344,11 +344,11 @@ def compiler(defptr)#0
|
||||
^codeptr = $D0; codeptr++ // BNE rel
|
||||
^codeptr = $01; codeptr++ // +1
|
||||
^codeptr = $88; codeptr++ // DEY
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0+1; codeptr++ // ESTKL+1
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0+1; codeptr++ // ESTKH+1
|
||||
^codeptr = $E8; codeptr++ // INX
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0; codeptr++ // ESTKL
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0; codeptr++ // ESTKH
|
||||
break
|
||||
is $42
|
||||
puts("ISNE")
|
||||
@ -367,11 +367,11 @@ def compiler(defptr)#0
|
||||
^codeptr = $D0; codeptr++ // BNE rel
|
||||
^codeptr = $01; codeptr++ // +1
|
||||
^codeptr = $C8; codeptr++ // INY
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0+1; codeptr++ // ESTKL+1
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0+1; codeptr++ // ESTKH+1
|
||||
^codeptr = $E8; codeptr++ // INX
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0; codeptr++ // ESTKL
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0; codeptr++ // ESTKH
|
||||
break
|
||||
is $44
|
||||
puts("ISGT")
|
||||
@ -392,11 +392,11 @@ def compiler(defptr)#0
|
||||
^codeptr = $30; codeptr++ // BMI rel
|
||||
^codeptr = $01; codeptr++ // +1
|
||||
^codeptr = $C8; codeptr++ // INY
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0+1; codeptr++ // ESTKL+1
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0+1; codeptr++ // ESTKH+1
|
||||
^codeptr = $E8; codeptr++ // INX
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0; codeptr++ // ESTKL
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0; codeptr++ // ESTKH
|
||||
break
|
||||
is $46
|
||||
puts("ISLT")
|
||||
@ -417,11 +417,11 @@ def compiler(defptr)#0
|
||||
^codeptr = $30; codeptr++ // BMI rel
|
||||
^codeptr = $01; codeptr++ // +1
|
||||
^codeptr = $C8; codeptr++ // INY
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0+1; codeptr++ // ESTKL+1
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0+1; codeptr++ // ESTKH+1
|
||||
^codeptr = $E8; codeptr++ // INX
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0; codeptr++ // ESTKL
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0; codeptr++ // ESTKH
|
||||
break
|
||||
is $48
|
||||
puts("ISGE")
|
||||
@ -442,11 +442,11 @@ def compiler(defptr)#0
|
||||
^codeptr = $10; codeptr++ // BPL rel
|
||||
^codeptr = $01; codeptr++ // +1
|
||||
^codeptr = $C8; codeptr++ // INY
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0+1; codeptr++ // ESTKL+1
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0+1; codeptr++ // ESTKH+1
|
||||
^codeptr = $E8; codeptr++ // INX
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0; codeptr++ // ESTKL
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0; codeptr++ // ESTKH
|
||||
break
|
||||
is $4A
|
||||
puts("ISLE")
|
||||
@ -467,11 +467,11 @@ def compiler(defptr)#0
|
||||
^codeptr = $10; codeptr++ // BPL rel
|
||||
^codeptr = $01; codeptr++ // +1
|
||||
^codeptr = $C8; codeptr++ // INY
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0+1; codeptr++ // ESTKL+1
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0+1; codeptr++ // ESTKH+1
|
||||
^codeptr = $E8; codeptr++ // INX
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $D0; codeptr++ // ESTKL
|
||||
^codeptr = $94; codeptr++ // STY zp,X
|
||||
^codeptr = $C0; codeptr++ // ESTKH
|
||||
break
|
||||
is $4C
|
||||
i++
|
||||
@ -527,11 +527,12 @@ def compiler(defptr)#0
|
||||
is $52
|
||||
i++
|
||||
case = i + *(bytecode+i)
|
||||
puts("SEL "); puti(case)
|
||||
j = ^case
|
||||
i++
|
||||
puts("SEL "); puti(case); putln
|
||||
j = ^(bytecode+case)
|
||||
dest = codeptr + 8 + case * 11)
|
||||
if isule(dest, codemax)
|
||||
^case = $FF // Flag as NOP
|
||||
^(bytecode+case) = $FF // Flag as NOP
|
||||
case++
|
||||
^codeptr = $B5; codeptr++ // LDA zp,X
|
||||
^codeptr = $D0; codeptr++ // ESTKL
|
||||
@ -539,7 +540,7 @@ def compiler(defptr)#0
|
||||
^codeptr = $C0; codeptr++ // ESTKH
|
||||
^codeptr = $E8; codeptr++ // INX
|
||||
repeat
|
||||
puts(" $"); puth(*case)
|
||||
puts(" $"); puth(*(bytecode+case))
|
||||
^codeptr = $C9; codeptr++ // CMP #imm
|
||||
^codeptr = ^(bytecode+case); codeptr++
|
||||
^codeptr = $D0; codeptr++ // BNE rel
|
||||
@ -548,16 +549,16 @@ def compiler(defptr)#0
|
||||
^codeptr = ^(bytecode+case+1); codeptr++
|
||||
^codeptr = $D0; codeptr++ // BNE rel
|
||||
^codeptr = $03; codeptr++ // +3
|
||||
*case = $FFFF
|
||||
*(bytecode+case) = $FFFF
|
||||
case = case + 2
|
||||
puts("-->"); puti(case + *case)
|
||||
puts("-->"); puti(case + *(bytecode+case)); putln
|
||||
^codeptr = $4C; codeptr++ // JMP abs
|
||||
*codeptr = addrxlate=>[case]
|
||||
if not (*codeptr & $8000) // Unresolved address list
|
||||
addrxlate=>[case] = codeptr - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 2
|
||||
*case = $FFFF
|
||||
codeptr = codeptr + 2
|
||||
*(bytecode+case) = $FFFF
|
||||
case = case + 2
|
||||
j--
|
||||
until not j
|
||||
@ -567,7 +568,6 @@ def compiler(defptr)#0
|
||||
addrxlate=>[case] = codeptr - *jitcodeptr
|
||||
fin
|
||||
codeptr = codeptr + 2
|
||||
i++
|
||||
else
|
||||
codeptr = dest
|
||||
fin
|
||||
|
@ -382,12 +382,13 @@ void emit_header(void)
|
||||
}
|
||||
void emit_rld(void)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
printf(";\n; RE-LOCATEABLE DICTIONARY\n;\n");
|
||||
/*
|
||||
* First emit the bytecode definition entrypoint information.
|
||||
*/
|
||||
/*
|
||||
for (i = 0; i < globals; i++)
|
||||
if (!(idglobal_type[i] & EXTERN_TYPE) && (idglobal_type[i] & DEF_TYPE))
|
||||
{
|
||||
@ -395,6 +396,14 @@ void emit_rld(void)
|
||||
printf("\t%s\t_C%03d\t\t\n", DW, idglobal_tag[i]);
|
||||
printf("\t%s\t$00\n", DB);
|
||||
}
|
||||
*/
|
||||
j = outflags & INIT ? defs - 1 : defs;
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
printf("\t%s\t$02\t\t\t; CODE TABLE FIXUP\n", DB);
|
||||
printf("\t%s\t_C%03d\t\t\n", DW, i);
|
||||
printf("\t%s\t$00\n", DB);
|
||||
}
|
||||
/*
|
||||
* Now emit the fixup table.
|
||||
*/
|
||||
|
@ -529,11 +529,13 @@ def init_idglobal#0
|
||||
word op
|
||||
word i
|
||||
|
||||
dfd_num = DFDNUM
|
||||
tag_num = TAGNUM
|
||||
fixup_num = FIXUPNUM
|
||||
globalbufsz = IDGLOBALSZ
|
||||
localbufsz = IDLOCALSZ
|
||||
if isult(heapavail, $8000)
|
||||
if isult(heapavail, $4000)
|
||||
dfd_num = DFDNUM/2
|
||||
tag_num = TAGNUM/2
|
||||
fixup_num = FIXUPNUM/2
|
||||
globalbufsz = IDGLOBALSZ
|
||||
@ -552,6 +554,7 @@ def init_idglobal#0
|
||||
//
|
||||
// Allocate remaining buffers
|
||||
//
|
||||
dfd_tag = heapalloc(dfd_num*2)
|
||||
tag_addr = heapalloc(tag_num*2)
|
||||
tag_type = heapalloc(tag_num)
|
||||
fixup_tag = heapalloc(fixup_num*2)
|
||||
@ -604,6 +607,14 @@ def new_moddep(nameptr, len)#0
|
||||
if moddep_cnt > MODDEPNUM; parse_warn("Module dependency overflow"); fin
|
||||
end
|
||||
//
|
||||
// DFD list
|
||||
//
|
||||
def new_dfd(tag)#0
|
||||
if dfd_cnt >= dfd_num; exit_err(ERR_OVER|ERR_CODE|ERR_TABLE); fin
|
||||
dfd_tag=>[dfd_cnt] = tag
|
||||
dfd_cnt++
|
||||
end
|
||||
//
|
||||
// Generate/add to a sequence of code
|
||||
//
|
||||
def gen_op(seq, code)
|
||||
@ -870,20 +881,23 @@ end
|
||||
// Write DeFinition Directory
|
||||
//
|
||||
def writeDFD(refnum, modfix)#0
|
||||
word dfd, idptr, idcnt
|
||||
word dfd, idptr, cnt
|
||||
byte defdir[128]
|
||||
|
||||
dfd, idptr, idcnt = @defdir, idglobal_tbl, globals
|
||||
while idcnt
|
||||
if idptr=>idtype & (FUNC_TYPE|EXTERN_TYPE) == FUNC_TYPE
|
||||
dfd = @defdir
|
||||
for cnt = 0 to dfd_cnt-1
|
||||
//dfd, idptr, cnt = @defdir, idglobal_tbl, globals
|
||||
//while cnt
|
||||
//if idptr=>idtype & (FUNC_TYPE|EXTERN_TYPE) == FUNC_TYPE
|
||||
dfd->0 = $02
|
||||
dfd=>1 = tag_addr=>[idptr=>idval] + modfix
|
||||
dfd=>1 = tag_addr=>[dfd_tag=>[cnt]] + modfix
|
||||
dfd->3 = 0
|
||||
dfd = dfd + 4
|
||||
fin
|
||||
idptr = idptr + idptr->idname + t_id
|
||||
idcnt--
|
||||
loop
|
||||
//fin
|
||||
//idptr = idptr + idptr->idname + t_id
|
||||
//cnt--
|
||||
//loop
|
||||
next
|
||||
fileio:write(refnum, @defdir, dfd - @defdir)
|
||||
end
|
||||
//
|
||||
|
@ -1624,8 +1624,9 @@ int parse_defs(void)
|
||||
emit_const(0);
|
||||
emit_leave();
|
||||
}
|
||||
while (lambda_cnt--)
|
||||
emit_lambdafunc(lambda_tag[lambda_cnt], lambda_id[lambda_cnt], lambda_cparams[lambda_cnt], lambda_seq[lambda_cnt]);
|
||||
for (cfnvals = 0; cfnvals < lambda_cnt; cfnvals++)
|
||||
emit_lambdafunc(lambda_tag[cfnvals], lambda_id[cfnvals], lambda_cparams[cfnvals], lambda_seq[cfnvals]);
|
||||
lambda_cnt = 0;
|
||||
return (1);
|
||||
}
|
||||
else if (scantoken == ASM_TOKEN)
|
||||
@ -1705,21 +1706,21 @@ int parse_module(void)
|
||||
while (parse_mods()) next_line();
|
||||
while (parse_vars(GLOBAL_TYPE)) next_line();
|
||||
while (parse_defs()) next_line();
|
||||
emit_bytecode_seg();
|
||||
emit_start();
|
||||
idlocal_reset();
|
||||
emit_idfunc(0, 0, NULL, 1);
|
||||
prevstmnt = 0;
|
||||
if (scantoken != DONE_TOKEN && scantoken != EOF_TOKEN)
|
||||
{
|
||||
emit_bytecode_seg();
|
||||
emit_start();
|
||||
idlocal_reset();
|
||||
emit_idfunc(0, 0, NULL, 1);
|
||||
prevstmnt = 0;
|
||||
while (parse_stmnt()) next_line();
|
||||
if (scantoken != DONE_TOKEN)
|
||||
parse_error("Missing DONE");
|
||||
if (prevstmnt != RETURN_TOKEN)
|
||||
{
|
||||
emit_const(0);
|
||||
emit_ret();
|
||||
}
|
||||
}
|
||||
if (prevstmnt != RETURN_TOKEN)
|
||||
{
|
||||
emit_const(0);
|
||||
emit_ret();
|
||||
}
|
||||
}
|
||||
emit_trailer();
|
||||
|
@ -1259,6 +1259,7 @@ def parse_defs
|
||||
new_idfunc(idstr, idlen, type, func_tag, cfnparms, infuncvals)
|
||||
fin
|
||||
emit_tag(func_tag)
|
||||
new_dfd(func_tag)
|
||||
while parse_vars(LOCAL_TYPE); nextln; loop
|
||||
emit_enter(cfnparms)
|
||||
prevstmnt = 0
|
||||
@ -1273,10 +1274,10 @@ def parse_defs
|
||||
next
|
||||
emit_leave
|
||||
fin
|
||||
while lambda_cnt
|
||||
lambda_cnt--
|
||||
emit_lambdafunc(lambda_tag[lambda_cnt], lambda_cparms[lambda_cnt], lambda_seq[lambda_cnt])
|
||||
loop
|
||||
for cfnvals = 0 to lambda_cnt-1
|
||||
emit_lambdafunc(lambda_tag[cfnvals], lambda_cparms[cfnvals], lambda_seq[cfnvals])
|
||||
new_dfd(lambda_tag[cfnvals])
|
||||
next
|
||||
fin
|
||||
return token == EOL_TKN ?? TRUE :: FALSE
|
||||
end
|
||||
|
@ -232,6 +232,7 @@ end
|
||||
// Generated code buffers
|
||||
//
|
||||
const OPSEQNUM = 256
|
||||
const DFDNUM = 128
|
||||
const TAGNUM = 1024
|
||||
const FIXUPNUM = 2048
|
||||
const MODDEPNUM = 8
|
||||
@ -239,12 +240,13 @@ const IDGLOBALSZ = 4096
|
||||
const IDLOCALSZ = 512
|
||||
const CASENUM = 64
|
||||
word fixup_cnt, tag_cnt = -1
|
||||
word dfd_tag, dfd_cnt
|
||||
word fixup_tag, fixup_addr
|
||||
word tag_addr, tag_type
|
||||
word idglobal_tbl, idlocal_tbl
|
||||
word pending_seq
|
||||
word globals, lastglobal, lastglobalsize, lastlocal, savelast
|
||||
word tag_num, fixup_num, globalbufsz, localbufsz, codebufsz
|
||||
word dfd_num, tag_num, fixup_num, globalbufsz, localbufsz, codebufsz
|
||||
word datasize, framesize, savesize
|
||||
byte locals, savelocals
|
||||
word codebuff, codeptr, entrypoint
|
||||
|
@ -39,7 +39,7 @@ end
|
||||
//
|
||||
// JIT compiler constants
|
||||
//
|
||||
const jitcount = $10
|
||||
const jitcount = $01//$10
|
||||
const jitcomp = $03E2
|
||||
const jitcodeptr = $03E4
|
||||
const jitcode = $BF00
|
||||
|
Loading…
Reference in New Issue
Block a user