I want to change a character in a string. For that I load in $t2 the char which is representing a hit. In this example the " " char at the 7th position should change to a "x".
After trying to updating my board with sh $t2, 0($t0)
I get the following errors:
Exception occurred at PC=0x0040003c
Unaligned adress in store: 0x1001000f
I guess I cannot update the board with the command I used, could you tell me how to do it right? Thank you in advance :)
# data segment
.data
hit: .asciiz "-"
ship: .asciiz "x"
miss: .asciiz "o"
water: .asciiz " "
board: .asciiz " x xx x x x x xxx x x x x x xxxx x x x xx x x xx"
.text
.globl main
main:
la $t0, board
# this is position of the array which should be a "x" char at the moment
addi $t0, $t0, 7
la $t1, hit
lhu $t2, 0($t1) # loading the hit char "-"
sh $t2, 0($t0) # ERROR : Here I tried to update the board
li $v0, 10
syscall