diff --git a/njvm.c b/njvm.c index 21ac61b..530076e 100644 --- a/njvm.c +++ b/njvm.c @@ -142,49 +142,48 @@ void execute(struct program program) { bip.op2 = pop(stack).u.objRef; bip.op1 = pop(stack).u.objRef; bigFromInt(bigCmp() != 0); - push(stack,stackSlotWithObjRef(bip.res)); + push(stack, stackSlotWithObjRef(bip.res)); break; case EQ: if (debug == 1) printf("eq: %i == %i\n", peek(stack, 2), peek(stack, 1)); bip.op2 = pop(stack).u.objRef; bip.op1 = pop(stack).u.objRef; - if (bigCmp() == 0) push(stack, stackSlotWithObjRef(getIntObj(true))); - else push(stack, stackSlotWithObjRef(getIntObj(false))); + bigFromInt(bigCmp() == 0); + push(stack, stackSlotWithObjRef(bip.res)); break; case LT: if (debug == 1) printf("lt: %i < %i\n", peek(stack, 2), peek(stack, 1)); bip.op2 = pop(stack).u.objRef; bip.op1 = pop(stack).u.objRef; - if (bigCmp() < 0) push(stack, stackSlotWithObjRef(getIntObj(true))); - else push(stack, stackSlotWithObjRef(getIntObj(false))); + bigFromInt(bigCmp() < 0); + push(stack, stackSlotWithObjRef(bip.res)); break; case LE: if (debug == 1) printf("le: %i <= %i\n", peek(stack, 2), peek(stack, 1)); bip.op2 = pop(stack).u.objRef; bip.op1 = pop(stack).u.objRef; - if (bigCmp() <= 0) push(stack, stackSlotWithObjRef(getIntObj(true))); - else push(stack, stackSlotWithObjRef(getIntObj(false))); + bigFromInt(bigCmp() <= 0); + push(stack, stackSlotWithObjRef(bip.res)); break; case GT: if (debug == 1) printf("gt: %i > %i\n", peek(stack, 2), peek(stack, 1)); bip.op2 = pop(stack).u.objRef; bip.op1 = pop(stack).u.objRef; - if (bigCmp() > 0) push(stack, stackSlotWithObjRef(getIntObj(true))); - else push(stack, stackSlotWithObjRef(getIntObj(false))); + bigFromInt(bigCmp() > 0); + push(stack, stackSlotWithObjRef(bip.res)); break; case GE: if (debug == 1) printf("ge: %i >= %i\n", peek(stack, 2), peek(stack, 1)); bip.op2 = pop(stack).u.objRef; bip.op1 = pop(stack).u.objRef; - if (bigCmp() >= 0) push(stack, stackSlotWithObjRef(getIntObj(true))); - else push(stack, stackSlotWithObjRef(getIntObj(false))); + bigFromInt(bigCmp() >= 0); + push(stack, stackSlotWithObjRef(bip.res)); break; case BRF: if (debug == 1) printf("brf: %i\n", SIGN_EXTEND(IMMEDIATE(program.program[i]))); if (debug == 1) printf("pop: %i\n", peek(stack, 1)); bip.op1 = pop(stack).u.objRef; int b = bigToInt(); - printf("%i , %i",b, false); if (b == false) { i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1; if (debug == 1) printf("new i: %i\n", i); diff --git a/njvm.o b/njvm.o index 44becfa..f15b144 100644 Binary files a/njvm.o and b/njvm.o differ diff --git a/support.o b/support.o index b9bac9c..83da1f6 100644 Binary files a/support.o and b/support.o differ