a risc-v simulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
vriscv/tests/jalr.s

46 lines
674 B

.global _start
_start:
# Set base value of a0 to 'test failed'
addi a0, zero, 1
# Setup a stack
addi sp, sp, 0x100
# Try to call a simple function
jal fn1
# Try to call two imbricated functions
jal fn0
auipc t0, 0
jalr ra, 12(t0)
ebreak
# just_after : address is 12 bytes after auipc
just_after:
addi a0, zero, 0
ret
ebreak
# fn0 : function that calls fn1 and returns
fn0:
# Make space on the stack
addi sp, sp, -4
# Save ra
sw ra, 0(sp)
# Call fn1
jal fn1
# Restore ra and stack
lw ra, 0(sp)
addi sp, sp, 4
ret
ebreak
# fn1 : just return
fn1:
ret
ebreak