你必须使用getstatement()来读取内核文本段MIPS

时间:2017-07-22 16:45:55

标签: assembly mips

我编写了这段代码,使用函数Array分配到堆栈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)

0 个答案:

没有答案