Question: ADD R 1 , R 1 , # 1 ; Sets R 1 to x 3 1 0 1 ( memory location to store key
ADD R R # ; Sets R to xmemory location to store
key
STR R R # ; Stores Encryption Key character at
memory location indicated by R
LEA R PROMPT ; Load third prompt Encryption Message into R
PUTS ; Output Prompt same as TRAP Write null
terminated string to console.
; The key is mapped to the line feed character on the LCASCII xA
ADD R R # ; Sets R to x for message storage
ADD R R #
ADD R R # ; Sets R to for counter. Encrypt message
limited to characters
ADD R R # ; Sets R to for comparison with "ENTER"
key LCASCII xA
InputLoop GETC ; Begin of InputLoop, gets characterinput
OUT ; Write one character to console same as TRAP
;Add code here ; Compares input character in R with R
BRz ExitInput ; Exits loop if "ENTER" key is detected
;Add code here ; Stores input character in R into memory
location in R
;Add code here ; Increments R memory location for next
character in input encrypt message
;Add code here ; Increments counter
BRn InputLoop ; Loops if counter is still negative
ExitInput ;
AND R R # ; Clears R for later use
AND R R # ; Clears R for later use
;These lines prepare for encryptiondecryption
LD R STORE ; Stores x in R
;Add code here ; Load encryption key ASCII from the memory
address which the R point to into R
ADD R R # ; These three lines convert R from ASCII to
Decimal. are ASCII code
ADD R R # ;
ADD R R # ;
;Add code here ; Makes R point to first char in input messge
for encryption from the memory location in R
LD R NEW ; Loads memory location NEW to store
encrypted message
LDI R STORE ; Reloads R with x
LD R N ; Loads R with to check for D input
;Add code here ; Adds R and R to check if D was first input
;BRz DECRYPT ; Goes to DECRYPT if D was first input, else it runs
encyption in next instruction
;
;Encryption algorithm:
;The encryption algorithm is as follows. Each ASCII code in the message will be
transformed as follows:
;
; The low order bit of the code will be toggled. That is if it is a
; it will be replaced by a if it is a it will be replaced by a
;
; The key will be added to the result of step above.
; For example, if the input plain text is A and the encryption
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
