MIPS – Fetch address not aligned on word boundary

I’m pretty new to assembly programming and programming in general and I’m doing my best to learn. I’ve been having trouble storing inputs to variables, can you help me please?

The problem seems to occur when I load the addresses of n1 and n2, or something like that. I have tried looking at similar problems and cannot translate them well. If anyone has any online references for learning, as well, that would be greatly appreciated.

Here is my code:

.data
prompt_n1: .asciiz "Enter first integer n1: "
prompt_n2: .asciiz "Enter second integer n2: "

debug_print: .asciiz "Your numbers are: "

n1: .word 0
n2: .word 0

.text

main:
#Prompt the user for n1.
li $v0, 4
la $a0, prompt_n1
syscall

#Store console: n1
li $v0, 5
syscall

#Attempts to load value of v0 into n1 - Problem Here
la $t0, n1
lw $t1, 0($v0)
sw $t0, 0($t1)

#Prompt the user for n2.
li $v0, 4
la $a0, prompt_n2
syscall

#Store console: n2
li $v0, 5
syscall

#Attempts to load value of v0 into n1 - Problem Here
la $t0, n2
lw $t4, 0($v0)
sw $t0, 0($t4)

j print_statement

print_statement:
li $v0, 4
la $a0, debug_print
syscall

li $v0, 1
lw $a0, n1
syscall

li $v0, 1
lw $a0, n2
syscall

Thank you for your time and help.

Leave a Comment