From 910ad02d86672cc3020cc5df0fa451ef4dd69bfd Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 19 Nov 2023 20:25:29 +0200 Subject: implement jalr --- tasm/src/parser.y | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tasm/src/parser.y') diff --git a/tasm/src/parser.y b/tasm/src/parser.y index a39c9c1..204fe0a 100644 --- a/tasm/src/parser.y +++ b/tasm/src/parser.y @@ -73,7 +73,7 @@ %token ecall ebreak pcall %token fence /* meta */ -%token li la nop +%token mv li la nop /* m (avoid name clash with stdlib div) */ %token mul diV rem @@ -292,8 +292,8 @@ i {emit_reloc(ctx, RELOC_J, $4); emit_u(ctx, OPCODE_JAL, $2, 0);} - | jalr gpr "," gpr "," imm - {emit_i(ctx, OPCODE_JALR, $2, 0, $4, $6);} + | jalr gpr "," imm "(" gpr ")" + {emit_i(ctx, OPCODE_JALR, $2, 0, $6, $4);} | beq gpr "," gpr "," addr {emit_reloc(ctx, RELOC_B, $6); @@ -337,6 +337,9 @@ i {emit_d(ctx, OPCODE_DIOP, $2, $4, $6, check_nop3($8));} /* meta */ + | mv gpr "," gpr + {emit_i(ctx, OPCODE_OP_IMM, $2, OP_IMM_ADDI, $4, 0);} + | nop {emit_i(ctx, OPCODE_OP_IMM, X0_NUM, OP_IMM_ADDI, X0_NUM, 0);} -- cgit v1.3