Leopold Toetsch wrote:

I have it ready.
It's based on the packfile patch #18056 by Juergen Boemmels. On top of this patch, it was quite easy to implement multiple code segments.
And yet another f'up me.

Here is a proposal for inter code segment jumps:

The assembler (imcc) can recognize when a branch ins goes to a different
code segment.

For such a branch, imcc generates this opcode seqence:

inter_cs
if i, ic # or whatever

The branch location "ic" is the index[1] into the fixuptable, which contains codesegment/offset pairs.

The inter_cs instruction looks like:

opcode_t *cur = cur_opcode; /* remember current */
// = CUR_OPCODE
opcode_t *pc;
DO_OP(pc, interpreter); /* pc is new pc now */
if (pc_is_outof_bounds) { /* branch taken */
index = (pc-code_start)/(sizeof opcode_t) & ~0x80000000;
interp->resume_code_seg = fixup_table[index].code_seg;
interp->resume_offset = fixup_table[index].offs;
//= restart OFFSET(x)
return 0; /* do a resume in new cs */
}
cur_opcode = pc; /* branch not taken */
// = goto ADDRESS(pc);

[1] the branch offsets are with the hight bit set, to allow recognition of out_of_bounds.

Some help to translate this to OpsFile macros as well as of course always comments are welcome,

leo



Reply via email to