diff --git a/src/instruction_executor.c b/src/instruction_executor.c index 30a104a..2c1e12d 100644 --- a/src/instruction_executor.c +++ b/src/instruction_executor.c @@ -239,7 +239,7 @@ int execute_instruction_on_cpu(CPU *cpu, uint32_t instruction) { // TODO conside imm |= (instruction >> 12) & 0xFF << 12; // Extract imm[19:12]*/ registers[rd] = cpu->programCounter + 4; - cpu->programCounter += imm; + cpu->programCounter += imm - 4; // program counter is incremented after this, and we have to execute the function we point to printf("JAL: Jumped to %u + %d = 0x%X (inst %d)", registers[rd], imm, cpu->programCounter, cpu->programCounter / 4); break;