I have written a code that prints array in 6 columns:
# -----
# Print array elements.
li $t1, 0
la $s0, py_sars
print_lp1:
bgt $t1, 59, print_end1
lw $a0, 0($s0) #get the value pointed by s0
li $v0, 1 #print int
syscall
la $a0, space
li $v0, 4 #print space between each output
syscall
addi $t1, $t1, 1 #increment counter for next element
addi $s0, $s0, 4
rem $t5, $t1, 6 #print areas in 6 columns
beq $t5, $zero, newline
j print_lp1
newline:
la $a0, new_ln
li $v0, 4 #print newline
syscall
j print_lp1
print_end1:
I can't get the elements aligned however.
We can asume that the longest length of the integer is 8, and must be right justified.
Could you please guide me on how to do this?
Thanks.