aboutsummaryrefslogtreecommitdiff
path: root/tasm
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-10-29 14:38:33 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2023-10-29 14:38:33 +0200
commit5d29afb530ffdaab4b5032b7422da988b31c0867 (patch)
tree0135976b951fa4c860a043f07e6d555e40c60d1f /tasm
parent80d78c5589d42f81b04e671b28c103a2112458d1 (diff)
downloadtri-5d29afb530ffdaab4b5032b7422da988b31c0867.tar.gz
tri-5d29afb530ffdaab4b5032b7422da988b31c0867.zip
initial working compiled program on simulator
Diffstat (limited to 'tasm')
-rw-r--r--tasm/gen/gen_parser.c4
-rw-r--r--tasm/src/assembler.c2
-rw-r--r--tasm/src/parser.y4
-rw-r--r--tasm/tests/a.t2
4 files changed, 6 insertions, 6 deletions
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