aboutsummaryrefslogtreecommitdiff
path: root/triscv/src/cpu.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-04-30 15:44:47 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-04-30 15:44:47 +0300
commit912dd003b081b628085e86bc151b8d91fbccb0c8 (patch)
tree8e27533fc5555e4c152e3f132c2b09e0dba9d86d /triscv/src/cpu.c
parent9fce87134559f8b5f86e105283b59e61a1707d39 (diff)
downloadtri-912dd003b081b628085e86bc151b8d91fbccb0c8.tar.gz
tri-912dd003b081b628085e86bc151b8d91fbccb0c8.zip
janitorial duties
+ Add doc and formatting tooling
Diffstat (limited to 'triscv/src/cpu.c')
-rw-r--r--triscv/src/cpu.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/triscv/src/cpu.c b/triscv/src/cpu.c
index 9e82974..59ba238 100644
--- a/triscv/src/cpu.c
+++ b/triscv/src/cpu.c
@@ -113,8 +113,8 @@ static void do_op_imm(struct cpu *cpu, tri_t i)
break;
}
default: fprintf(stderr, "illegal/unimplemented OP_IMM at %lli, "
- "aborting\n", (long long int)cpu->pc);
- abort();
+ "aborting\n", (long long int)cpu->pc);
+ abort();
}
cpu->pc += 3;
@@ -129,7 +129,7 @@ static void do_op(struct cpu *cpu, tri_t i)
tri_t src2 = get_gpr(cpu, rs2);
switch (fn5) {
- case 0:
+ case 0:
switch (fn0) {
case OP_ADD: {
tri_t r = tri_add(src1, src2);
@@ -143,14 +143,14 @@ static void do_op(struct cpu *cpu, tri_t i)
break;
}
default: fprintf(stderr, "illegal/unimplemented OP at %lli, "
- "aborting\n", (long long int)cpu->pc);
- abort();
+ "aborting\n", (long long int)cpu->pc);
+ abort();
}
break;
- default: fprintf(stderr, "illegal/unimplemented OP at %lli, "
- "aborting\n", (long long int)cpu->pc);
- abort();
+ default: fprintf(stderr, "illegal/unimplemented OP at %lli, "
+ "aborting\n", (long long int)cpu->pc);
+ abort();
}
cpu->pc += 3;
@@ -174,8 +174,8 @@ static void do_system(struct cpu *cpu, tri_t i)
}
default: fprintf(stderr, "illegal/unimplemented SYSTEM at %lli,"
- "aborting\n", (long long int)cpu->pc);
- abort();
+ "aborting\n", (long long int)cpu->pc);
+ abort();
}
cpu->pc += 3;
@@ -297,13 +297,13 @@ static void do_branch(struct cpu *cpu, tri_t i)
bool take = false;
switch (fn0) {
- case BRANCH_BLT: take = tri_lt(c0, c1); break;
- case BRANCH_BGE: take = tri_ge(c0, c1); break;
- case BRANCH_BNE: take = tri_ne(c0, c1); break;
- case BRANCH_BEQ: take = tri_eq(c0, c1); break;
- default: fprintf(stderr, "illegal/unimplemented BRANCH at %lli,"
- "aborting\n", (long long int)cpu->pc);
- abort();
+ case BRANCH_BLT: take = tri_lt(c0, c1); break;
+ case BRANCH_BGE: take = tri_ge(c0, c1); break;
+ case BRANCH_BNE: take = tri_ne(c0, c1); break;
+ case BRANCH_BEQ: take = tri_eq(c0, c1); break;
+ default: fprintf(stderr, "illegal/unimplemented BRANCH at %lli,"
+ "aborting\n", (long long int)cpu->pc);
+ abort();
}
cpu->pc = take ? t : f;
@@ -336,11 +336,11 @@ void cpu_run(struct cpu *cpu, vm_t start)
case OPCODE_JALR: do_jalr(cpu, i); break;
case OPCODE_BRANCH: do_branch(cpu, i); break;
default: /** @todo raise illegal instruction exception */
- fprintf(stderr, "illegal/unimplemented "
- "instruction at %lli, aborting\n",
- (long long int)cpu->pc);
- abort();
- break;
+ fprintf(stderr, "illegal/unimplemented "
+ "instruction at %lli, aborting\n",
+ (long long int)cpu->pc);
+ abort();
+ break;
}
/* do_* is responsible for updating pc */