kingkactuar 0 Newbie Poster

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:


    title: .asciiz "program start\nenter string: "
    endl: .asciiz "\n"
    msg: .asciiz "You wrote: "
    .align 2
    str: .space 20
    count: .space 40
.globl main
    la $a0, title
    li $v0, 4

    # get input
    li $v0, 8
    la $a0, str
    li $a1, 20

    # print "you wrote: "
    la $a0, msg
    li $v0, 4

    la $t0, str
    la $t7, count

    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

    # print buffer
    la $a0, str
    li $v0, 4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.