I wrote the following function with POASM.
.data
value REAL8 2.026119
.code
my_cos proc
push ebp
mov ebp, esp
fld qword ptr [value]
fcos
pop ebp
ret
my_cos endp
I wonder if I can declare "value" inside function body.
I tried fld 2.026119 and I got the error "Invalid combination of opcode and operands (or wrong CPU setting)."
There is no direct opcode fld 2.026119, but if you prefer this simple syntax to a REAL8 in the .data section, it should be easy to set up a PoAsm macro. Here are some Masm equivalents for your inspiration.
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init
fldpi ; these are real opcodes
fldl2e
fldl2t
fldlg2
fld FP8(2.0261191) ; this is a Masm32 macro
FpuPush (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1189) 2.0261192 ; this is a MasmBasic macro
deb (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1019) 4, "Fpu", ST(0), ST(1), ST(2), ST(3), ST(4), ST(5), ST(6) ; use debug macro to display ST(0)
EndOfCode
Output:
Fpu
ST(0) 2.026119232177734375
ST(1) 2.026119099999999840
ST(2) 0.3010299956639811952
ST(3) 3.321928094887362348
ST(4) 1.442695040888963407
ST(5) 3.141592653589793238
ST(6) 0.0
something to test
MVR8 MACRO value
LOCAL varr8
.data
varr8 REAL8 value
.code
EXITM <addr varr8>
ENDM
.code
my_cos proc
.data
value REAL8 2.026119
.code
push ebp
mov ebp, esp
fld qword ptr [value]
fld qword ptr MVR8(2.026119)
fcos
pop ebp
ret
my_cos endp
Thank you for the help, jj2007 & TimoVJL.