fix comparisons
This commit is contained in:
parent
6319ddcad9
commit
1f02f49cdf
23
njvm.c
23
njvm.c
@ -142,49 +142,48 @@ void execute(struct program program) {
|
|||||||
bip.op2 = pop(stack).u.objRef;
|
bip.op2 = pop(stack).u.objRef;
|
||||||
bip.op1 = pop(stack).u.objRef;
|
bip.op1 = pop(stack).u.objRef;
|
||||||
bigFromInt(bigCmp() != 0);
|
bigFromInt(bigCmp() != 0);
|
||||||
push(stack,stackSlotWithObjRef(bip.res));
|
push(stack, stackSlotWithObjRef(bip.res));
|
||||||
break;
|
break;
|
||||||
case EQ:
|
case EQ:
|
||||||
if (debug == 1) printf("eq: %i == %i\n", peek(stack, 2), peek(stack, 1));
|
if (debug == 1) printf("eq: %i == %i\n", peek(stack, 2), peek(stack, 1));
|
||||||
bip.op2 = pop(stack).u.objRef;
|
bip.op2 = pop(stack).u.objRef;
|
||||||
bip.op1 = pop(stack).u.objRef;
|
bip.op1 = pop(stack).u.objRef;
|
||||||
if (bigCmp() == 0) push(stack, stackSlotWithObjRef(getIntObj(true)));
|
bigFromInt(bigCmp() == 0);
|
||||||
else push(stack, stackSlotWithObjRef(getIntObj(false)));
|
push(stack, stackSlotWithObjRef(bip.res));
|
||||||
break;
|
break;
|
||||||
case LT:
|
case LT:
|
||||||
if (debug == 1) printf("lt: %i < %i\n", peek(stack, 2), peek(stack, 1));
|
if (debug == 1) printf("lt: %i < %i\n", peek(stack, 2), peek(stack, 1));
|
||||||
bip.op2 = pop(stack).u.objRef;
|
bip.op2 = pop(stack).u.objRef;
|
||||||
bip.op1 = pop(stack).u.objRef;
|
bip.op1 = pop(stack).u.objRef;
|
||||||
if (bigCmp() < 0) push(stack, stackSlotWithObjRef(getIntObj(true)));
|
bigFromInt(bigCmp() < 0);
|
||||||
else push(stack, stackSlotWithObjRef(getIntObj(false)));
|
push(stack, stackSlotWithObjRef(bip.res));
|
||||||
break;
|
break;
|
||||||
case LE:
|
case LE:
|
||||||
if (debug == 1) printf("le: %i <= %i\n", peek(stack, 2), peek(stack, 1));
|
if (debug == 1) printf("le: %i <= %i\n", peek(stack, 2), peek(stack, 1));
|
||||||
bip.op2 = pop(stack).u.objRef;
|
bip.op2 = pop(stack).u.objRef;
|
||||||
bip.op1 = pop(stack).u.objRef;
|
bip.op1 = pop(stack).u.objRef;
|
||||||
if (bigCmp() <= 0) push(stack, stackSlotWithObjRef(getIntObj(true)));
|
bigFromInt(bigCmp() <= 0);
|
||||||
else push(stack, stackSlotWithObjRef(getIntObj(false)));
|
push(stack, stackSlotWithObjRef(bip.res));
|
||||||
break;
|
break;
|
||||||
case GT:
|
case GT:
|
||||||
if (debug == 1) printf("gt: %i > %i\n", peek(stack, 2), peek(stack, 1));
|
if (debug == 1) printf("gt: %i > %i\n", peek(stack, 2), peek(stack, 1));
|
||||||
bip.op2 = pop(stack).u.objRef;
|
bip.op2 = pop(stack).u.objRef;
|
||||||
bip.op1 = pop(stack).u.objRef;
|
bip.op1 = pop(stack).u.objRef;
|
||||||
if (bigCmp() > 0) push(stack, stackSlotWithObjRef(getIntObj(true)));
|
bigFromInt(bigCmp() > 0);
|
||||||
else push(stack, stackSlotWithObjRef(getIntObj(false)));
|
push(stack, stackSlotWithObjRef(bip.res));
|
||||||
break;
|
break;
|
||||||
case GE:
|
case GE:
|
||||||
if (debug == 1) printf("ge: %i >= %i\n", peek(stack, 2), peek(stack, 1));
|
if (debug == 1) printf("ge: %i >= %i\n", peek(stack, 2), peek(stack, 1));
|
||||||
bip.op2 = pop(stack).u.objRef;
|
bip.op2 = pop(stack).u.objRef;
|
||||||
bip.op1 = pop(stack).u.objRef;
|
bip.op1 = pop(stack).u.objRef;
|
||||||
if (bigCmp() >= 0) push(stack, stackSlotWithObjRef(getIntObj(true)));
|
bigFromInt(bigCmp() >= 0);
|
||||||
else push(stack, stackSlotWithObjRef(getIntObj(false)));
|
push(stack, stackSlotWithObjRef(bip.res));
|
||||||
break;
|
break;
|
||||||
case BRF:
|
case BRF:
|
||||||
if (debug == 1) printf("brf: %i\n", SIGN_EXTEND(IMMEDIATE(program.program[i])));
|
if (debug == 1) printf("brf: %i\n", SIGN_EXTEND(IMMEDIATE(program.program[i])));
|
||||||
if (debug == 1) printf("pop: %i\n", peek(stack, 1));
|
if (debug == 1) printf("pop: %i\n", peek(stack, 1));
|
||||||
bip.op1 = pop(stack).u.objRef;
|
bip.op1 = pop(stack).u.objRef;
|
||||||
int b = bigToInt();
|
int b = bigToInt();
|
||||||
printf("%i , %i",b, false);
|
|
||||||
if (b == false) {
|
if (b == false) {
|
||||||
i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1;
|
i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1;
|
||||||
if (debug == 1) printf("new i: %i\n", i);
|
if (debug == 1) printf("new i: %i\n", i);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user