The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Ficko on July 02, 2010, 06:40:50 PM

Title: Number -N to String -N MACRO Q?
Post by: Ficko on July 02, 2010, 06:40:50 PM
How to convert a minus number to string retaining the format. -SDWORD-
MASM seems to convert it to "DWORD" except for "%echo" :eek

I need "-20.0" and not "4294967276.0" ::)


.686p
.model flat, stdcall
option casemap :none

pushf4 MACRO Num:REQ
push dword ptr 0
    ORG $-4
    REAL4 Num
ENDM

First MACRO Num:REQ
LOCAL Fl,StrFl
Fl EQU Num
%echo @CatStr(<%Fl>)
StrFl CATSTR %(&Fl),<.0>
%echo StrFl
pushf4 StrFl
ENDM

.code
start:
int 3
First -10*2
fld dword ptr [esp]
end start
Title: Re: Number -N to String -N MACRO Q?
Post by: jj2007 on July 02, 2010, 06:52:28 PM
include \masm32\include\masm32rt.inc

pushf4 MACRO Num:REQ
  push dword ptr 0
  ORG $-4
  REAL4 Num
ENDM

First MACRO Num:REQ
  pushf4 @CatStr(%Num, <.0>)
ENDM

.code
start:
int 3
First -10*2
fld dword ptr [esp]
exit
end start
Title: Re: Number -N to String -N MACRO Q?
Post by: Ficko on July 02, 2010, 07:25:35 PM
Damn! 
Thanks :clap:

I wish I could understand why something works and why not. :red  :green