From a0d85e33c21e2578f9e484eba969fa9419b81925 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 13 Mar 2020 17:50:57 +0900 Subject: [PATCH] [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. --- include/QF/pr_comp.h | 3 ++- libs/gamecode/pr_exec.c | 9 ++++++--- libs/gamecode/pr_opcode.c | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/include/QF/pr_comp.h b/include/QF/pr_comp.h index 80b9e963d..3c6ccc8fe 100644 --- a/include/QF/pr_comp.h +++ b/include/QF/pr_comp.h @@ -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 diff --git a/libs/gamecode/pr_exec.c b/libs/gamecode/pr_exec.c index 718e2b09a..a73e5a474 100644 --- a/libs/gamecode/pr_exec.c +++ b/libs/gamecode/pr_exec.c @@ -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); } diff --git a/libs/gamecode/pr_opcode.c b/libs/gamecode/pr_opcode.c index dc3a59fb9..3d3e8fe17 100644 --- a/libs/gamecode/pr_opcode.c +++ b/libs/gamecode/pr_opcode.c @@ -1181,17 +1181,22 @@ VISIBLE const opcode_t pr_opcodes[] = { {"", "movepi", OP_MOVEPI, true, ev_pointer, ev_short, ev_pointer, PROG_VERSION, - "%Ga, %Gb, %Gc", + "%Ga, %sb, %Gc", }, - {"", "memset", OP_MEMSET, true, + {"", "memseti", OP_MEMSETI, true, + ev_integer, ev_short, ev_void, + PROG_VERSION, + "%Ga, %sb, %gc", + }, + {"", "memsetp", OP_MEMSETP, true, ev_integer, ev_integer, ev_pointer, PROG_VERSION, "%Ga, %Gb, %Gc", }, - {"", "memseti", OP_MEMSETI, true, + {"", "memsetpi", OP_MEMSETPI, true, ev_integer, ev_short, ev_pointer, PROG_VERSION, - "%Ga, %Gb, %Gc", + "%Ga, %sb, %Gc", }, {"", "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: