MIP で文字列を作成し、文字列の各文字を整数に変更しようとしています。現在、新しい文字列の作成に問題があり、何が間違っているのかわかりません。挿入するコード ブロックは、4 文字のメモリ割り当てを作成し、各位置に番号を割り当てて、文字列をメモリ位置に保存する必要があります。ただし、後で印刷すると常に空白になるため、文字列を保存していないようです。機能していないように見えるコードブロックのみを含めています。
どんなヒントでも大歓迎です!
.data
string: .space 16 #declare storage for string 4 char
string2: .asciiz "Success!"
string3: .asciiz "Failure!"
.text
main: # convert string to integer
la $t0, string # load base address of string to reg $t0
li $t1, 1 # $t1 = 1
sw $t1, ($t0) # first array element set to 1
li $t1, 2 # $t1 = 2
sw $t1, 4($t0) # second array element set to 2
li $t1, 3 # $t1 = 3
sw $t1, 8($t0) # third array element set to 3
li $t1, 0 # $t1 = 0
sw $t1, 12($t0) # third array element set to 0
# array stored at #t0
sw $t0, string
li $v0, 4 # syscall for print string
la $a0, string # load string to be printed
syscall # print digit string
これはすべて問題なくコンパイルされます。