diff --git a/bigint/build/bin/testbip b/bigint/build/bin/testbip index c09a576..19b0ef9 100755 Binary files a/bigint/build/bin/testbip and b/bigint/build/bin/testbip differ diff --git a/bigint/build/lib/libbigint.a b/bigint/build/lib/libbigint.a index f3b373c..591b9f9 100644 Binary files a/bigint/build/lib/libbigint.a and b/bigint/build/lib/libbigint.a differ diff --git a/bigint/src/libbigint.a b/bigint/src/libbigint.a index f3b373c..591b9f9 100644 Binary files a/bigint/src/libbigint.a and b/bigint/src/libbigint.a differ diff --git a/bigint/tst/testbip b/bigint/tst/testbip index c09a576..19b0ef9 100755 Binary files a/bigint/tst/testbip and b/bigint/tst/testbip differ diff --git a/njvm.c b/njvm.c index 9ffe24b..0e3bde7 100644 --- a/njvm.c +++ b/njvm.c @@ -52,7 +52,7 @@ void execute(struct program program) { int tempInt; for (i = 0; i < *program.size; ++i) { if (debug == 1 || bp == i) debugMenu(fp, stack, &debug, i, &bp); - if(debug == 1) printf("(%i)",i); + if (debug == 1) printf("(%i)", i); switch (program.program[i] >> 24) { case HALT: if (debug == 1) printf("halt\n"); @@ -260,25 +260,25 @@ void execute(struct program program) { case GETF: if (debug == 1) printf("getf\n"); tempObj = pop(stack).u.objRef; - push(stack, stackSlotWithObjRef(getField(tempObj,SIGN_EXTEND(IMMEDIATE(program.program[i]))))); + push(stack, stackSlotWithObjRef(getField(tempObj, SIGN_EXTEND(IMMEDIATE(program.program[i]))))); break; case PUTF: if (debug == 1) printf("putf\t%i\n", SIGN_EXTEND(IMMEDIATE(program.program[i]))); tempObj = pop(stack).u.objRef; tempObj2 = pop(stack).u.objRef; - setField(tempObj2, SIGN_EXTEND(IMMEDIATE(program.program[i])),tempObj); + setField(tempObj2, SIGN_EXTEND(IMMEDIATE(program.program[i])), tempObj); break; case NEWA: - if(debug == 1) printf("newa\n"); + if (debug == 1) printf("newa\n"); bip.op1 = pop(stack).u.objRef; push(stack, stackSlotWithObjRef(newRecord(bigToInt()))); break; case GETFA: - if(debug == 1) printf("getfa\n"); + if (debug == 1) printf("getfa\n"); bip.op1 = pop(stack).u.objRef; tempInt = bigToInt(); tempObj = pop(stack).u.objRef; - push(stack, stackSlotWithObjRef(getField(tempObj,bigToInt()))); + push(stack, stackSlotWithObjRef(getField(tempObj, bigToInt()))); break; case PUTFA: if (debug == 1) printf("putfa\n"); @@ -286,12 +286,12 @@ void execute(struct program program) { tempObj2 = pop(stack).u.objRef; // Index bip.op1 = tempObj2; tempInt = bigToInt(); - setField(pop(stack).u.objRef, tempInt,tempObj); + setField(pop(stack).u.objRef, tempInt, tempObj); break; case GETSZ: if (debug == 1) printf("getsz\n"); tempObj = pop(stack).u.objRef; - if(IS_PRIMITIVE(tempObj)) bigFromInt(-1); + if (IS_PRIMITIVE(tempObj)) bigFromInt(-1); else bigFromInt(GET_ELEMENT_COUNT(tempObj)); push(stack, stackSlotWithObjRef(bip.res)); break; @@ -301,13 +301,13 @@ void execute(struct program program) { break; case REFEQ: if (debug == 1) printf("refeq\n"); - if(pop(stack).u.objRef == pop(stack).u.objRef) bigFromInt(true); + if (pop(stack).u.objRef == pop(stack).u.objRef) bigFromInt(true); else bigFromInt(false); push(stack, stackSlotWithObjRef(bip.res)); break; case REFNE: if (debug == 1) printf("refeq\n"); - if(pop(stack).u.objRef != pop(stack).u.objRef) bigFromInt(true); + if (pop(stack).u.objRef != pop(stack).u.objRef) bigFromInt(true); else bigFromInt(false); push(stack, stackSlotWithObjRef(bip.res)); break; @@ -419,43 +419,53 @@ void swap() { } void garbageCollector() { + char *memToPurgePtr = halfHeapPtr - ((heapSizeKiB * 1024) / 2); swap(); - //printf("%s\n", "stack"); - for (int i = 0; i < stack.current; i++) { + printf("%s\n", "stack"); + for (int i = 0; i < *stack.current; i++) { if (stack.stack[i].isObjRef) { stack.stack[i].u.objRef = relocate(stack.stack[i].u.objRef); } } - //printf("%s\n", "globals"); - for (int i = 0; i < sda.size; i++) { + printf("%s\n", "globals"); + for (int i = 0; i < *sda.size; i++) { sda.sda[i] = relocate(sda.sda[i]); } - //printf("%s\n", "retVal"); +// printf("%s\n", "retVal"); //returnValue = relocate(returnValue); - //printf("%s\n", "op1"); + printf("%s\n", "op1"); bip.op1 = relocate(bip.op1); ObjRef b = bip.op1; - if(b!= NULL) + + if (b != NULL) //printf("%d\n", GET_SIZE(b)); //printf("%s\n", "op2"); bip.op2 = relocate(bip.op2); + b = bip.op2; - if(b!= NULL) + if (b != NULL) //printf("%d\n", GET_SIZE(b)); //printf("%s\n", "res"); bip.res = relocate(bip.res); b = bip.res; - if(b!= NULL) + + if (b != NULL) { //printf("%d\n", GET_SIZE(b)); - //printf("%s\n", "rem"); + printf("%s\n", "rem"); + bip.op1 = bip.rem; + bigPrint(stdout); bip.rem = relocate(bip.rem); + printf("%s\n", "rem"); + } + b = bip.rem; - if(b!= NULL) + printf("bip finished\n"); + if (b != NULL) //printf("%d\n", GET_SIZE(b)); @@ -575,4 +585,4 @@ int main(int argc, char *argv[]) { printf("Error: no code file specified\n"); return 1; } -} \ No newline at end of file +} diff --git a/njvm.o b/njvm.o index 52dfb78..05e75a1 100644 Binary files a/njvm.o and b/njvm.o differ