diff --git a/src/main.c b/src/main.c index 4d3df88..d7624e0 100644 --- a/src/main.c +++ b/src/main.c @@ -94,7 +94,7 @@ int main(int argc, char** argv){ } tinyriscv_hart hart; - hart.mem = malloc(hart.mem_size = mem_size); + hart.mem = calloc(hart.mem_size = mem_size, 1); //file handling FILE* file = fopen(file_path, "rb"); diff --git a/src/tinyriscv.h b/src/tinyriscv.h index ad81d0e..5426ce9 100644 --- a/src/tinyriscv.h +++ b/src/tinyriscv.h @@ -154,7 +154,7 @@ void tinyriscv_step(tinyriscv_hart* hart){ switch(opcode){ case /*LUI*/ 0x37: hart->x[rd] = inst & 0xfffff000; break; - case /*AUIPC*/ 0x17: hart->x[rd] = hart->pc + (inst & 0xfffff000); break; + case /*AUIPC*/ 0x17: hart->x[rd] = hart->pc - 4 + (inst & 0xfffff000); break; case /*JAL*/ 0x6f: hart->x[rd] = hart->pc; hart->pc += imm_j - 4; break; case /*JALR*/ 0x67: const u32 last_pc = hart->pc; diff --git a/tests/test.bin b/tests/test.bin index 73256dc..3df3f69 100644 Binary files a/tests/test.bin and b/tests/test.bin differ