From a14bf1188c4cee23db44a590ada52aa8778a2a3f Mon Sep 17 00:00:00 2001 From: ubq323 Date: Tue, 25 Jun 2024 16:24:29 +0100 Subject: add setting locals --- vm.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'vm.c') diff --git a/vm.c b/vm.c index 39bf65d..9a69472 100644 --- a/vm.c +++ b/vm.c @@ -45,6 +45,7 @@ int runvm(State *S) { if (S->do_trace) { printf("\t[%lu + %lu] : ",th->fp, th->sp); for (int i = 0; i < th->sp; i++) { + printf("(%d) ",i); print_val(th->stack[th->fp + i]); printf(" ; "); } @@ -124,6 +125,12 @@ int runvm(State *S) { PUSH(th->stack[th->fp + lidx]); break; } + case OP_SETLOCAL: { + uint8_t lidx = RBYTE(); + Val v = PEEK(); + th->stack[th->fp + lidx] = v; + break; + } #define BINARY_OP(opcode, OP, RET_TYPE) \ case opcode: { \ -- cgit v1.2.3