Hi everyone

I was wondering if anyone has ever sorted an array of structures
(Like Lastname alphabetically)
I'm doing it using Visual C as my assembler,
Masm32 code would be just as cool,
What is strcmp in Masm32?

Part of my problem I bet is my algorithm and me too!

but I notice in my output only my lastname, and only once at that get's switched

Here is my code

push ebp
mov ebp,esp
sub esp,8
lea edx,names1
put_ch 0ah
push edx
pop edx
mov edi,0

mov esi,0


add edx,esi
mov ebx,edx

add ebx,36
push ebx
push edx
call strcmp
pop edx
pop ebx

cmp eax,1
je swap

add esi,36
cmp esi,108
jl inner
inc edi
cmp edi,3
jl outer

mov esp,ebp
pop ebp

mov eax,dword ptr
mov ecx,dword ptr
mov dword ptr,ecx
mov dword ptr ,eax
jmp inner

My Output

before sort routine

Randy Feckwith 19

Candy Beckwith 29

Dandy Aeckwith 39

after sort routine

Randy Beckwith 19

Candy Aeckwith 29

Dandy 39

Posted on 2001-12-10 22:46:21 by andy981
You can use QuickSort to sort just about anything. All you need to write is an algo that returns: 0=Equal, 1=Greater, -1=Less. Then you just pass an array of pointers to the structures. I'd post my code, but I don't have a pretty example demostrating it's use. Damn I need to get my code together one of these days. ;) If your still interested I'll post it.

Edit: I don't mean to tease. Here is a messy test...it worked last time I looked. ;)

Edit: Edit: I've heard from others that my code is hard to follow unless you already understand QuickSort?
Posted on 2001-12-10 23:25:04 by bitRAKE
I don't care if there not pretty,
Prettier than what my compiler churns out,

We need a section called the "Hex Alley" or "The Big Hex Dump" here where
people can post what they feel is un pretty code,

The other night I combined a C cgi with an assembler procedure
A lot of just experamental junk,
But something I would like to seen ,If I had'nt made it my self.

Yes If you can post it or send an attachment I Love to see it


Posted on 2001-12-10 23:32:19 by andy981
You must have posted that
While I was writing my last post

Posted on 2001-12-10 23:36:43 by andy981
Given that, it's most likely easy for you to follow. :) Just write a COMPARE macro to replace the one that is there. The macro should exit with the flags set for a three-way branch (<,=,>).
Posted on 2001-12-10 23:37:33 by bitRAKE
Be honest it's a little hard for me to follow,
I'm not good with windows, so I just go cgi
Console Mode!
but I did see this

invoke QuickSort, ADDR ArrayData, 0, 15

I'm hoping to someone has some more primitive stuff,
But I do look at window material too.

I wonder how one can get Masm32 libraires to mix Visual C
so you write assembly procedures with Masm32 and havem
hook up to Visual C programs.

Evertime I try I get 101 errors, really!

But it must be the way I'm doing it

Oh well it's Late here

THanks Bit Rake

I really like seeing whatever code I can see,
Everyday it makes more sense


Posted on 2001-12-10 23:57:01 by andy981
QuickSort takes the pointer to the array and the first and last index that you want sorted - you could do a partial sort that way. The macro is all in the end of the file. I didn't write the popup windows code - that came from Hutch-- (thx!). I'll write the lastname COMPARE macro tomorrow. Sleep comes now. :)
Posted on 2001-12-11 00:10:00 by bitRAKE
Hi Bitrake

I finished my assembly exam today, It tired me out,
If you want you too still
I'd liked to see that lastname COMPARE macro,
(It'll be really mentally digestable on a console project, then I could view it as a cgi)
Off hand do you know , the Masm32 syntex to accomplish in
Visual C

push ebx
push edx
call strcmp

it must be something like
invoke strcmp, string1,string2

Then I'd write what I have in Masm32,
But I really want to learn is how to access these Masm32 libraries in Visual C, Or get a better handle on C calls in assembly
So I can write killer asm procedures, to add to C programs particularly in loops, that where you have problems,

Well whatever you decide
Thanks for all the help you've given me so far,

By the way do you like writing CGIs
I do!


Posted on 2001-12-12 20:14:01 by andy981
I just noticed Hutch-- has included a QuickSort in the new MASM32 package - it is quite good, and should be used. I haven't done any CGI, and I'm not interested in C unless it's for convertion to ASM. :)
Posted on 2001-12-12 22:56:36 by bitRAKE