Arrays work now

This commit is contained in:
nilspolek 2024-01-23 22:05:23 +01:00
parent 797bfa45eb
commit 4f0fc8a364

10
njvm.c
View File

@ -43,7 +43,6 @@ void execute(struct program program) {
ObjRef tempObj2; ObjRef tempObj2;
int tempInt; int tempInt;
for (i = 0; i < *program.size; ++i) { for (i = 0; i < *program.size; ++i) {
printf("Program ist an der stelle %i\n", i);
if (debug == 1) debugMenu(fp, stack, &debug, i); if (debug == 1) debugMenu(fp, stack, &debug, i);
switch (program.program[i] >> 24) { switch (program.program[i] >> 24) {
case HALT: case HALT:
@ -274,12 +273,11 @@ void execute(struct program program) {
break; break;
case PUTFA: case PUTFA:
if (debug == 1) printf("putfa"); if (debug == 1) printf("putfa");
tempObj = pop(stack).u.objRef; tempObj = pop(stack).u.objRef; // Value
tempObj2 = pop(stack).u.objRef; tempObj2 = pop(stack).u.objRef; // Index
bip.op1 = pop(stack).u.objRef; bip.op1 = tempObj2;
bigPrint(stdout);
tempInt = bigToInt(); tempInt = bigToInt();
setField(tempObj2, tempInt,tempObj); setField(pop(stack).u.objRef, tempInt,tempObj);
break; break;
case GETSZ: case GETSZ:
if (debug == 1) printf("getsz"); if (debug == 1) printf("getsz");