News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Listview Sort Problem

Started by sonic, November 04, 2007, 03:56:24 AM

Previous topic - Next topic

sonic

I coded this after having some reading but it seems i have not understood it well. It crashes on clicking the column header. I m trying to sort floats and string. The string also seems to be sorted incorrectly?

zooba

You're not popping the floats off the stack after comparing them. This causes the string-to-float conversion to fail sometimes due to a stack overflow. It appears that this isn't causing the crash, but it will cause invalid sorting.

I couldn't see a reason for the strings to sort incorrectly, maybe someone else can see something?

Cheers,

Zooba :U

TNick

Shouldn't be finit there? Before any other floating point instructions? Sorry, no time to investigate...

Nick

MichaelW

To eliminate the crashes I substituted a CRT conversion function for StrToFloat. The problem was an access violation, but I didn’t attempt to determine exactly why or where it was occurring. To do the substitution I replaced everything from:

.486

To:

includelib masm32.lib

With:

include \masm32\include\masm32rt.inc

And replaced the two invoke StrToFloat statements with:

invoke crt_atof, ADDR TBUFFER1
fstp tdq
invoke crt_atof, ADDR TBUFFER2
fstp tdq1

In case it’s not apparent the CRT function returns a floating-point result on the FPU stack in the top data register, and the FSTP instruction copies the value to memory and then pops it from the FPU stack.

To get the code to sort the floating-point items correctly I substituted FCOMPP for FCOM, so the values pushed by FLD would be popped from the FPU stack, leaving it empty.

http://www.ray.masmcode.com/fpu.html

Also, although it does not appear to be causing a problem, an ASSUME dataregister:qualifiedtype should generally followed by a matching ASSUME dataregister:NOTHING.
eschew obfuscation

sonic

Thanks for suggestions. Now i got the floats working but strings still seems being sorted as case insensitive. So "learn..." should be sorted to top or bottom?

Here is updated source incase anyone else having problems like me.

[attachment deleted by admin]