The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: Farabi on July 13, 2009, 10:38:55 AM

Title: StrToFloat
Post by: Farabi on July 13, 2009, 10:38:55 AM
Is StrToFloat destroy edi?
Im not sure but everytime Im not save the edi register before use StrToFloat and then used edi my app crash, is edi destroyed?
Title: Re: StrToFloat
Post by: ramguru on July 13, 2009, 10:56:17 AM
1) 'LAZY' way to check:
LOCAL buf[16]:BYTE

invoke dwtoa, edi, ADDR buf
invoke MessageBox, 0, ADDR buf, 0, 0

invoke StrToFloat... ; invoke any_proc

invoke dwtoa, edi, ADDR buf
invoke MessageBox, 0, ADDR buf, 0, 0

2) 'CLEVER' way to check:
check source-code of \masm32\masm32lib\atofp.asm

3) 'SMARTEST' way to check
open \masm32\help\masmlib.chm, type StrToFloat ... see if prototype uses 'USES edi'
if it does then it saves edi
Title: Re: StrToFloat
Post by: ToutEnMasm on July 13, 2009, 11:44:50 AM

PRESERVATION of esi edi ebx is a rule for each proc
Title: Re: StrToFloat
Post by: dedndave on July 13, 2009, 11:57:47 AM
it uses EBX, ESI, and EDI - no PUSH's or other preservation that i can see
EBP should also be preserved - StrToFloat does not use that one
Title: Re: StrToFloat
Post by: ToutEnMasm on July 13, 2009, 12:14:55 PM

You are right,
the \masm32\m32lib\atofp.asm don't preserve anything and modifies the registers.
Not usual coming from a proc of the masm32 library that as been verify.

Title: Re: StrToFloat
Post by: Farabi on July 13, 2009, 12:55:11 PM
Quote from: ToutEnMasm on July 13, 2009, 12:14:55 PM

You are right,
the \masm32\m32lib\atofp.asm don't preserve anything and modifies the registers.
Not usual coming from a proc of the masm32 library that as been verify.


Yeah, not usual. Unfortunately I dont know where is StrToFloat located so I dont checked it out. I thought every MASM32 lib function is preserve all the registers.
Title: Re: StrToFloat
Post by: dedndave on July 13, 2009, 03:47:15 PM
it is in this file - not hard to fix it - but let Hutch know so he can update it on the next release, as well
that is a good find, Farabi   :U
\masm32\masm32lib\atofp.asm