Assembly 必须使用getstatement()从内核文本段MIPS读取

Assembly 必须使用getstatement()从内核文本段MIPS读取,assembly,mips,Assembly,Mips,我编写了这段代码,使用函数数组将5个整数分配到堆栈上。所以我打印素数,但它给了我这个错误: 开发者:您必须使用getStatement()来读取内核文本段!0x80000000 你能帮我吗?多谢各位 .data pr:.asciiz"Give me the value of the array[" pr2:.asciiz"]: " .text .globl main main: addiu $sp, $sp, -20 #allocate space for 5 integers

我编写了这段代码,使用函数数组将5个整数分配到堆栈上。所以我打印素数,但它给了我这个错误: 开发者:您必须使用getStatement()来读取内核文本段!0x80000000 你能帮我吗?多谢各位

.data
pr:.asciiz"Give me the value of the array["
pr2:.asciiz"]: "

.text
.globl main

main: addiu $sp, $sp, -20 #allocate space for 5 integers
      move $a0, $sp
      jal Array
      move $a0, $sp
      jal Num
      li $v0,10
      syscall

Array: move $t0, $a0
       li $t1, 0       #counter for the 5 numbers
Loop: beq $t1, 5, Ret  #if the numbers allocated are 5 return
      la $a0, pr       #print the message
      li $v0,4
      syscall
      move $a0, $t1
      li $v0,1      
      syscall
      la $a0, pr2
      li $v0,4
      syscall
      li $v0,5
      syscall
      sw $v0, 0($t0)   #store the number onto the stack
      addiu $t1, $t1, 1 
      addiu $t0, $t0, 4 #go to the next word onto the stack
      j Loop
 Ret: jr $ra

Num:  move $t4, $a0       
      li $t3, 0  #counter for the numbers
Loop: li $t2, 2 
      beq $t3, 5, Exit
      lw $t5, 0($t4) 
Loop2:div $t5, $t2  #divide the number n by 2 to (n-1) 
      mfhi $t3  
      beqz $t3, Skip  #if the remainder is 0 than go to the next number
      addiu $t2, $t2,1  # if the remainder is not 0 it may be prime so add 1 to the last divider
      blt $t2, $t5, Loop2  # if this divider is less than n so go to Loop2
      move $a0, $t5  # the number is prime so print it
      li $v0,1
      syscall
Skip: addiu $t4, $t4, 4   
      addiu $t3, $t3, 1
      j Loop
Exit: jr $ra
出现错误的行如下所示:

 lw $t5, 0($t4)

这意味着您的
$t4
超出了范围,可能是因为您循环次数太多。使用调试器单步执行代码并查看为什么会发生这种情况。我没有看到我使用了2倍的$t3用于两种不同的事情!非常感谢。