[gamecode] Redesign jump's B addressing

Yet another redundant addressing mode (since ptr + 0 can be used), so
replace it with a variable-indexed array (same as in v6p). Was forced
into noticing the problem when trying to compile Machine.r.
This commit is contained in:
Bill Currie 2022-01-30 22:34:40 +09:00
parent b8df11b2cb
commit 766bf758ab
3 changed files with 5 additions and 5 deletions

View file

@ -204,11 +204,11 @@ jump_formats = {
"jump_fmt": branch_fmt,
"jump_types": [
"ev_short, ev_invalid, ev_invalid",
"ev_ptr, ev_invalid, ev_invalid",
"ev_void, ev_int, ev_invalid",
"ev_ptr, ev_short, ev_invalid",
"ev_ptr, ev_int, ev_invalid",
],
"jump_widths": [ "0, 0", "1, 0", "1, 0", "1, 1" ]
"jump_widths": [ "0, 0", "1, 1", "1, 0", "1, 1" ]
},
}
lea_formats = {

View file

@ -1867,8 +1867,8 @@ pr_jump_mode (progs_t *pr, const dstatement_t *st, int jump_ind)
jump_offs = jump_offs + (short) st->a;
break;
case 1:
// simple pointer dereference: *a
jump_offs = OPA(ptr);
// variable indexed array: a + *b (only +ve)
jump_offs = (op_a + OPB(uint))->uint_var;
break;
case 2:
// constant indexed pointer: *a + b (supports -ve offset)

View file

@ -19,7 +19,7 @@ static dstatement_t jump_A_statements[] = {
};
static dstatement_t jump_B_statements[] = {
{ OP(0, 0, 0, OP_JUMP_B), 3, 0, 0 },
{ OP(0, 0, 0, OP_JUMP_B), 1, 2, 0 },
{ OP(0, 0, 0, OP_BREAK), 0, 0, 0 },
{ OP(0, 0, 0, OP_LEA_A), 1, 0, 0 },
{ OP(0, 0, 0, OP_LEA_A), 1, 0, 4 },