diff --git a/njvm.c b/njvm.c index 07d50c8..9f6a71b 100644 --- a/njvm.c +++ b/njvm.c @@ -150,7 +150,7 @@ void execute(struct program program) { if (debug == 1) printf("brf: %i\n", SIGN_EXTEND(IMMEDIATE(program.program[i]))); if (debug == 1) printf("pop: %i\n", peek(stack, 1)); if (pop(stack) == 0) { - i = SIGN_EXTEND(IMMEDIATE(program.program[i])); + i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1; if (debug == 1) printf("new i: %i\n", i); } break; @@ -158,12 +158,12 @@ void execute(struct program program) { if (debug == 1) printf("brt: %i\n", SIGN_EXTEND(IMMEDIATE(program.program[i]))); if (debug == 1) printf("pop: %i\n", peek(stack, 1)); if (pop(stack) == 1) { - i = SIGN_EXTEND(IMMEDIATE(program.program[i])); + i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1; if (debug == 1) printf("new i: %i\n", i); } case JMP: if (debug == 1) printf("jmp: %i\n", SIGN_EXTEND(IMMEDIATE(program.program[i]))); - i = SIGN_EXTEND(IMMEDIATE(program.program[i])); + i = SIGN_EXTEND(IMMEDIATE(program.program[i])) - 1; if (debug == 1) printf("new i: %i\n", i); break; }