/ / Iterácia a modifikácia reťazca v MIPS - reťazec, slučky, montáž, mips

Prepisovanie a modifikácia reťazca v MIPS - reťazec, slučky, montáž, mipsy

Snažím sa napísať metódu, aby sa vykonal posun caesaru na reťazci textu v jazyku MIPS. Môj spôsob šifrovania je nasledovný:

encryptMessage:
la $s0, message     #s0 will hold message that will be iterated through
lw $t1, key     #s1 will hold the key to shift by
li $t0, 0       #t0 will be iterator, starting at 0

encryptionLoop:
add $s1, $s0, $t0   #$s1 = message[i]
lb $s2, 0($s1)      #Loading char to shift into $s2
beq $s2, $zero, exit    #Breaking the loop if we"ve reached the end: http://stackoverflow.com/questions/12739463/how-to-iterate-a-string-in-mips-assembly
add $s2, $s2, $t1   #Shifting the character by the key amount
la $s1, ($s2)       #Changing the character in message to the shifted character
addi $t0, $t0, 1    #i++
j encryptionLoop    #Going back to the beginning of the loop

Avšak, pri výstupe metóda, kde som vytlačiťúdajne zašifrovaná správa, len vytlačí správu tak, ako bola pôvodne zadaná. Môj kód nie je "pamätám", že som zmenil postavy a nemôžem zistiť, ako si to zapamätať. Mám podozrenie, že tento riadok

la $s1, ($s2)       #Changing the character in message to the shifted character

má s tým niečo spoločné, ale neviem, ako to opraviť.

odpovede:

0 pre odpoveď č. 1

Prísť na to. Tá línia, o ktorej som predpokladal, mala byť

sb $s2 ($s1)