Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Exception MIPS异常4和5错误_Exception_Assembly_Mips - Fatal编程技术网

Exception MIPS异常4和5错误

Exception MIPS异常4和5错误,exception,assembly,mips,Exception,Assembly,Mips,我试图使用堆栈生成函数AVA,其中x1[I]=y1[I]+z1[I],但我得到以下错误: Exception 5 [Address error in store] occurred and ignored Exception 5 [Address error in store] occurred and ignored Exception 5 [Address error in store] occurred and ignored Exception 5 [Add

我试图使用堆栈生成函数AVA,其中x1[I]=y1[I]+z1[I],但我得到以下错误:

  Exception 5  [Address error in store]  occurred and ignored
  Exception 5  [Address error in store]  occurred and ignored
  Exception 5  [Address error in store]  occurred and ignored
  Exception 5  [Address error in store]  occurred and ignored
  Exception 5  [Address error in store]  occurred and ignored
  Exception 4  [Address error in inst/data fetch]  occurred and ignored
0
  Exception 4  [Address error in inst/data fetch]  occurred and ignored
0
  Exception 4  [Address error in inst/data fetch]  occurred and ignored
0
  Exception 4  [Address error in inst/data fetch]  occurred and ignored
0
  Exception 4  [Address error in inst/data fetch]  occurred and ignored
0 
这是我的密码:

    .data
newline: .asciiz  "\n"
x1: .space 20
y1: .word 1, 2, 3, 4, 5
z1: .word -5, -4, -3, -2, -1
x2: .space 40
y2: .word -1, 3, -5, 7, -9, 2, -4, 6, -8, 10
z2: .word 1,2,3,4,5,6,7,8,9,10
#######################################################

  .globl main
  .text

main:
#$a0-a3 for passing to functions
#$v0-v1 for storing return values from functions

  addiu $sp, $sp, -16    #allocate stack space
  la $t0, x1          #AVA(x1,y1,z1,5)
  sw $t0, 0($sp)
  la $t0, y1
  sw $t0, 4($sp)
  la $t0, z1
  sw $t0, 8($sp)
  li $t0, 5
  sw $t0, 12($sp)
  jal AVA 
  addiu  $sp, $sp, 16    #deallocate stack space
#############################  
  la $t0, x1      #t0 = x
  li $t2, 0          #iterator
  li $t3, 5      #array size
For:
  bge     $t2, $t3, endFor       # loop while element <= arraysize
  lw      $t1, 0($t0)             # get word from x array

   li      $v0, 1                  # 'print' command code
   move    $a0, $t1                # needs value in $a0
   syscall                         # print it


  # print newline
  li  $v0, 4
  la  $a0, newline
  syscall


   addi    $t0, $t0, 4             # move to next entry in array x
   addi    $t2, $t2, 1             # increment iterator number

  b For                  # go to Loop
endFor:
#############################

li $v0, 10  #exit
syscall

AVA:
  li $t0, 0          #iterator
  lw $t1, 0($sp)        #x[i]
  lw $t2, 4($sp)        #y[i]
  lw $t3, 8($sp)        #z[i]
  lw $t4, 12($sp)       #n

loop:
  bge $t0, $t4, return   # loop while iterator < n
  lw  $t5, 0($t2)
  lw  $t6, 0($t3)
  add $t5, $t5, $t6      #y[i] + z[i]
  sw $t5, 0($t1)        #x[i] = y[i] + z[i]

  addi $t0, $t0, 1      #increment iterator
  addi $t1, $t1, 4      #increment x
  addi $t2, $t2, 4      #increment y
  addi $t3, $t3, 4      #increment z
  b loop

return:
  sw $t1, 0($sp)
  jr $ra
#######################################################  
.data
换行符:.asciiz“\n”
x1:.空间20
y1:.单词1、2、3、4、5
z1:。字-5,-4,-3,-2,-1
x2:.空间40
y2:。单词-1,3,-5,7,-9,2,-4,6,-8,10
z2:.单词1,2,3,4,5,6,7,8,9,10
#######################################################
格洛博梅因酒店
.文本
主要内容:
#$a0-a3用于传递给函数
#$v0-v1用于存储函数的返回值
添加$sp,$sp,-16#分配堆栈空间
la$t0,x1#AVA(x1,y1,z1,5)
sw$t0,0($sp)
la$t0,y1
sw$t0,4($sp)
洛杉矶$t0,z1
sw$t0,8($sp)
李$t0,5
sw$t0,12($sp)
日航
添加$sp,$sp,16#释放堆栈空间
#############################  
la$t0,x1#t0=x
li$t2,0#迭代器
li$t3,5#阵列大小
用于:

bge$t2,$t3,endFor#loop while element数组前面缺少
.align
指令。
newline
常量有两个字节长,因此它使
x1
y1
z1
从未对齐的地址开始。尝试在定义
x1
之前添加
.align 2
(对齐到2^2字节的倍数)