From 5d29afb530ffdaab4b5032b7422da988b31c0867 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 29 Oct 2023 14:38:33 +0200 Subject: initial working compiled program on simulator --- tasm/gen/gen_parser.c | 4 ++-- tasm/src/assembler.c | 2 +- tasm/src/parser.y | 4 ++-- tasm/tests/a.t | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tasm') diff --git a/tasm/gen/gen_parser.c b/tasm/gen/gen_parser.c index aadb8fb..dc1eac6 100644 --- a/tasm/gen/gen_parser.c +++ b/tasm/gen/gen_parser.c @@ -2799,8 +2799,8 @@ yyreduce: case 118: /* i: li gpr "," imm */ #line 349 "src/parser.y" - {emit_u(ctx, OPCODE_LUI, (yyvsp[-2].gpr), 0); - emit_i(ctx, OPCODE_OP_IMM, (yyvsp[-2].gpr), OP_IMM_ADDI, (yyvsp[-2].gpr), 0);} + {emit_u(ctx, OPCODE_LUI, (yyvsp[-2].gpr), tri_sr((yyvsp[0].tri), 9)); + emit_i(ctx, OPCODE_OP_IMM, (yyvsp[-2].gpr), OP_IMM_ADDI, (yyvsp[-2].gpr), tri_mask((yyvsp[0].tri), 9));} #line 2805 "gen/gen_parser.c" break; diff --git a/tasm/src/assembler.c b/tasm/src/assembler.c index 3faf1fb..731a736 100644 --- a/tasm/src/assembler.c +++ b/tasm/src/assembler.c @@ -549,7 +549,7 @@ tri_t check_csr(const char *csr) { /** @todo only mpower supported for now, will have to work on this */ assert(strcmp(csr, "mpower")); - return 0; + return tri_from(-9841); } tri_t check_width(const char *width) diff --git a/tasm/src/parser.y b/tasm/src/parser.y index 64418d1..a39c9c1 100644 --- a/tasm/src/parser.y +++ b/tasm/src/parser.y @@ -346,8 +346,8 @@ i emit_i(ctx, OPCODE_OP_IMM, $2, OP_IMM_ADDI, $2, 0);} | li gpr "," imm - {emit_u(ctx, OPCODE_LUI, $2, 0); - emit_i(ctx, OPCODE_OP_IMM, $2, OP_IMM_ADDI, $2, 0);} + {emit_u(ctx, OPCODE_LUI, $2, tri_sr($4, 9)); + emit_i(ctx, OPCODE_OP_IMM, $2, OP_IMM_ADDI, $2, tri_mask($4, 9));} /* stuff like call and ret TBD once I've come up with a proper register * calling convention so we know which register to use as ra */ diff --git a/tasm/tests/a.t b/tasm/tests/a.t index f23f9c0..da41b34 100644 --- a/tasm/tests/a.t +++ b/tasm/tests/a.t @@ -1,6 +1,6 @@ start: li x1, 48 li x2, 19683 - st w, x1, 0(x2) + st t, x1, 0(x2) li x1, 3 csrrw mpower, x0, x1 -- cgit v1.3