Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly 提取地址未在字边界上对齐,MIPS32_Assembly_Mips32 - Fatal编程技术网

Assembly 提取地址未在字边界上对齐,MIPS32

Assembly 提取地址未在字边界上对齐,MIPS32,assembly,mips32,Assembly,Mips32,我有一个简单的mips32程序: .text .globl main main: lw $s3,10 move $a0,$s3 li $v0,1 syscall li $v0,10 syscall #program termination 我所要做的就是加载并注册$s3编号10,然后打印它。Mars会毫无错误地组装它,但当我点击run时,我得到以下错误: Runtime exception at 0x00400000: fetch address not aligned on wor

我有一个简单的mips32程序:

.text
.globl main

main:

lw $s3,10 

move $a0,$s3
li $v0,1
syscall

li $v0,10
syscall #program termination
我所要做的就是加载并注册$s3编号10,然后打印它。Mars会毫无错误地组装它,但当我点击run时,我得到以下错误:

Runtime exception at 0x00400000: fetch address not aligned on word boundary 0x0000000a
我知道这辆车出了点问题

lw $s3,10 
命令,但我并不真正关心如何修复它。我不理解的是错误:
获取地址未在字边界上对齐。这是什么意思?为什么会发生这种情况呢?

lw
表示从指定地址的内存中加载单词。因为MIPS32上的1个字是4字节,所以地址必须是4的倍数

因此,这些命令将给出相同的错误:

lw $s3,9
lw $s3,11
这些措施不会:

lw $s3,8
lw $s3,12

您只能读取字对齐的内存地址。在MIPS32上,字是4个字节。因此,内存地址必须是4字节对齐的。