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
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
You show floating points with '%f' not '%d'. '%d' shows the parameter as a DWORD.
wsprintf doesn't handle floating points
h.
:rolleyes:
h.
:rolleyes:
OK thx but it not solve my problem.
"" BDW %d does not mean a DWORD but "decimal" ""
"" BDW %d does not mean a DWORD but "decimal" ""
The masm32 package come with several floating point to string conversion routines.
have a look at them....
have a look at them....
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 !!
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 !!
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:
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.
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
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.
Hint: FP does not use two's complement arithmetic.