I'm trying to write in assembly language a function sort. It will sort the two dimensional array such that the rows will now contain data in alphabetical order. I have tried many things but it is honestly beyond my current knowledge. here's what I tried so far...
.386
public _Sort
.model flat
.code
_Sort proc
push ebp
mov ebp, esp
push esi
push edi
mov edi, [esp + 4] ; address of destination array
mov esi, [esp + 8] ; address of source array
mov ecx, [esp + 16] ; # of elements to mov
cld
rep movsd
L1:
mov eax, [esi]
cmp [esi + 8], eax
jg L2
xchg eax, [esi + 8]
mov [esi], eax
L2:
pop edi
pop esi
pop ebp
ret
_Sort endp
end
Here's the C++ code...
#include <iostream>
using namespace std;
extern "C" int Sort (char [] [20], int, int);
void main ()
{
char Strings [10] [20]
= { "One",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten" };
int i;
cout << "Unsorted Strings are" << endl;
for (i = 0; i < 10; i++)
cout << '\t' << Strings [i] << endl;
Sort (Strings, 10, 20);
cout << "Sorted Strings are" << endl;
for (i = 0; i < 10; i++)
cout << '\t' << Strings [i] << endl;
}
I do realize my assembly does not make sense, sorry about that.