Reputation: 148
I'm trying to load an .asciiz parameter into a register, and I get an error,
code:
.data
stp:
.asciiz "stop"
.text
.globl main
main:
la $t1, stp
lw $t1, 0($t1)
I get an exception: Unaligned address in inst/data fetch,
is there a way to load an .ascii to a register as a word?
I want to compare an input variable to the text saved in stp,
What am I doing wrong?
Upvotes: 3
Views: 3536
Reputation: 58762
You probably want lb
or lbu
instruction for sign- or zero-extended byte sized loads, respectively.
If you want to load all 4 characters as a word, then make sure the string is aligned by adding the appropriate assembler directive (such as .align 2
) Alternatively, use the ulw
pseudo instruction that you assembler will turn into the proper sequence.
Upvotes: 4