Fetch address not aligned on word boundary ,MIPS32

-2

Ok so i have this simple mips32 program:

.text
.globl main

main:

lw $s3,10 

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

li $v0,10
syscall #program termination

All i want to do is to load to register $s3 number 10 and then print it.Mars assembles this without errors, but when i hit run i get the following error:

Runtime exception at 0x00400000: fetch address not aligned on word boundary 0x0000000a

I understand there is something wrong with the

lw $s3,10 

command but i dont really care how to fix it.What i dont understand is the error: fetch address not aligned on word boundary.What does this mean? And why does it happen?

assembly
mips32

1 Answer

1

lw means load word from memory at the specified address. Because 1 word on MIPS32 is 4 bytes, the address must be a multiple of 4.

So, these commands will give you the same error:

lw $s3,9
lw $s3,11

These will not:

lw $s3,8
lw $s3,12
answered on Stack Overflow Dec 26, 2016 by Rei

User contributions licensed under CC BY-SA 3.0