Arrays MIPS在阵列中保存数据
我在运行程序时遇到一个错误:存储地址未在字边界上对齐,我该怎么办? 代码如下:Arrays MIPS在阵列中保存数据,arrays,assembly,mips,memory-alignment,memory-address,Arrays,Assembly,Mips,Memory Alignment,Memory Address,我在运行程序时遇到一个错误:存储地址未在字边界上对齐,我该怎么办? 代码如下: .data welcome: .asciiz "Welcome to Memorization Game. \n\nYour need to enter the numbers printed in the exact sequence. Press S to start.\n" start: .asciiz "\nHere we go....\n" enter: .asciiz "\n P
.data
welcome: .asciiz "Welcome to Memorization Game. \n\nYour need to enter the numbers printed in the exact sequence. Press S to start.\n"
start: .asciiz "\nHere we go....\n"
enter: .asciiz "\n Please enter the number:\n"
array: .space 400
.text
main: la $t0, array # load address of array
la $a0, welcome
li $v0, 4 #
syscall # print welcome message
li $v0, 12 #
syscall # scan to continue
bne $v0, 115, Exit # if $v0 != "s", jump to Exit
la $a0, start #
li $v0, 4 #
syscall # Print start message
li $s0, 0 # N0. of random generated numbers = 0
add $t3, $t0, $0 # load address of array into $t3
Random: slti $t2, $s0, 100 #
beqz $t2, Exit #
addi $a0, $zero, 10 #
addi $a1, $zero, 99 #
li $v0, 42 #
syscall # generate a random number
sw $v0, ($t3) # put number generated into array[n]
addi $t3, $t3, 4 # next address
addi $s0, $s0, 1 # counter++
j Random
Exit: li $v0, 10 #
syscall # terminate
请尝试在数组之前插入以下内容之一:.space 400:
.p2align 2
另一个可能的选择是将
数组:.space 400
移动到数据部分的开头。谢谢,这解决了问题,但我认为不会存储随机生成的数字。有什么建议吗?是的,使用调试器。此外,既然这个问题已经解决,剩下的问题就应该单独提出。但是在发布新问题之前要进行调试。
.align 2
.align 4