summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-25 16:24:29 +0100
committerubq323 <ubq323@ubq323.website>2024-06-25 16:24:29 +0100
commita14bf1188c4cee23db44a590ada52aa8778a2a3f (patch)
treea5f5d3ecd18427e12f0133ed98e3e251fdf3a58d /vm.c
parente48386449b1f50c9f9d9b0645c8c469c1d4cbe4a (diff)
add setting locals
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c7
1 files changed, 7 insertions, 0 deletions
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: { \