[gamecode] Rework implementation of memset*

The memset instructions now match the move* instructions other than the
first operand (always int). Probably breaks much, but fixed in next few
commits.
This commit is contained in:
Bill Currie 2020-03-13 17:50:57 +09:00
parent 087cee06be
commit a0d85e33c2
3 changed files with 20 additions and 8 deletions

View file

@ -396,8 +396,9 @@ typedef enum {
OP_MOD_F,
OP_MOD_D,
OP_MEMSET,
OP_MEMSETI,
OP_MEMSETP,
OP_MEMSETPI,
} pr_opcode_e;
#define OP_BREAK 0x8000

View file

@ -1616,14 +1616,17 @@ op_call:
pr->pr_globals + OPA.integer_var,
st->b * 4);
break;
case OP_MEMSET:
case OP_MEMSETI:
pr_memset (&OPC, OPA.integer_var, st->b);
break;
case OP_MEMSETP:
if (pr_boundscheck->int_val) {
PR_BoundsCheckSize (pr, OPC.pointer_var, OPB.uinteger_var);
PR_BoundsCheckSize (pr, OPC.pointer_var, OPB.integer_var);
}
pr_memset (pr->pr_globals + OPC.pointer_var, OPA.integer_var,
OPB.integer_var);
break;
case OP_MEMSETI:
case OP_MEMSETPI:
if (pr_boundscheck->int_val) {
PR_BoundsCheckSize (pr, OPC.pointer_var, st->b);
}

View file

@ -1181,17 +1181,22 @@ VISIBLE const opcode_t pr_opcodes[] = {
{"<MOVEP>", "movepi", OP_MOVEPI, true,
ev_pointer, ev_short, ev_pointer,
PROG_VERSION,
"%Ga, %Gb, %Gc",
"%Ga, %sb, %Gc",
},
{"<MEMSET>", "memset", OP_MEMSET, true,
{"<MEMSET>", "memseti", OP_MEMSETI, true,
ev_integer, ev_short, ev_void,
PROG_VERSION,
"%Ga, %sb, %gc",
},
{"<MEMSETP>", "memsetp", OP_MEMSETP, true,
ev_integer, ev_integer, ev_pointer,
PROG_VERSION,
"%Ga, %Gb, %Gc",
},
{"<MEMSET>", "memseti", OP_MEMSETI, true,
{"<MEMSETP>", "memsetpi", OP_MEMSETPI, true,
ev_integer, ev_short, ev_pointer,
PROG_VERSION,
"%Ga, %Gb, %Gc",
"%Ga, %sb, %Gc",
},
{"<PUSH>", "push.s", OP_PUSH_S, false,
@ -1710,6 +1715,9 @@ PR_Check_Opcodes (progs_t *pr)
check_global_size (pr, st, op, st->b, st->a);
check_global_size (pr, st, op, st->b, st->c);
break;
case OP_MEMSETI:
check_global_size (pr, st, op, st->b, st->c);
break;
case OP_PUSHB_F:
case OP_PUSHB_S:
case OP_PUSHB_ENT: