Does anyone have a simple console Masm32 QuickSort example they might share.

I just wondering, I seem to be having a hard time with it
It's the morning here in the USA, I guess



I just want to see it sort, I'm trying to make a Quick Sort version
of my BubbleSort I posted in Algorithms a few days ago


Thanks Andy




:stupid:
Posted on 2001-12-21 09:42:11 by andy981
Here is the part I've tried using it in


Main proc
LOCAL Buffer[128]:BYTE
invoke ClearScreen
invoke StdOut,ADDR content
invoke StdOut,ADDR mytop
invoke StdOut,ADDR mytitle
invoke StdOut,ADDR centertop
invoke StdOut,ADDR before

lea eax,nums
push len
push eax
call print
invoke StdOut,ADDR br

invoke StdOut,ADDR after

invoke nrQsortA, Addr nums,Addr count <-------right here
lea eax,nums
push len
push eax

call print
invoke StdOut,ADDR centerb
ret
Main endp


But it just crashes , I just don't know,
I thought it might be as simple as StdOut
I also added the extra lib it needed too

does anyone have a sample
of using Quicksort

Thanks Andy


:stupid:
Posted on 2001-12-21 21:20:06 by andy981
I don't think you pass the ADDR of count, but the value itself.
Posted on 2001-12-21 22:27:40 by bitRAKE
You were right,

where i had gone wrong was i used count instead of
11.
like
invoke nrQsortA, nums,count
but I should
have kept the addr for the array and, used a number for count,

like
invoke nrQsortA,Addr nums,11

I'm sure a register should work too, but I'll have too try it.

Do you know much about,
include \masm32\include\oleaut32.inc

includelib \masm32\lib\oleaut32.lib

invoke SysAllocStringByteLen,0,bLen

invoke SysFreeString,hMem

Do they have an Visual C equvalent or well Masm API, I can incorporate in a asm procedure in C,
I know why not all in ASM, but I Love the power of it all
there like big lightning bolts in your C program

Anyway, I did discover the light today of

.data
thisisasmtoo db "This is Great and real ASM too",0ah,0

.code
mov eax,7
mov edx, 9
.if eax == 7 && edx == 9
invoke StdOut, addr thisisrealasmtoo
.endif

I think that is cool, that will lead to a lot better asm programs
and, I read the assembler will optimise it too!


THanks Andy

Oh here's the program
Posted on 2001-12-21 23:04:12 by andy981
I don't have anything against other languages. Your doing very well and should learn many things while your at it. :) All those APIs should be usable from ASM or C.
Posted on 2001-12-21 23:13:43 by bitRAKE
Is there a site

where you can get the APIs?


Is there anywhere you can see the code of some of the
compliled MASM32 libarys

particularly

oleaut32.lib

Thanks Andy
Posted on 2001-12-21 23:31:22 by andy981
Don't quite underestand what you mean?
oleaut32.lib is the library file for oleaut32.dll - which should be in your windows directory.

Are you saying you'd like to see usage of the functions within that lib, or the source code to the DLL (ask M$)? Usually, I search this board, or the source code I've downloaded from here for the API function I'm having problems with. If that doesn't work I google. This board and the code posted here is the best resource I know of for ASM, but for C/C++ there are code examples everywhere.

Please, explain more if I missed the broad side of the barn. :tongue:
Posted on 2001-12-22 01:17:00 by bitRAKE
I wish I knew how to make the Make a C version
of
invoke SysAllocStringByteLen,0,bLen
and
invoke SysFreeString,hMem
to access
oleaut32.dll

like I did for
EXTERN strcmp:NEAR
mov ebx,dword ptr ;this is sptr->lastname
push ebx
mov edx,dword ptr ;this is sptr->lastname
push edx
call strcmp

Anyway I made a procedure with Hutch's QuickSort
from the M32LIB
But it Crashes when it hits,
this part that deals with the memory section


cmp ecx, Last ; If ecx < Last jump over
jg iNxt

; =========================
; mov eax, cntr
; mov , ecx ;<-- Area it Crashes at
; mov ebx, Last
; mov , ebx
; =========================
; add cntr, 2
iNxt:


I omitted the memory function, because I don't know how to add
those libraries

I guess that's what I need to learn to do, be able to add external libraries for my Visual C ASM procedures

And learn more about what function I have internally available

But were getting there

Andy


:)
Posted on 2001-12-22 22:17:18 by andy981
You add the LIB in the project settings.
Posted on 2001-12-22 22:31:19 by bitRAKE
I wonder where you put it, and what else you must add to it
like

/c /Cx /coff $(InputPath)
Posted on 2001-12-22 22:44:40 by andy981
Project Setting -> Link?? -> Libraries...

I've been using VS.NET beta 2, and have totally forgot VS6. :)
What are you using? The LIB doesn't need options on it, just
add it to the link process. It is more involved to access the
functions from C/C++ though -- the names of the functions
might need to start with an underscore? Others around here
have more experience at this than I. Or, just play with -- it's
hard to break anything too bad. :grin:
Posted on 2001-12-23 02:01:02 by bitRAKE