From a62148255ee41a31bc616f42c98c33f25b2252a5 Mon Sep 17 00:00:00 2001 From: vhaudiquet Date: Mon, 9 Oct 2023 14:51:42 +0200 Subject: [PATCH] Added negative offset case for JALR --- tests/jalr.s | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/jalr.s b/tests/jalr.s index 48f743c..8a7564f 100644 --- a/tests/jalr.s +++ b/tests/jalr.s @@ -12,17 +12,19 @@ _start: # Try to call two imbricated functions jal fn0 + # Jump to 'just_after' auipc ra, 0 - jalr 12(ra) + jalr 16(ra) + + # Jump far to test jalr with negative offset + jal fnfar ebreak -# just_after : address is 12 bytes after auipc +# just_after : address is 16 bytes after auipc just_after: # ra must still be the old address - addi a0, zero, 0 ret - addi a0, zero, 1 ebreak # fn0 : function that calls fn1 and returns @@ -46,3 +48,12 @@ fn0: fn1: ret ebreak + +fnneg: + addi a0, zero, 0 + ebreak + +fnfar: + auipc ra, 0 + jalr -8(ra) + ebreak