forked from Imagelibrary/binutils-gdb
sim/riscv: fix JALR instruction simulation
Fix 32bit 'jalr rd,ra,imm' integer instruction, where RD was written before using it to calculate destination address. This commit also improves testutils.inc for riscv; make use of pushsection and popsection when adding things to .data, and setup the %gp global pointer register within the 'start' macro. Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
committed by
Andrew Burgess
parent
29736fc507
commit
1c37b30945
22
sim/testsuite/riscv/jalr.s
Normal file
22
sim/testsuite/riscv/jalr.s
Normal file
@@ -0,0 +1,22 @@
|
||||
# Basic jalr tests.
|
||||
# mach: riscv
|
||||
|
||||
.include "testutils.inc"
|
||||
|
||||
start
|
||||
|
||||
# Load desination into register a0.
|
||||
la a0, good_dest
|
||||
|
||||
# Jump to the destination in a0.
|
||||
jalr a0, a0, 0
|
||||
|
||||
# If we write destination into a0 before reading it in order
|
||||
# to jump, we might end up here.
|
||||
bad_dest:
|
||||
fail
|
||||
|
||||
# We should end up here.
|
||||
good_dest:
|
||||
pass
|
||||
fail
|
||||
@@ -21,8 +21,9 @@
|
||||
# Trigger OS trap.
|
||||
ecall;
|
||||
exit 0;
|
||||
.data
|
||||
.pushsection .data
|
||||
1: .asciz "pass\n"
|
||||
.popsection
|
||||
.endm
|
||||
|
||||
# MACRO: fail
|
||||
@@ -33,14 +34,15 @@
|
||||
# Use stdout.
|
||||
li a0, 1;
|
||||
# Point to the string.
|
||||
lla a1, 1f;
|
||||
la a1, 1f;
|
||||
# Number of bytes to write.
|
||||
li a2, 5;
|
||||
# Trigger OS trap.
|
||||
ecall;
|
||||
exit 0;
|
||||
.data
|
||||
.pushsection .data
|
||||
1: .asciz "fail\n"
|
||||
.popsection
|
||||
.endm
|
||||
|
||||
# MACRO: start
|
||||
@@ -49,4 +51,8 @@
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
.option push
|
||||
.option norelax
|
||||
lla gp, __global_pointer$
|
||||
.option pop
|
||||
.endm
|
||||
|
||||
Reference in New Issue
Block a user