Question
Implement, in MIPS assembly language, an encryption/decryption program that meets the following requirements: Input Your program should prompt the user for two separate inputs from
Implement, in MIPS assembly language, an encryption/decryption program that meets the following requirements:
Input
Your program should prompt the user for two separate inputs from the keyboard, as follows
The prompt: ENTER THE ENCRYPTION KEY (A NUMBER BETWEEN 1 and 15):
The user will input a number. We will assume the user follows direction, and actually enters an integer value. However, if the userand enters a value greater than 15, we will use a bitmask of 0xF to force to the number to be less than 16. Store this somewhere safe, as it will be our encryption/decryption key.
The prompt: INPUT A MESSAGE OF NO MORE THAN 80 CHARACTERS. WHEN DONE, PRESS
The user will input a character string from the keyboard, terminating the message with the
Your program will store the message in an array you have allocated that is big enough to hold 80 characters.
One constraint: Once again, we assume the user follows direction and that the length of the message is indeed less than or equal to 80 characters.
this is what i have so far.
.data begin: .asciiz " ------- Encryption Program ------- " Number: .asciiz "Enter an Encryption key between 1 and 15: " TooBig: .asciiz "Your entry was invalid number chosen for you. " SaveSpace: .space 80 # makes space for 80 chars. AskChar: .asciiz "Enter string with max (80 chars): " Magic: .asciiz " ---------- Magic ---------- " Encpt: .asciiz " Encrypted string: " End: " Thank you for encrypting goodbye. " .text
MAIN:
#prints begin message li $v0,4 la $a0, begin syscall #Prints Number message li $v0,4 la $a0, Number syscall # allows user to a enter number li $v0,5 syscall # if user input is less than or equal to 15 direct user to AskForChar. ble $t0,15,AskForChar bgt $t0,15,Invalid jal AskForChar
Invalid: la $a0,TooBig li $v0,4 addi $t0,$zero,2 syscall jal AskForChar
AskForChar: # Prints AskChar message la $a0, AskChar li $v0, 4 syscall
# loads string into buffer li $v0, 8 # take in input la $a0, SaveSpace # load byte space into address lb $t1,0($a0) li $a1, 48 syscall la $a0, Magic li $v0, 4 syscall jal Encrypt Encrypt: while: lb $t5, SaveSpace beq $t5, 10, EncryptMssg xor $t5,$t5,$t4 sb $t5,SaveSpace addi $t2,$t2,1 j while
EncryptMssg: la $a0, Encpt li $v0, 4 Syscall la $a0, SaveSpace jal EXIT EXIT:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started