1

所以我遇到了我的 PCSpim 程序的问题,在查看后我仍然找不到正确的解决方案,我认为它可能是“对齐”指令,要么我错过了一个,要么我错过了它。

这里是程序的开始,初始化数组

  .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 

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

我想它就在这附近搞砸了

#-------------------------------------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

任何建议将不胜感激!:)

4

0 回答 0