I'm writing a program in MARS that encrypts/decrypts a string with a simple addition/subtraction method to each character according to a 4 digit key such as '2848.' I'm now trying to navigate through each character in a string and just increase the decimal count by 1 just to test it in a smaller scope but I don't understand how to save the byte back into the string. Here's what i have so far:
.data
title: .asciiz "program start\nenter string: "
endl: .asciiz "\n"
msg: .asciiz "You wrote: "
.align 2
str: .space 20
count: .space 40
.text
.globl main
main:
la $a0, title
li $v0, 4
syscall
# get input
li $v0, 8
la $a0, str
li $a1, 20
syscall
# print "you wrote: "
la $a0, msg
li $v0, 4
syscall
la $t0, str
la $t7, count
loop:
lb $t1($t0)
beqz $t1, done # if null, go to 'done'
addi $t2, $t1, 1 # increment character by 1
sw $t2, $t7($t1) # save into the char
addi $t7, $t7, 4 # increment counter
addi $t0, $t0, 1 # increment character in string
j loop
done:
# print buffer
la $a0, str
li $v0, 4
syscall