.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.DATA
FloatNumber real4 1.5
StrFormat DB 'Float is %f',0
Caption DB 'Float Message',0
Buff DB 50 dup (0)
.CODE
START:
push FloatNumber
push offset StrFormat
push offset Buff
call wsprintf
add esp, 12
push MB_OK
push offset Caption
push offset Buff
push 0
call MessageBox
push 0
call ExitProcess
END START
Hi.
What I do wrong? ::)
I need help :)
LechooY ,
It would be nice if you told us what the problem or error is. Ratch
LechooY, wsprintf doesn't support f format value, hence it can't format floating point numbers.
You could use fpulib functions (it's located in MASM32 folder) to convert floating point numbers to ascii string.
Thanks arafel :U
LechooY,
You can also use sprintf from the MSVCRT library.
.386
.MODEL FLAT, STDCALL
OPTION CASEMAP :NONE
INCLUDE c:\masm32\include\windows.inc
INCLUDE c:\masm32\include\user32.inc
INCLUDE c:\masm32\include\kernel32.inc
INCLUDE c:\masm32\include\msvcrt.inc
INCLUDELIB c:\masm32\lib\user32.lib
INCLUDELIB c:\masm32\lib\kernel32.lib
INCLUDELIB c:\masm32\lib\msvcrt.lib
.DATA
FloatNumber REAL4 1.5
DoubleNumber REAL8 0.0
StrFormat BYTE 'Float is %f',0
Caption BYTE 'Float Message',0
Buff BYTE 50 dup (0)
.CODE
START:
; sprintf expects a REAL8, so convert
finit
fld FloatNumber
fstp DoubleNumber
fwait
push DWORD PTR [DoubleNumber+4]
push DWORD PTR [DoubleNumber+0]
push OFFSET StrFormat
push OFFSET Buff
call crt_sprintf
add esp, 16
push MB_OK
push OFFSET Caption
push OFFSET Buff
push 0
call MessageBox
push 0
call ExitProcess
END START
wouldnt exitProcess have to be defined up top? or is my outdated asm just not like that?
ExitProcess should be defined in windows.inc.
Thanks All!
This forum is great :U
Small correction, ExitProcess is defined in kernel32.inc as:
ExitProcess PROTO :DWORD
Quote from: MichaelW on April 27, 2006, 10:33:07 PM
Small correction, ExitProcess is defined in kernel32.inc as:
ExitProcess PROTO :DWORD
Oh whoops, yes you're right. :red I did a quick search using my Library Search tool (http://www.masmforum.com/simple/index.php?topic=3863.0) and it showed windows.inc as having the text "ExitProcess" in it, but indeed the function is only defined in kernel32.inc.