1

so I've come across a problem with my PCSpim program, after looking I still cannot find the right solution, I thought it may be the 'align' directive, either I'm missing one or I am missing it.

Here is the beginning of the program, initializing the array

  .data
  .align  2             # Let's make sure that it's aligned  

   Z: .word  10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23,
                        # above we allocated and initialized 13 
                        # elements of array Z 

  .space  80            # here we allocated space here for 20 elements
  .text

  .globl main

main:                   # main has to be a global label
  addu  $s7, $0, $ra    # save the return address
                        # in a global register
  la  $s3, Z            # $s3 has the starting address of Z 

===============================================================

I think it is around here where is messed up

#-------------------------------------Compute Z[12] = Z[k] + z[k+j]
 .text
 .align 2

    la $t3, Z            # put address of Z into $t3
    li $t5, 12           # put the index into $t5
    add $t5, $t2, $t3    # combine the two components of the address
    sw $t4, 0($t1)       # store the value into the array cell

#-----------------------------------printing Z[12] = Z[k] + z[k+j] on the console

    .data   
    .globl  message4 
    message4:  .asciiz "\nZ[12] = "  #string to print

    .text   li  $v0, 4            # print_str (system call 4)   
     la  $a0, message             # takes the address of string as an argument    
     syscall

     li  $v0, 1            # print_int (system call 1)  
     add  $a0, $0, $t1     # put value to print in $a0   
     syscall

Any suggestions would be greatly appreciated! :)

0 Answers0