MIPS:运行时异常:地址超出范围
MIPS: Runtime Exception: address out of range
我正在用汇编 (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
插入第一个数字时出现以下异常。
Runtime exception at 0x0040004c: address out of range 0x40040000
我做错了什么?是否与我未使用的指令 align
有关?提前致谢。
你移动$t0
而不return它,所以它会越来越大。
未测试,试试这个。
.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 $ra
我正在用汇编 (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
插入第一个数字时出现以下异常。
Runtime exception at 0x0040004c: address out of range 0x40040000
我做错了什么?是否与我未使用的指令 align
有关?提前致谢。
你移动$t0
而不return它,所以它会越来越大。
未测试,试试这个。
.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 $ra