I have this bit of code in masm32:

;Temp = 256, Cr = -2.0

FLD Temp ;store Temp to FP stack
FLD Cr ;store Cr to FP stack
FMUL ;ST(0) x ST(1)
FST Temp ;store ST(0) to Temp
PrintDec Temp :DEBUGGER display value of Temp

The debugger shows this:

Temp = -2

Shouldn't this be -512 ? That is what I was hoping for anyway. What am I doing wrong?
If I use FIST instead of FST it gets even weirder, -214748356.

:stupid:
Posted on 2003-01-24 14:41:16 by evanmars
;Temp = 256, Cr = -2.0

did you define temp as 256 oder 256.0? ;)
Posted on 2003-01-24 15:00:41 by Tola
Perhaps I should include a bit more of my code:

LOCAL Temp :DWORD

mov edx, 0
mov eax, 0
mov eax, Wwd ;store window width in eax eax = 1024
mov Temp, 4 ;store 4 in Temp Temp = 4
div Temp ;divide eax by Temp eax = 256
mov Temp, eax ;store result in Temp Temp = 256

;everything is fine up to here

FLD Temp ;store Temp to FP stack

;from FP help: All memory operands are automatically converted to temporary-real numbers before being loaded.
;.....can be ... 16-, 32-, or 64-bit integers

FLD Cr ;store Cr to FP stack
FMUL ; ST(0) x ST(1) --> 256 *-2
FST Temp
PrintDec Temp
:confused:
Posted on 2003-01-24 15:14:16 by evanmars
use
FILD Temp
since Temp is holding an integer value, not a floating point one.
Posted on 2003-01-24 15:31:08 by Tola


;Temp = 256, Cr = -2.0

FILD Temp ;store Temp to FP stack
FLD Cr ;store Cr to FP stack
FMUL ;ST(0) x ST(1)
FIST Temp ;store ST(0) to Temp
FSTP Temp2

PrintDec Temp :DEBUGGER display value of Temp
PrintFloat Temp2
The debugger shows this:

Temp = -512
Temp2 = -512.0



I have written the PrintFloat macro watching PrintDec from VKDebug's src. Here's it:


ifndef PRINT_FLOATS_HERE
PRINT_FLOATS_HERE equ 1
PrintFloats proc uses eax Input,Kade
local doub:real8
fld Input
fstp doub
invoke FloatToStr2,doub,Kade
ret
PrintFloats endp
endif


PrintFloat macro Var:REQ
local szDN
.data
szDN byte 24 dup(0)
.code
pushad
invoke PrintFloats,Var,addr szDN
invoke lstrlen,addr szDN
add eax,@SizeStr(&Input)+4
invoke GlobalAlloc, GMEM_FIXED+GMEM_ZEROINIT, eax
mov ebx,eax
FillMem ebx,&Var
mov dword ptr [eax+@SizeStr(&Var)], 203D20h
invoke lstrcat,eax,addr szDN
invoke DebugPrint,ebx
invoke GlobalFree,ebx
popad
endm

PrintDouble macro Var:REQ
local szDN
.data
szDN byte 24 dup(0)
.code
pushad
invoke FloatToStr2,Var,addr szDN
invoke lstrlen,addr szDN
add eax,@SizeStr(&Input)+4
invoke GlobalAlloc, GMEM_FIXED+GMEM_ZEROINIT, eax
mov ebx,eax
FillMem ebx,&Var
mov dword ptr [eax+@SizeStr(&Var)], 203D20h
invoke lstrcat,eax,addr szDN
invoke DebugPrint,ebx
invoke GlobalFree,ebx
popad
endm
Posted on 2003-01-27 23:51:48 by Ultrano
Ultrano,
The latest version of VKDEBUG has PrintDouble macro. Please, download the MASM32v8.
With best regards, vkim.
Posted on 2003-01-28 21:11:31 by vkim
Yes, I was going to write about it :), I downloaded masm8 yesterday. But .. the lack of PrintFloat is not good! Please upgrade the macros, I think PrintFloat is a hundred times more important to any masm coder, than PrintDouble. I haven't toyed much with masm8- just saw the new stuff in it. Nice installation :) . I think the TrapException should be made not use external dlls . But everything else is perfect ;) thanks for VKDebug, vkim ;).
A little note: I will not "witch" to masm8- all the functions that are new and that I need, I have already made :). The xxBitmap, for instance. But it's just me, I suppose.
Posted on 2003-01-29 05:11:19 by Ultrano