Hi Everyone

I wonder if anyone knows how to list the
contents of an array in Masm32, but I guess
you need to look at is my source
What I mean is that it only lists one element of the array and then crashes, I'm using
StdOut to show my contents.
I also changed the code so it won't lock up on my host's server, but I have arrows pointing
to where it crashes,
If I get past this hurdle, I want to do a bubblesort

CGI

http://busybeesolutions.com/cgi-bin/intro/cgidemo2.exe

Source

http://busybeesolutions.com/sourcefiles/cgidemo2.asm


Here is the problem code

lea edx,nums
topp:

inc num1
mov eax, ; <-------- This is what makes it crash
invoke wsprintf,ADDR sizeBuffer,ADDR printint,eax
invoke StdOut,ADDR br
invoke StdOut,ADDR sizeBuffer
add edx,4 ; <-----The Increment

invoke StdOut,ADDR lf

cmp num1,5
jl plopy




:stupid:
Posted on 2001-11-17 13:31:23 by andy981
topp:

inc num1
mov eax,num1 ; This way it prints 0 tru 4

invoke wsprintf,ADDR sizeBuffer,ADDR printint,eax
invoke StdOut,ADDR br
invoke StdOut,ADDR sizeBuffer
add edx,4 ; <-----The Increment

invoke StdOut,ADDR lf

cmp num1,5
jl topp


I at first thought it was
invoke wsprintf,ADDR sizeBuffer,ADDR printint,eax

but has to do with array contents
of
lea edx,nums
mov eax,
Posted on 2001-11-17 13:40:31 by andy981
First of all, EDX is not preserved by the API functions in the loop, so after these functions it can be anything... The only registers that are saved are ebx, esi and edi (and ebp, esp of course)..
An easier solution is this:


xor ebx, ebx

topp:

invoke wsprintf,ADDR sizeBuffer,ADDR printint, dword ptr [offset nums + 4 * ebx]
invoke StdOut,ADDR br
invoke StdOut,ADDR sizeBuffer
invoke StdOut,ADDR lf

inc ebx
cmp ebx, 5
jl topp


Thomas
Posted on 2001-11-17 13:58:37 by Thomas
Thank You Thomas

I got it working, that was big help!, Now I got digest it and make a
bubble sort.
And make a way to parse post info, and break characters into
numbers


CGI

http://busybeesolutions.com/cgi-bin/intro/cgidemo3.exe

Source

http://busybeesolutions.com/sourcefiles/cgidemo3.asm


:alright:
Posted on 2001-11-17 14:45:42 by andy981
There is a bubble sort in the algo section...
Posted on 2001-11-17 15:06:07 by bitRAKE

invoke wsprintf,ADDR sizeBuffer,ADDR printint,eax


I gotta ask: shouldn't you clean up the stack after that wsprintf call?
Posted on 2001-11-18 03:22:31 by sluggy
wsprintf is declared as C function in windows.inc, and then masm cleans up the stack for you.

Thomas
Posted on 2001-11-18 04:34:53 by Thomas