Once again I have found myself stuck on another problem in assembly langauge because it owns me. I am trying to write a program that uses the Bubble sort algorithm but to make things challenging I am required to use Local Variable. And that must be based off of this C++ coding:
function BubbleSort(int & array, int count)
{
int x, n=count ,y; //<---Create locals for these
for(x=0; x<n; x++)
{
for(int y=0; y<x; y++)
{
if(array[y]>array[y+1])
{
int temp = array[y+1];
array[y+1] = array[y];
array[y] = temp;
}
}
}
Next I have to let this module print out the array as loaded with
random number (The "fill array" module does this). The array has 100
elements so I have to let PrintArray produce a 10x10 display of numbers.
This has proven difficult so unfortunately this is all I have
INCLUDE Irvine32.inc
.data
count = 100
array WORD count DUP(?)
.code
main PROC
push OFFSET array
push COUNT
call ArrayFill
exit
main ENDP
; Fills an array with 16-bit random integers.
ArrayFill PROC
push ebp
mov ebp,esp
pushad ; save registers
mov esi,[ebp+12] ; offset of array
mov ecx,[ebp+8] ; array size
cmp ecx,0 ; ECX == 0?
je L2 ; yes: skip over loop
L1:
mov eax,10000h ; get random 0 - FFFFh
call RandomRange ; from the link library
mov [esi],ax
add esi,TYPE WORD
loop L1
L2: popad ; restore registers
pop ebp
ret 8 ; clean up the stack
ArrayFill ENDP
END main
So if anyone has any comments sugguestions or peices of coding to help me get the ball rolling, that would be extremely helpful