Arrays MIPS-访问和更改字符数组

Arrays MIPS-访问和更改字符数组,arrays,char,mips,tic-tac-toe,Arrays,Char,Mips,Tic Tac Toe,我正在为MIPS的家庭作业做一个井字游戏 所以我有一个字符数组设置如下: boardArray: .align 2 .byte '_', '_', '_', '_', '_', '_', '_', '_', '_', '-' 我正在尝试这样访问: sll $t1,$t1,2 # multiply the index by 4 add $t2,$t4,$t1 # add the values of the address and the offset

我正在为MIPS的家庭作业做一个井字游戏

所以我有一个字符数组设置如下:

boardArray:
    .align 2
    .byte '_', '_', '_', '_', '_', '_', '_', '_', '_', '-'
我正在尝试这样访问:

sll $t1,$t1,2           # multiply the index by 4
add $t2,$t4,$t1      # add the values of the address and the offset; store in $t2
lw $t3,($t2)            # store the contents of $t2 in $t3
最后一行替换为:

sw $s1,($t2)            # store the value of $s1 in $t2

更改数组中的值。然而,它似乎不起作用。我让播放机输入一行和一列值,然后尝试检查该位置(访问数组)以查看它是否打开(如果它打开,则是一个“\”)。如果它是打开的,则根据当前播放机的不同,它将被“X”或“O”替换。我上传了整个程序。请原谅这有多可怕,assembly和我不是朋友。

lw
/
sw
中的
w
表示
word
,在MIPS上是4字节的单位。
boardArray
中的元素是字节,而不是单词

你有两种选择:要么让你的数组成为一个单词数组;或者使用
lbu
/
sb
而不是
lw
/
sw
并跳过索引缩放