News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Float to ASCII

Started by JK, June 04, 2020, 02:25:47 AM

Previous topic - Next topic

JK

I want to display floating point numbers, but my code doesn´t work. What am i doing wrong?



.386
.model flat, stdcall

include <windows.inc>
include <c:\masm32\include\msvcrt.inc>


includelib kernel32.lib
includelib user32.lib
includelib <C:\masm32\lib\msvcrt.lib>


.data
  r8fmt   BYTE "%F", 0
  r8value REAL8 2.0

.code


start proc
;***************************************************************************
;
;***************************************************************************
local buffer[100]:byte


  lea eax, buffer
  mov byte ptr [eax], "F"
  add eax, 1
  mov byte ptr [eax], ":"
  add eax, 1
  mov byte ptr [eax], " "
  add eax, 1


  invoke crt__snprintf, eax, 96, ADDR r8fmt, r8value ;output float
  invoke MessageBoxA, 0, ADDR buffer, CSTR("Float"), 0

  invoke ExitProcess, 0
  ret

   
start endp


end start




Thanks


JK

jj2007


JK

Thanks a lot - this one cost me quite some time!

I´m asking myself why the uppercase version just doesn´t work. According to here (https://en.cppreference.com/w/c/io/fprintf) and here (http://www.cplusplus.com/reference/cstdio/printf/) it definitely should.


JK