Question: In 32 bit x86 assembly language, Given the following code, encrypt each number of the array using the given encryption algorithm, then prompt the user

In 32 bit x86 assembly language, Given the following code, encrypt each number of the array using the given encryption algorithm, then prompt the user to enter an index from 1-10, then run the decryption procedure to decrypt that index, and output the original number to the screen.

.586

.model flat,stdcall

.stack 4096

ExitProcess proto,dwExitCode:dword

include Irvine32.inc

include BinarySearch.inc

KEY=99

.data

myArray DWORD 10 DUP(?)

enterNum BYTE "Enter a number: ",0

enterInd BYTE "Enter index 1-10: ",0

.code

main proc

; fills an array of ten locations with numbers entered by the user

mov ebx,0

mov ecx,LENGTHOF myArray

.WHILE(ebx < ecx)

mov edx,OFFSET enterNum

call WriteString

call ReadDec

mov myArray[ebx*4],eax

inc ebx

.ENDW

; sorts the array so that smaller numbers are pushed to the top (smaller index locations)

INVOKE BubbleSort, ADDR myArray, LENGTHOF myArray

call Crlf

; print the whole array to the screen

mov ebx,0

.WHILE(ebx < ecx)

mov eax,myArray[ebx*4]

call WriteDec

call Crlf

inc ebx

.ENDW

call Crlf

; encrypts each number of the array with the following encryption algorithm

; Encryption Scheme: Rotate right each character by 2 bits then perform XOR with the key.

; using the decimal number 99 as the key

; It prompts the user to enter any index less than 10.

mov edx,OFFSET enterInd

call WriteString

call ReadInt

mov ebx,eax

; run decryption procedure to decrypt the number at that location

; display the original number

invoke ExitProcess,0

main endp

BubbleSort PROC USES eax ecx esi,

pArray:PTR DWORD,

Count:DWORD

mov ecx,Count

dec ecx

L1: push ecx

mov esi,pArray

L2: mov eax,[esi]

cmp [esi+4],eax

jge L3

xchg eax,[esi+4]

mov [esi],eax

L3: add esi,4

loop L2

pop ecx

loop L1

L4: ret

end main

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