News:

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

Request for Comment

Started by Randall Hyde, February 07, 2008, 11:38:26 PM

Previous topic - Next topic

Randall Hyde

Hi All,

I am currently dealing with the string module in the HLA standard library (writing documentation, cleaning up the code, etc.). I am modifying the string comparison functions (e.g., str.eq) so that they set/clear the carry flag on a true/false result (the original plan was to put this into the zero flag, but I've found the use of the z-flag totally confusing and it's more difficult to work with the z-flag than the carry flag).

One thing I am considering is dropping the return value in EAX and *strictly* returning the result in the carry flag. I'm thinking about doing this because of the *large* number of times the following code has tripped me up:

str.a_cpy( someStr );
if( str.ne( someStr, "asdfasdf" )) then

...

endif;
str.free( eax ); // Whoops!

The problem, of course, is that str.ne (and all string comparisons) wipe out the value in EAX, meaning the pointer to the string allocated on the heap is lost. I tend to encounter this pattern *far* more often than I need an actual return value from str.ne (or whatever) in EAX.

My guess is that better than 90% of the code out there never uses the value in EAX other than in some boolean test to determine if the condition is true. That being the case, I'm going to change the string comparisons so they preserve EAX.

If anyone has tons of code that will break if I do this, now is the time to speak up.
hLater,
Randy Hyde