I do not know if such a question appeared. So sorry if "YES".
I'm just starting with asm so ... ... . . . . .. . . . . . . . . . . .. ...................................thx.

.date
X dd 1.5
format db "%d",0
text db 10 dup (?)


invoke wsprintf,ADDR text,ADDR format,X
invoke TextOut,hdc,50,50,addr text,11

;and a strange things appears in the window


it is very short version as u can see
Posted on 2002-11-15 07:25:13 by drakoforma
You show floating points with '%f' not '%d'. '%d' shows the parameter as a DWORD.
Posted on 2002-11-15 08:42:00 by gliptic
wsprintf doesn't handle floating points

h.
:rolleyes:
Posted on 2002-11-15 15:25:16 by hitchhikr
OK thx but it not solve my problem.

"" BDW %d does not mean a DWORD but "decimal" ""
Posted on 2002-11-16 10:47:30 by drakoforma
The masm32 package come with several floating point to string conversion routines.
have a look at them....
Posted on 2002-11-16 15:52:24 by MArtial_Code
Those functions take QWORDS.
Unfortunately, most people are using FLOATS which are REAL4 (DWORDS).

To convert a DWORD to a QWORD you can use the CDQ opcode.
It extends 32bit EAX into 64bit EDX:EAX, keeping the sign true.
What a pain !!
We want better support in masmlib for larger data types !!
Posted on 2002-12-04 00:21:33 by Homer

We want better support in masmlib for larger data types !!

Write your own routine and submit it, im sure hutch will be happy to consider it for everyones use. Cheers, thanks a lot for volunteering:rolleyes:
Posted on 2002-12-04 03:17:10 by huh
I have cut out this snip of code, it takes a 80 bit float (lpdvFloat), a maximum precision in digits (dwPrec) and returns a string in lpszOut.
The float parameter can be easily changed from tbyte to qword or dword by changing the fld command.

store	macro	data

local stoVoid

test edi, edi
je stoVoid

mov byte ptr [edi + edx], data
stoVoid: inc edx

endm

fjl MACRO Marke
fstsw ax
sahf
ja Marke
ENDM

fjge MACRO Marke
fstsw ax
sahf
jbe Marke
ENDM

;***********************************************************************
; does: converts float to string *
; last update: 07-12-2001 - Scholz *
; parameters: dwLength FloatToString (lpdvFloat, dwPrec, lpszOut) *
; returns: length of string or zero *
;***********************************************************************

FloatToString PROC USES edi esi, lpdvFloat:DWORD, dwPrec:DWORD, lpszOut:DWORD
LOCAL dvTenth:QWORD, dvCalc:QWORD, dvTen:QWORD, dvFloat:QWORD
LOCAL wFPU:DWORD, wOrg:DWORD, dwNumber:DWORD, fSign:DWORD

finit
fstcw word ptr wFPU

mov eax, wFPU
mov wOrg, eax

or word ptr wFPU, 0F00h
fldcw word ptr wFPU

mov dword ptr dvTen, 10
fild dword ptr dvTen
fst dvTenth
fstp dvTen

xor eax, eax
mov fSign, eax

mov eax, lpdvFloat
fld tbyte ptr [eax]
fldz
fcomp st(1)
fjge fstPos
fchs

mov fSign, TRUE

fstPos: fstp dvFloat


;----------------- calc maximum decimal base

fstLength: fld dvFloat
fdiv dvTenth
frndint

fld1
fcomp st(1)
fjl fstConInt

ffree st
fld dvTenth
fmul dvTen
fstp dvTenth
jmp fstLength


;----------------- convert integer part

fstConInt: xor edx, edx
mov edi, lpszOut

mov eax, fSign
test eax, eax
je fstStart

store "-"

fstStart: fld dvTenth
fdiv dvTen
fstp dvTenth

fld dvFloat
fstp dvCalc

fstIntLoop: fld1
fcomp dvTenth
fjl fstConFrac

fld dvCalc
fld dvCalc
fdiv dvTenth
frndint
fist dword ptr dwNumber
fmul dvTenth
fsubp st(1), st

mov ecx, dwNumber
add cl, "0"
store cl

fld dvTenth
fdiv dvTen
fstp dvTenth

fstp dvCalc
jmp fstIntLoop


;----------------- convert fractional part

fstConFrac: store "."

xor ebx, ebx
mov esi, dwPrec
fstFracLoop: cmp ebx, esi
jae fstZeros

fld dvCalc
fld dvCalc
fdiv dvTenth
frndint
fist dword ptr dwNumber
fmul dvTenth
fsubp st(1), st

mov ecx, dwNumber
add cl, "0"
store cl
inc ebx

fld dvTenth
fdiv dvTen
fstp dvTenth

fstp dvCalc
jmp fstFracLoop


;----------------- remove least zeros

fstZeros: add edx, dwPrec
test edi, edi
je fstDone

sub edx, dwPrec
dec edx

cmp byte ptr [edi + edx], "."
je fstDot
cmp byte ptr [edi + edx], "0"
jne fstZero
jmp fstZeros

fstDot: dec edi
fstZero: mov byte ptr [edi + edx + 1], 0

fstDone: mov eax, edx

finit
fldcw word ptr wOrg
ret

FloatToString ENDP
Posted on 2002-12-04 04:26:17 by beaster

Unfortunately, most people are using FLOATS which are REAL4 (DWORDS).

To convert a DWORD to a QWORD you can use the CDQ opcode.
It extends 32bit EAX into 64bit EDX:EAX, keeping the sign true.
You do not convert a REAL4 to REAL8 by using CDQ. You are better off just loading an FP register, which automatically extends a REAL4 number to 80-bit format. And then storing a REAL8 number from that register. I don't use the FP registers, so I'm guessing the opcodes are FLD and FST.

Hint: FP does not use two's complement arithmetic.
Posted on 2002-12-04 12:17:26 by tenkey