  .section    .boot, "ax", @progbits

 .global _start
_start:
        la      gp, _gp                 # Initialize global pointer
	la      sp, _fstack

        # Clear registers
        mv      s0, zero
        mv      s1, zero
        mv      s2, zero
        mv      s3, zero
        mv      s4, zero
        mv      s5, zero
        mv      s6, zero
        mv      s7, zero
        mv      s8, zero
        mv      s9, zero
        mv      s10, zero
        mv      s11, zero

        mv      tp, zero
        mv      t0, zero
        mv      t1, zero
        mv      t2, zero
        mv      t3, zero
        mv      t4, zero
        mv      t5, zero
        mv      t6, zero

        mv      a0, zero
        mv      a1, zero
        mv      a2, zero
        mv      a3, zero
        mv      a4, zero
        mv      a5, zero
        mv      a6, zero
        mv      a7, zero
        call    main

        .size _start, . - _start

        .global refresh_regs
refresh_regs:
        la      t0,_regs
        sw      ra,4(t0)
        sw      sp,8(t0)
        sw      gp,12(t0)
        
        sw      tp,16(t0)
        sw      t0,20(t0)
        sw      t1,24(t0)
        sw      t2,28(t0)
        
        sw      s0,32(t0)
        sw      s1,36(t0)
        sw      a0,40(t0)
        sw      a1,44(t0)

        sw      a2,48(t0)
        sw      a3,52(t0)
        sw      a4,56(t0)
        sw      a5,60(t0)

        sw      a6,64(t0)
        sw      a7,68(t0)
        sw      s2,72(t0)
        sw      s3,76(t0)

        sw      s4,80(t0)
        sw      s5,84(t0)
        sw      s6,88(t0)
        sw      s7,92(t0)

        sw      s8,96(t0)
        sw      s9,100(t0)
        sw      s10,104(t0)
        sw      s11,108(t0)

        sw      t3,112(t0)
        sw      t4,116(t0)
        sw      t5,120(t0)
        sw      t6,124(t0)
        ret
        .size refresh_regs, . - refresh_regs
