Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to write an ascending bubble sort procedure and a procedure that counts and displays the number of times each number appears in an

I'm trying to write an ascending bubble sort procedure and a procedure that counts and displays the number of times each number appears in an array. This is my code so far:

INCLUDE Irvine32.inc

LO = 15 HI = 50 ARRAYSIZE = 200

.data intro_1 BYTE "Random Array Manipulator by Synzin Darkpaw",0 intro_2 BYTE "This program will generate a list of random numbers, display them, sort them, calculate",0 intro_3 BYTE "and display the median value, and calculate and display the instances of each number.",0 array DWORD ARRAYSIZE DUP(?) ; Holds the array to be manipulated count DWORD ? list_title BYTE "Unsorted List: ", 0 sort_title BYTE "Sorted List: ", 0 med_title BYTE "Median: ", 0 count_title BYTE "Count of each integer: ", 0 spaces BYTE " ", 0 ; spacing for display close_str BYTE "Thank you for participating. Goodbye!",0 .code

main PROC ; Prepare the random number seed call Randomize ; Display programmer & program name & instructions for user to enter number of primes to be displayed push OFFSET intro_3 push OFFSET intro_2 push OFFSET intro_1 call introduction ; Fill an array with random integers push OFFSET array call fillArray ; Display a passed array push OFFSET array push OFFSET list_title call displayList ; Sort a passed array (not working) push OFFSET array call sortList ; Display a passed array push OFFSET array push OFFSET sort_title call displayList ; Calculates and displays the median of a passed array push OFFSET array push OFFSET med_title call displayMedian ; Calculates the number of instances of each number in the array (not working) ; push OFFSET array ; push OFFSET count ; call countList ; Display a passed array ; push OFFSET count ; push OFFSET count_title ; call displayList ; Say goodbye push OFFSET close_str call farewell exit

main ENDP

introduction PROC push ebp mov ebp, esp call CrLf mov edx, [ebp+8] call WriteString call Crlf mov edx, [ebp+12] call WriteString call Crlf mov edx, [ebp+16] call WriteString call Crlf call Crlf pop ebp ret 8

introduction ENDP fillArray PROC push ebp mov ebp, esp mov esi, [ebp+8] mov ecx, ARRAYSIZE

fillArrayLoop: mov eax, HI sub eax, LO inc eax call RandomRange add eax, LO mov [esi], eax add esi, 4 loop fillArrayLoop pop ebp ret 8

fillArray ENDP sortList PROC push ebp mov ebp, esp mov ecx, ARRAYSIZE dec ecx

ret 8

sortList ENDP exchangeElements PROC push ebp mov ebp, esp

pop ebp ret

exchangeElements ENDP displayList PROC push ebp mov ebp, esp mov esi, [ebp+12] mov ecx, ARRAYSIZE mov ebx, 1

; display the title call CrLf mov edx, [ebp+8] call WriteString call CrLf

displayCurrent: cmp ebx, 20 jg newRow mov eax, [esi] call WriteDec mov edx, OFFSET spaces call WriteString add esi, 4 add ebx, 1 loop displayCurrent jmp done

newRow: call CrLf mov ebx, 1 jmp displayCurrent

done: call CrLf pop ebp ret 8

displayList ENDP countList PROC push ebp mov ebp, esp mov edi, [ebp+12] mov ecx, ARRAYSIZE

ret 8

countList ENDP

I've tried everything I can think of and get either a memory address error or no actual sorting. Please help!

I have to pass the variables on the stack.

I cannot use global variables other than LO, HI, ARRAYSIZE

The countList must generate a new list to be sent to the display procedure.

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

4. What decision would you make and why?

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago