Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions

Question

years.

Answered: 1 week ago