News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

String to double conversion: CRT strtod

Started by jj2007, April 18, 2021, 10:15:05 PM

Previous topic - Next topic

jj2007

I've never paid attention to the second parameter, it's actually useful:

include \masm32\include\masm32rt.inc

.data?
MyR8 REAL8 ?

.code
start:
  mov ebx, chr$("123.456 789.0 111.1 222.2 333 444 555")
  .Repeat
push ebx
invoke crt_strtod, ebx, esp
fstp MyR8
pop ebx
printf("Result: %f\n", MyR8)
  .Until !len(ebx)
  exit

end start


Btw if you use this...
push ebx
mov edx, esp
invoke crt_strtod, ebx, esp, 123, 456, 789
pop ebx

... no assembly error will be thrown, but it doesn't work any more. The function strtod is defined as double strtod (const char* str, char** endptr);, which is not a VARARG - make sure you understand this ;-)

HSE

Quote from: jj2007 on April 18, 2021, 10:15:05 PM
which is not a VARARG

Look like was a way to define Unprototyped functions in 32 bits.
Equations in Assembly: SmplMath