I couldn't get the macro "FP4" to work. This macro is supposed to insert floating point values in floating point instructions, as if you were using immediate, but the compiler says "missing operator in expression"

I'm trying to do something like

fld FP4 1.0

I'm probably doing something wrong, I'm not used with MASM macros.
Thanks in advance.
Posted on 2003-09-07 07:36:36 by Chrishka
I'm not familiar with this FP4 macro, but here is the one I use:
fpc MACRO val:REQ

LOCAL w,x,y,z,zz,ww

;; split type and value, defaulting to REAL4
z INSTR 1,<&val>,<! >
IF z EQ 0
y TEXTEQU <REAL4>
x TEXTEQU <&val>
ELSE
y TEXTEQU @SubStr(<&val>,1,z-1) ;; Type
x TEXTEQU @SubStr(<&val>,z+1,) ;; Value
ENDIF

;; replace . with _
z INSTR 1,x,<!.>
IF z EQ 0
w TEXTEQU x
x CATSTR x,<.0> ;; prevent error message
ELSE
w CATSTR @SubStr(%x,1,z-1),<_>,@SubStr(%x,z+1,)
ENDIF

;; replace - with _
zz INSTR 1,w,<!->
IF zz EQ 0
ww TEXTEQU w
ELSE
ww CATSTR @SubStr(%w,1,zz-1),<_>,@SubStr(%w,zz+1,)
ENDIF

;; figure out global name for constant
z SIZESTR y ;; use last char for size distiction
ww CATSTR <__>,ww,<r>,@SubStr(%y,z,1)

IF (OPATTR(ww)) EQ 0 ;; not defined
CONST$fpu SEGMENT
ww y x
CONST$fpu ENDS
ENDIF
EXITM ww
ENDM
You can use it like this:

fld fpc(1)
fadd fpc(-1)
fmul fpc(REAL8 3.141592653589793238462643383279502884197169399375)
fdiv fpc(REAL4 -3)
Posted on 2003-09-07 10:26:50 by bitRAKE
Holy smokes
I don't like using code I don't understand and, damn, I really don' t understand this.
Does this generate a lot of instruction in code, or those are only compiler directives ?
Posted on 2003-09-07 10:32:50 by Chrishka
Just use like this:
fld FP4(x.x)
Posted on 2003-09-07 11:26:19 by inFinie
Chrishka, bitRAKEs code is complicated only because it avoids duplicating values.

Eg if you use fld fpc(1) twice in your program both will reference the same memory rather than having the value repeated in two places.
Posted on 2003-09-07 12:19:55 by Eóin
wow, sounds like good work. Will his macro be included in the next package ? Can I use it, BitRAKE ?
Posted on 2003-09-07 12:39:28 by Chrishka
Chrishka,

The FP4 macro is designed to embed literal floating point values into code so that you can use code as follows.


fld FP4(1.0000)

If you look at the macro,


FP4 MACRO value
LOCAL vname
.data
align 4
vname REAL4 value
.code
EXITM <vname>
ENDM

It gives you a unique REAL4 variable each time it is used.

Regards,
http://www.asmcommunity.net/board/cryptmail.php?tauntspiders=in.your.face@nomail.for.you&id=2f46ed9f24413347f14439b64bdc03fd
Posted on 2003-09-07 19:08:04 by hutch--

wow, sounds like good work. Will his macro be included in the next package ? Can I use it, BitRAKE ?
Sure, it is hard to wear out - even with everyone using it. :)
Posted on 2003-09-07 20:07:29 by bitRAKE
Thanks BitRAKE for your macro, thanks Infinie and Hutch-- too for the answer about FP4, I was missing the parenthesis, works fine now
Posted on 2003-09-08 00:33:24 by Chrishka