Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MASM 32... Kip Irvine Can anyone help me write a function to call exchange PROC where it will swap the values if [esi] => [edi].

MASM 32... Kip Irvine

Can anyone help me write a function to call exchange PROC where it will swap the values if [esi] => [edi]. I am having trouble pushing the values and getting them to compare in the exchange PROC.

Here is the code. It is a bubblesort.

sortList PROC

push ebp ; Set up stack

mov ebp, esp ; Set up EBP to ESP pointer

mov ecx, [ebp + 8] ; Loop counter

dec ecx ; We will loop until n-1

outerloop:

push ecx ; Save the outer loop count

mov esi, [ebp + 12] ; Point to the first value in the array

innerloop:

mov eax, [esi] ; Get the element at index inside array

cmp [esi+4], eax ; Compare a pair of values

jb notgreater ; If [esi] => [edi], exchange

call exchange ; Else call Exchange

>> xchg eax, [esi+4] << ; How can I exchange these two values in the EXCHANGE PROC? and return to the next line?

mov [esi], eax

notgreater:

add esi, 4 ; Move both pointers forward

loop innerloop ; Inner loop

pop ecx ; Get outer loop count

loop outerloop ; Else repeat outer loop

bubblecomplete:

pop ebp

ret 8 ; Clear stack

sortList ENDP

exchange PROC

exchange ENDP

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

8. Providing support during instruction.

Answered: 1 week ago

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago