A program I wrote 1.5 years ago suddenly stopped working on a new machine with WinXP. The problem turned out to be with the A2DW routine I used for this program. The problem was with register preservation:

Original code:

xor ecx, ecx
mov edi, String
invoke lstrlen, String

The lstrlen routine modifies the ecx register in XP but not on the 95, 98, and ME machine my program works on. A slight modification makes it work:

mov edi, String
invoke lstrlen, String
xor ecx, ecx

HTH

farrier
Posted on 2002-11-14 00:42:34 by farrier
Thank you Farrier,

I have just used a2dw for the first time and it was returning very strange results indeed. I assumed I had a complete misunderstanding of a2dw and thought I had better read up on it.

5 minutes later, problem solved.
Posted on 2002-11-16 17:09:48 by GreenScreenAlternator
farrier,

Thanks for finding this problem, the changes are as follows,

The "uses" preservations were wrong, they preserved ECX and EDX but not EBX. Your mod with XOR ECX, ECX is correct as well, the lstrlen API does not have to preserve the ECX register so it can be changed by the API.



a2dw proc uses ebx edi esi String:DWORD

;----------------------------------------
; Convert decimal string into dword value
; return value in eax
;----------------------------------------

mov edi, String
invoke lstrlen, String
xor ecx, ecx


Regards,

hutch@movsd.com
Posted on 2002-11-17 05:41:52 by hutch--