fix comparisons
This commit is contained in:
parent
6319ddcad9
commit
1f02f49cdf
21
njvm.c
21
njvm.c
@ -148,43 +148,42 @@ void execute(struct program program) {
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user