.include "exit_return.s" .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 # Jump to 'just_after' auipc ra, 0 jalr 16(ra) # Jump far to test jalr with negative offset jal fnfar exret # just_after : address is 16 bytes after auipc just_after: # ra must still be the old address ret exret # 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 exret # fn1 : just return fn1: ret exret fnneg: addi a0, zero, 0 exret fnfar: auipc ra, 0 jalr -8(ra) exret