Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago

Question

Define Decision making

Answered: 1 week ago

Question

What are the major social responsibilities of business managers ?

Answered: 1 week ago

Question

What are the skills of management ?

Answered: 1 week ago

Question

Is how things are said consistent with what is said?

Answered: 1 week ago

Question

Has the priority order been provided by someone else?

Answered: 1 week ago