MIPS 汇编程序内存对齐问题(包括详细代码)



我试图将从用户那里读取的整数存储到数组中,但是当我尝试将其存储到数组中时,我的数据变得未对齐。

第一个代码块是我初始化所有数据的地方。(在 1. 下是我尝试存储整数的地方(

'#Constants
P_INT        = 1      #Syscall to print integer(value)
P_STRING     = 4      #Syscall to print a string(addr)
P_CHAR       = 11     #Syscall to print a char(char)
R_INT        = 5      #Syscall to read a integer(none)
EXIT         = 10     #Exit program(none)
'#Data
        .data
newline:
        .asciiz "n"        
'#Space for the bored.
 1. 
board_rep:
        .space     578
'#The current node to be read in
cur_node:
        .word      0 
'#Size of the bored
size:
        .space     4
'#Plus sign
plus:
        .asciiz "+"
'#dash
dash:
        .asciiz "-"

这里就是它变得未对齐的地方(2 之后的 sw。奇怪的是,我稍后(在第三个代码块中(正在做完全相同的事情,只是我将其存储在 size 数组中。

'#Grabs user input for the bored and stores it
get_board_rep: 

        li       $v0,R_INT     '#Read next node and store it    
        syscall 
2.
        sw       $v0,0($s1)
        addi     $s1,$s1,4    ' #Increment next node addr
        lw       $a0,0($s1)
        j        prnt_node

在存储字(在 3. 下(它以整数精细存储读取。

        la        $s0, size      ' #Store the variable addr's
        la        $s1, board_rep  
        li        $v0,R_INT      ' #Get user input(size of bored)
        syscall 
3.
        sw        $v0,0($s0)     ' #Store the size of bored

        jal       get_board_rep      

我想也许数组太大了,但我把它改成了 4(与其他工作的数组大小相同(。但它仍然不结盟。

提前谢谢.这是一个项目,我知道有些人不喜欢帮助这样的事情。但是我已经做了功课,在任何地方都找不到答案。

这对我来说看起来没有对齐,如果我错了,无论如何都要尝试明确对齐它。

最新更新