fix jump not working right
This commit is contained in:
parent
27400289f5
commit
55af679c39
6
njvm.c
6
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user