assembly - How do I load the Address of an array in MIPS -


.data stra: .asciiz "original array:\n" strb: .asciiz "second array:\n:" newline: .asciiz "\n" space : .asciiz " " # start of original array. original: .word 200, 270, 250, 100 .word 205, 230, 105, 235 .word 190, 95, 90, 205 .word 80, 205, 110, 215 # next statement allocates room other array. # array takes 4*16=64 bytes. # second: .space 64 .align 2 .globl main .text main:  la $t0, original  #load address of original array li $v0, 4   #system call code printing la $a0, stra syscall  addi $t1, $zero,0 sll $t2, $t1, 2 add $t3, $t2, $t1 li $v0, 4 lw $a0, 0($t3) syscall 

i trying make program transposes matrix. keep getting error saying bad address read: 0x00000000. tried loading addresses of matrix , loading 0 $t1 beginning index , multiplying 4 , adding base address of array.

as can see have loaded address of array , added i*4 amount sll. why getting error?

system call 4 prints string. if want print array of integers you'll have write loop , use system call 1 (print_int) each integer in array.

the exception occurs @ lw $a0, 0($t3), , if @ way set $t3 should obvious couldn't have other value 0, i'm not sure expected happen there.
i'm assuming you're using simulator spim or mars, can find out these kinds of things yourself. simulator report address @ exception occurs, can set breakpoint @ address (or single-step until address) , @ values of registers see if make sense.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -