From 4f0fc8a364a16b6ba7ae04ca5576736937ddb3b1 Mon Sep 17 00:00:00 2001 From: nilspolek Date: Tue, 23 Jan 2024 22:05:23 +0100 Subject: [PATCH] Arrays work now --- njvm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/njvm.c b/njvm.c index 2069520..c6e3db0 100644 --- a/njvm.c +++ b/njvm.c @@ -43,7 +43,6 @@ void execute(struct program program) { ObjRef tempObj2; int tempInt; for (i = 0; i < *program.size; ++i) { - printf("Program ist an der stelle %i\n", i); if (debug == 1) debugMenu(fp, stack, &debug, i); switch (program.program[i] >> 24) { case HALT: @@ -274,12 +273,11 @@ void execute(struct program program) { break; case PUTFA: if (debug == 1) printf("putfa"); - tempObj = pop(stack).u.objRef; - tempObj2 = pop(stack).u.objRef; - bip.op1 = pop(stack).u.objRef; - bigPrint(stdout); + tempObj = pop(stack).u.objRef; // Value + tempObj2 = pop(stack).u.objRef; // Index + bip.op1 = tempObj2; tempInt = bigToInt(); - setField(tempObj2, tempInt,tempObj); + setField(pop(stack).u.objRef, tempInt,tempObj); break; case GETSZ: if (debug == 1) printf("getsz");