The MASM Forum

General => The Campus => Topic started by: ragdog on April 18, 2014, 01:55:02 AM

Title: Calc macros
Post by: ragdog on April 18, 2014, 01:55:02 AM
Hello all

Gives any simply calculationĀ“s macros for Masm what i can use in a call like cpp?

example +,-,*,/

testproc( pstruct->item, pstruct->item1 - pstruct->item0 - 1 );

regards,
Title: Re: Calc macros
Post by: jj2007 on April 18, 2014, 03:05:25 AM
Sure:
include \masm32\MasmBasic\MasmBasic.inc      ; download (http://masm32.com/board/index.php?topic=94.0)
      Init
      mov eax, 100
      mov ecx, 1000
      fldpi
      Inkey Str$("10*PI=%f", ecx/eax*ST(0))
      Exit
end start


10*PI=31.41593

But wait for qWord, he can explain what SmplMath (http://sourceforge.net/projects/smplmath/) is all about ;-)
Title: Re: Calc macros
Post by: ragdog on April 18, 2014, 05:17:29 AM
Hi Jochen

I have look in simplemath and i can understand it works this with Fpu?!?

I wish only with sub,add,Imul,Idiv and eax,ebx.....

After compile it with cpp
"testproc( pstruct->item, pstruct->item1 - pstruct->item0 - 1 );"

is this only

mov     edx, [eax+385h]
mov     eax, [eax+389h]
dec     ecx
push    ecx
sub     eax, edx
push    edx
call   testproc

And this same Macros for Masm32 is wonderful :biggrin: