    #######################################################
    # (C) 2021 T. Risset
    # assembly skeleton fror writing assembly function by hand Code compiled from the follwing program with -O0 option
    # riscv64-linux-gnu-gcc -S whileLoop.c -o whileLoop.S -O0
    # and manually adapted to qtrvsim
    #######################################################

#pragma qtrvsim show terminal
#pragma qtrvsim show registers
#pragma qtrvsim show memory

.globl _start
.globl __start
    
.org 0x00000200

.text

__start:
_start:
    addi    sp,sp,-4    # reserve 4 bytes in stack
    sw    s0,0(sp)      # Store s0 in stack (s0 used by main)
    addi    s0,sp,4    # s0 <- fp (frame pointer)
    li    a5,10          # a5 <- 10, if you want to test another value
			 # change this value
    call dec
    lw    s0,0(sp)      # restore s0
    addi  sp,sp,4     # restore sp
    mv a5,a0          # get result from dec in a0 (check its value)	
loop:
    jal zero, loop    # loop at end of main, chack that a5 is i-1

dec:
	#add your code here



#pragma qtrvsim tab core
