.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 ra, 0 jalr 12(ra) ebreak # just_after : address is 12 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 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