Hi, i'm new in this forum and i need help with mips assembly.
I wrote this code but i can't found the error.

#Convert from decimale base to binary one using recursive procedure



    .data
prompt: .asciiz "Insert decimal number: "
output: .asciiz "The number in binary base is: "

     .text
     .globl main

main:

# Read int
    li $v0, 4           
    la $a0, prompt      # $a0 string address
    syscall             
       

    li $v0, 5       
    syscall             # read int and store in $v0

# Calculate  

   move $a0, $v0        # $a0 n
   jal  converti        # call converti(n)
   move $s0, $v0        # $s0 n converted
   
# Print result
    li $v0, 4        
    la $a0, output    # $a0 string address
    syscall        
    move $a0, $s0    # $a0 n converted
    li $v0, 1        
    syscall        # print n converted

# end of programma  
    li $v0, 10         # $v0 exit code
    syscall        

converti:
       addi $sp, $sp,-8          # allocates stack
       sw   $ra, 4($sp)        # save return address
       sw   $a0, 0($sp)        # save n
       li   $v0, 1            
       j    end

converti_main:
    div $a0, $0            # divides n by zero
    mflo $t1            # save quotient
    mfhi $t2            # save rest
    sll $t2,$t2,1                # shift left
    add $t2,$t2,$0              # sum for the rest
    bne  $a0, $zero, converti_main    # if n !=0 go to start of converti_main cicle

    jal  converti        
    lw   $a0, 0($sp)        # restore n in $v1

end:

    lw   $ra, 4($sp)        # restore return address
    addi $sp, $sp, 8        # deallocates stack
    jr   $ra

The problem is that I can't let him print the sequence of 0 and1 but only MSB

Please!

please help me!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.