News:

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

ascii to real translation

Started by ToutEnMasm, November 14, 2006, 05:31:08 PM

Previous topic - Next topic

ToutEnMasm


Hello,
I have a lot of real numbers to put on a structure and
fld 0.5  ;error A2050: real or BCD number not allowed

Is there an ascii to real function somewhere ?
                        ToutEnMasm

Draakie

There's one in the MASM32 - see FpuLIB by Raymond.


Does this code make me look bloated ? (wink)

sinsi

FLD needs the source to be a memory address, so to use "fld 0.5" try
.const
half REAL4 0.5   ;can be REAL8 or REAL10
.code
...
fld half


That error should say "immediate value not allowed"... ::)
Light travels faster than sound, that's why some people seem bright until you hear them.

ToutEnMasm

Thanks at all,

It's the method i have first used

TREAL4 MACRO pvalue:REQ,text:REQ
invoke StrToFloat,SADR(text),addr ChargeReal
fld real8 ptr ChargeReal
  fstp real4 ptr pvalue
ENDM


But zooba have posted a macro in the masm forum that solve the problem using the definition of a real4.

movr4 MACRO dest, src
mov dest, 0BADF00Dh ; make sure it's using a full DWORD move
ORG $-4
REAL4 src ; now overwrite with our real number
ENDM


The two give the same result ,but the movr4 used less time of the processor.

and the method with defined constants give another useful
                                      ToutEnMasm






                                         ToutEnMasm


ToutEnMasm


Ok,it seems that i have learn something this time.I have write a very simple method
I have verified it with the debugger,the result is correct.
                                   ToutEnMasm


R4MOV MACRO dest,src
     local reel
    .const
reel REAL4 src
     .code
PUSH reel
POP dest
ENDM