hey friends im new to mips and im trying to convert numbers from a linked list into base 4 and print them out but i dont really know how to do that i have heared about a way with dividing the numbers by 4 and pushing the remainder of each number to a somekind of stack but im unsure how to do that or which stack i should use
i want to print out each number in the list as base 4 number
i would love to get some help or guidance how to do it
here is my code so far (im printing the sum of the numbers too and the sum of the postive numbers whos divided by 4)
.data
num1: .word -1 , num3
num2: .word 17 , 0
num3: .word 32 , num5
num4: .word -6 , num2
num5: .word 1972 , num4
.globl main
.text
main:
la $t1,num1
li $s0,0 # sum of the linked list
li $s1,0 # sum of divided by 4 and postivie in the list
li $t3,0 # temp remainder for the div by 4
li $t4,4
li $t5,0 # counter how many words we enterted the stack
sumloop:
beqz $t1,exit
lw $t0,0($t1)
add $s0,$s0,$t0 # adding to the sum the value in the current node
lw $t1,4($t1)
### need your help here :)
blez $t0,sumloop # if negative or zero dont add to s1
div $t0,$t4
mfhi $t3
bnez $t3,sumloop # if the value isnt divided by 4 without remainder jump to sumloop
add $s1,$s1,$t0
j sumloop
exit:
move $a0,$s0
li $v0,1
syscall
li $a0,'\n'
li $v0,11
syscall
move $a0,$s1
li $v0,1
syscall