assembly - Cannot access and print byte array in index in mips -


i trying print random byte screen check see if i'm getting right element. use li $v0, 11 since byte apparently, can lw , use byte value, tried , doesn't work well. prints out address 268501003 example @ current row + col index set to, , address change depending on arguments set $a0 , $a1 prior calling calculate address. i'm getting no output array index value i'm trying print. please help!

.data  n: .word 10  # gives board dimensions  board:    .byte 1, 0, 0, 0, 0, 0, 0, 0, 0, 0    .byte 1, 1, 0, 0, 0, 0, 0, 0, 0, 0    .byte 0, 0, 0, 1, 0, 0, 0, 0, 0, 0    .byte 0, 0, 1, 0, 1, 0, 0, 0, 0, 0    .byte 0, 0, 0, 0, 1, 0, 0, 0, 0, 0    .byte 0, 0, 0, 0, 1, 1, 1, 0, 0, 0    .byte 0, 0, 0, 1, 0, 0, 1, 0, 0, 0    .byte 0, 0, 1, 0, 0, 0, 0, 0, 0, 0    .byte 0, 0, 1, 0, 0, 0, 0, 0, 0, 0    .byte 0, 0, 1, 0, 0, 0, 0, 0, 0, 0  newboard: .space 100  .data  maxiter: .word 0 nn: .word 0 promptmsg: .asciiz "# iterations: " dot: .asciiz "." newline: .asciiz "\n" .text #=============================== main:  la $a0, promptmsg jal printtext  li $v0, 5 syscall  li $a0, 6 #random row/col index li $a1, 7 la $a2, board jal calculate_address  move $t5, $v0  li $v0, 1 move $a0, $t5 syscall  la $a0, newline jal printtext  li $t7, 0 li, $a0, 0 lb $t7, board($t5) move $a0, $t7 li $v0, 11 syscall  li $v0, 10 syscall  printtext: li $v0, 4 syscall jr $ra   calculate_address: #(row index * column size + column index)*datasize + base address #a0 = rowindex, a1 = colindex, a2 = base address lw $t6, n # col size li $t3, 0 mult $a0, $t6 mfhi $t3 add $t3, $t3, $a1 add $t3, $t3, $a2 #la $a0, msg4 #jal printtext move $v0, $t3 #return address of element [i][j] jr $ra 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -