首页 > 解决方案 > 程序一直显示“存储中未对齐的地址:0x100100d2”错误

问题描述

我必须编写一个程序来接受来自用户的特定数量的浮点数并将它们存储到一个数组中。但是,每当我尝试存储浮点数时,QtSpim(MIPS Simulator) 总是说“存储中的未对齐地址:0x100100d2”。我尝试将 $f0 存储到 0($s3) 的方式有什么问题吗?

                        .data  
arrayLen:         .asciiz "Specify how many numbers should be stored in the array(at most 12): " 
enterNum:         .asciiz "Enter a number: " 
rawArray:         .asciiz "The array contains the following: " 
currArray:        .asciiz "The array currently contains the following: " 
resArray:         .asciiz "The result array contains the following: " 
blankLine:        .asciiz "\n"
floatArray:       .space 1000
                        .text
                        .globl    main    

main:
    la $a0, arrayLen    #load 'specify how many numbers' message 
    li $v0, 4           #print message
    syscall
    li $v0, 5           #read int (how many numbers) into v0
    syscall
    move $s0, $v0       #s0 holds the length of the array
    
    li $s1, 0           #s1 holds the index of the array
    la $s2, floatArray  #s2 holds the array
    
    Loop:
        slt $t1, $s1, $s0       #check if index(s1) is less than arrayLength(s0)
        beq $t1, $zero, Exit    #if not less than arrayLength exit program
        
        sll $t2, $s1, 2         #multiply index by 4 to get the Offset
        add $s3, $s2, $t2       #add offset to s2 to get floatArray[i](t3)
        
        
        
        la $a0, enterNum    #load 'enter a number' message 
        li $v0, 4           #print message
        syscall
        li $v0, 6           #read float (enter number) into f0
        syscall

        s.s $f0, 0($s3)   #store float into the array
        
        
        addi $s1, $s1, 1   #increment index
        
        j Loop            #jump back to start of loop
    
    Exit:

标签: mipsqtspim

解决方案


推荐阅读