Question: I have a code but I can't get it to reverse. I was wondering if someone can help me. I also need help making a

I have a code but I can't get it to reverse. I was wondering if someone can help me.

I also need help making a decrypt function. Thank you.

it is in assembly.

.data

zero: .ascii "ZE"

one: .ascii "ON"

two: .ascii "TW"

three: .ascii "TH"

four: .ascii "FO"

five: .ascii "FI"

six: .ascii "SI"

seven: .ascii "SE"

eight: .ascii "EI"

nine: .ascii "NI"

NumberArray: .asciiz "1234."

cipher: .asciiz "ZEONTWTHFOFISISEEINI."

encrypted: .space 17

decrypted: .space 17

.text

.globl main

main:

la $a0, NumberArray

la $a1, cipher

la $a2, encrypted

la $a3, decrypted

moveThroughNumbers:

jal encrypt

add $a0, $a0, 1

lb $s1, 0($a0)

beq $s1, 0x2E, exit

j moveThroughNumbers

lb $a0, 0($t2)

li $v0, 10

syscall

encrypt:

la $t0, ($a0) #pointer to num

la $t1, ($a1) #pointer to ciper

la $t2, ($a2) #pointer to encryption

li $t5, 0

lb $t3, 0($t0) #loading number from number array

add $t3, $t3, -48 # turn it into decimal number

mul $t3, $t3, 2 # use to index cipher array

add $t3, $t1, $t3 # get address to correct letters in cipher

lh $t4, 0($t3) #load 2 bytes (half word)

sh $t4, 0($t2) #store in encrypted

# checking to see if correct bytes were stored

la $a0, encrypted

li $v0, 4

syscall

la $a0, ($t0)

jr $ra

loop:

add $s0, $a0, $t5 #$s0 = num[i]

lb $s1, 0($s0) #Loading char to shift into $s1

beq $s1, 0x2E, exit #if reaches full stop it leaves loop

add $a0, $a0, $t1 #shitfting character by cipher

la $s0, 0($s1) #changes the character

addi $t5, $t5, 1 #i++

j loop

exit:

la $v0, 10

syscall

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!