我正在编写一个汇编中的小程序(MIPS),其中我必须读取11个浮点数并将它们存储在一个数组中:
.include "../../ac1_macros.h"
.eqv size, 11
.data
array: .float 0:size
str1: .asciiz "Insert 11 numbers: "
.text
.globl main
main: la $t0, array
print_str(str1)
li $t1, 1
fill_array:
sll $t0, $t0, 2
read_float()
s.s $f0, ($t0)
addi $t1, $t1, 1
bne $t1, 11, fill_array
jr $ra插入第一个数字时,我会得到以下异常。
运行时异常在0x0040004c:地址超出范围0x40040000
我做错了什么?这与我没有使用的指令align有关吗?提前谢谢。
发布于 2015-12-01 15:54:25
您移动$t0,而不返回它,因此它将变得越来越大。
没有测试,试试这个。
.include "../../ac1_macros.h"
.eqv size, 11
.data
array: .float 0:size
str1: .asciiz "Insert 11 numbers: "
.text
.globl main
main: la $t0, array
print_str(str1)
li $t1, 1
fill_array:
read_float()
s.s $f0, ($t0)
addi $t1, $t1, 1
addi $t0, $t0, 4 # proceed to the next element
bne $t1, 11, fill_array
jr $rahttps://stackoverflow.com/questions/34024406
复制相似问题