Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ONLY NEED AN ANSWER TO PART 2 Part 1: Write an ARM assembly routine which accept

ID: 3865401 • Letter: O

Question

ONLY NEED AN ANSWER TO PART 2

Part 1: Write an ARM assembly routine which accepts a series of 3-digit integers from message_in.txt (provided), bitwise XORs the first with 0x2, and then bitwise XOR each succeeding value with the next PN code in your sequence. Write the result to a file, message_scram.txt. Note that we have radically altered the message, which might be a PIN code or account information. PART 2: Now unscramble and recover the original message. Read message_scram.txt into your processor from step 7 and write out message_out.txt, which should match message_in.txt. Repeat with an initial key of 0xd instead of 0x2, and comment on the readability of the reconstructed data sequence.   

Explanation / Answer

Problem 1 (4 points)

The LC-3 does not have a logical XOR instruction, but we can write a sequence of instructions to implement one. The following instructions perform the XOR function on the values stored in R1 and R2 and store the result in R3. Fill in the missing two instructions and write comments on what the instructions do.

*Hint: DeMorgan's Law

Problem 2 (4 points)

Answer the following questions for the following snippet of code. Assume R0=0x1000, R1=0x0100, R2=0x0010, R3=0x0001 before the instruction at 0x3000 is executed.

Problem 3 (10 points)

Write a program in LC-3 binary code that searches for odd numbers in 200 memory locations starting from 0x4000. Set R0 to the number of found odd numbers. Your solution should use a looping construct. Comment each line of code and submit the binary code as a textfile to the dropbox. Print out a screenshot of your code with the PC at the HALT instruction.

Problem 4 (12 points)

The LC-3 has no left shift instruction. The algorithm should take in a 16-bit value at memory location M1 that contains the number that will have its bits shifted and a value at M2 that contains the number of bits to shift and store the 16-bit result in M3. For instance, suppose M1 = 0x0010 and M2 = 0x0004. After execution of the program, M3 = 0x0100. Note that the lowest bits will be filled with zeros.

Show the process of designing the algorithm:

Load value at M1 into R1
Load value at M2 into R2
Add R1 to R1 (Doubling = left shift 1)
Decrement R2
If p flag, go back two steps
Else Store R1 into M3

Read carefully and understand it might be it will help you to solve your problme

0x987F NOT R4, R1 R4=NOT(A) 0x9ABF NOT R5, R2 R5=NOT(B) 0x5A45 AND R5, R1, R5 R5=A AND NOT(B) 0x5884 AND R4, R2, R4 R4=NOT(A) AND B 0x9B7F NOT R5, R5 R5=NOT(A AND NOT(B)) 0x993F NOT R4, R4 R4=NOT(NOT(A) AND B) 0x5905 AND R4, R4, R5 R4=NOT(A AND NOT(B)) AND NOT(NOT(A) AND B) 0x973F NOT R3, R4 R3=NOT(NOT(A AND NOT(B)) AND NOT(NOT(A) AND B)) = [A AND NOT(B)] OR [NOT(A) AND B]