Question: ;Project 2 - Encryption and Decryption message using encryption key and special logic. ;The line with Add code here need to supply the LC -

;Project 2- Encryption and Decryption message using encryption key and special
logic.
;The line with "Add code here" need to supply the LC-3 Instruction for asm program
run success.
;Algorithm
;
;The encryption algorithm is as follows. Each ASCII code in the message will be
transformed as follows:
;
; 1.The low order bit of the code will be toggled. That is, if it is a 1,
; it will be replaced by a 0, if it is a 0, it will be replaced by a 1.
;
; 2. The key will be added to the result of step 1 above.
; For example, if the input (plain text) is A and the encryption key is 6,
; the program should take the ASCII value of A,01000001, toggle bit [0:0],
; producing 01000000 and then add the encryption key, 6.
; The final output character would be 01000110, which is the ASCII value F.
;
;The decryption algorithm is the reverse. That is,
; 1.Subtract the encryption key from the ASCII code. 2. Toggle the low order bit
of the result of step 1.
; For example, if the input (cipher text) is F, and the encryption key is 6,
; we first subtract the encryption key (i.e., we add -6) from the ASCII value
of F,
; 01000110+11111010, yielding 01000000. We then toggle bit [0:0],
; producing 01000001, which is the ASCII value for A.
;
;The result of the encryption/decryption algorithm should be stored in locations
x3116 to x3129.
;
;Output
;
;Your program should output the encrypted or decrypted message to the screen.
;Note that the encryption/decryption algorithm stored the message to be output
starting in location x3116.
.ORIG x3000
AND R0, R0, #0 ;Clear R0
AND R1, R1, #0 ;Clear R1
AND R2, R2, #0 ;Clear R2
AND R3, R3, #0 ;Clear R3
AND R4, R4, #0 ;Clear R4
AND R5, R5, #0 ;Clear R5
AND R6, R6, #0 ;Clear R6
LD R1, STORE ; Sets R1 to x3100 for memory storage and access
LEA R0, PROMPT1 ; Load Prompt1"(E)ncryption or (D)ecryption
PUTS ; Output Prompt1 same as TRAP 22. Write null-
terminated string to console.
IN ; Get character input from keyboard same as
TRAP 20
STR R0, R1, #0 ; Stores/write character at memory location
indicated by R1
LEA R0, PROMPT2 ; Load Prompt2 Encryption Key "0-9"
PUTS ; Output Prompt2 same as TRAP 22
IN ; Get character input from keyboard same as
TRAP 20

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 Programming Questions!