From 53d03b32e0f8797d475d02ccbc3bab4952967c75 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Tue, 22 Oct 2024 18:31:21 +0200 Subject: [PATCH] "The" fix Which is just one line... A basic arithmetic operation... --- src/instruction_executor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;