Write a small subroutine, that converts numbers in the range 0 through 15 into a
printable ASCII-coded character: '0' through '9', or 'A' through 'F', depending on the number.
For numbers not in the range 0 through 15, some bits will be ignored.

Name: The subroutine must be called hexasc .
Parameter: One, in register $a0 . The 4 least significant bits specify a number, from 0 through 15.
All other bits in register $a0 can have any value and must be ignored.
Return value: The 7 least significant bits in register $v0 must be an ASCII code as described below.
All other bits must be zero when your function returns.
Required action: The function must convert input values 0 through 9 into the ASCII codes for digits
'0' through '9', respectively. Input values 10 through 15 must be converted to the ASCII codes for
letters 'A' through 'F', respectively.

```
.text

 main:
      li    $a0,0       # change this to test different values

      jal   hexasc      # call hexasc
      nop               # delay slot filler (just in case)  

      move  $a0,$v0     # copy return value to argument register

      li    $v0,11      # syscall with v0 = 11 will print out
      syscall           # one byte from a0 to the Run I/O window

stop:   j   stop        # stop after one run
       nop              # delay slot filler (just in case)

```

I wrote my `hexasc` subroutine here and for some reason that I'm not understand so it doesn't work. I can't figure it out in which part i have bugs and maybe I'm not doing as it Say's in the specification above.
 Any help would be appreciated, Thanks in advance.

```
hexasc:
        addi    $sp,$sp,-4      #make space on the stack
        sw      $a0,0($sp)      #store $a0 on the stack
        li      $t0,0x30        #$t0 = 0x30 ('0' in ascii)
        andi    $a0,$a0,0xf     #only 4 least significant bits is 
                                #needed ignore other bits
loop:       
        add     $a0,$a0,$t0     #$a0 i will think why i did this
        addi    $t0,$t0,1       #increment $t0 by 1
        beq     $t0,0x39,loop2  # if $t0 = 0x39 (9 in ascii)
        j       loop

        li      $t1,0x41       # $t1 = 0x41 ( A in ascii)
loop2:  
        andi    $a0,$a0,0xf    # only 4 LSB ignore other bits
        add     $a0,$a0,$t1    # ???? i will think about this
        beq     $t1,0x46,done  # if $t1 = 0x46 (F in ascii)
        j       loop2

done:           
        add     $v0,$a0,$a0    # return  $a0 in $v0 suspicious ...?
        lw      $a0,0($sp)     # restore the $a0 
        addi    $sp,$sp,4      # put back the stack
        jr      $ra

```