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

In Assembly using Irvine32: Write a procedure that performs simple encryption by

ID: 3894813 • Letter: I

Question

In Assembly using Irvine32:

Write a procedure that performs simple encryption by rotating each plaintext byte a varying number of positions in different directions. For example, in the following array that represents the encryption key, a negative value indicates a rotation to the left and a positive value indicates a rotation to the right. The integer in each position indicates the magnitude of the rotation:
key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6

Your procedure should loop through a plaintext message and align the key to the ?rst 10 bytes of the message. Rotate each plaintext byte by the amount indicated by its matching key array value. Then, align the key to the next 10 bytes of the message and repeat the process. Write a program that tests your encryption procedure by calling it twice, with different data sets.

Explanation / Answer

PROGRAM:

Include Irvine32.inc

SECTION.data

msg BYTE "Hello", 0

key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6

SECTION.code

main proc

mov ecx, LENGTHOF key   //Loop Counter

mov edx, OFFSET msg     //EDX Holds msg and will Display it

mov esi, OFFSET key     //Point to first array element

mov ebx, 0              //CMP number

top:

cmp [esi], ebx //if esi < ebx

jl ShiftLeft    //jump to shift left

cmp [esi], ebx //if esi > ebx

jg ShiftRight   //jump to shift right

cmp [esi], ebx

je NoShift

ShiftLeft: