The MASM Forum

General => The Campus => Topic started by: Mikl__ on October 27, 2015, 07:12:47 PM

Title: macro for transfer a real value to a local variable
Post by: Mikl__ on October 27, 2015, 07:12:47 PM
Maybe there is somebody ready macro? I need something likemovr local_var, 3.1415926wher local_var is a local variable and macro movr x, y
... <-- I dont know yet
dd y
endm
something likedb 68h;push
dd 3.1415926
pop local_var
but without the instructions "Push/pop" and FPU-instructions
thank you!
Title: Re: macro for transfer a real value to a local variable
Post by: jj2007 on October 27, 2015, 07:51:20 PM
include \masm32\include\masm32rt.inc

SetLocalFloat MACRO dest, immfloat
  fld FP8(immfloat)
  fstp dest
ENDM

.code
mytest proc
LOCAL MyR8:REAL8
  SetLocalFloat MyR8, 123.456
  printf("\nR8=%f\n", MyR8)
  ret
mytest endp

start:
  call mytest
  exit

end start
Title: Re: macro for transfer a real value to a local variable
Post by: Mikl__ on October 27, 2015, 08:01:57 PM
Hi, jj2007!
Quotebut without the instructions "Push/pop" and FPU-instructions
I need something like
db 0C7h,85h,68h
dd 3.1415926;== mov dword ptr [rbp-98h], 3.1415926
Title: Re: macro for transfer a real value to a local variable
Post by: jj2007 on October 28, 2015, 12:52:10 AM
somevar dd 3.1415926 ; won't assemble == mov dword ptr [rbp-98h], 3.1415926

somevar REAL4 3.1415926;== m2m dword ptr [rbp-98h], dword ptr somevar  ; 3.1415926

Perhaps you should explain the context...
Title: Re: macro for transfer a real value to a local variable
Post by: Mikl__ on October 28, 2015, 08:40:20 PM
macro by KyberMax
movr MACRO x, y
      MOV   x, 0
      ORG   $ - SizeOf REAL4
      dd y
ENDM
Title: Re: macro for transfer a real value to a local variable
Post by: jj2007 on October 28, 2015, 08:53:05 PM
Yes, that works. But so does this built-in Masm32 macro:

  mov ecx, FP4(111.222)
Title: Re: macro for transfer a real value to a local variable
Post by: Mikl__ on October 28, 2015, 09:26:11 PM
I did not know about it (http://www.cyberforum.ru/images/smilies/sorry.gif)
Title: Re: macro for transfer a real value to a local variable
Post by: jj2007 on October 28, 2015, 10:05:00 PM
And I did not know that the assemblers (Masm, JWasm, AsmC) accept a mov eax, somereal4 ::)
Title: Re: macro for transfer a real value to a local variable
Post by: jj2007 on November 17, 2015, 10:32:09 PM
Hi Mikl,
Just saw your fractal tree code - very nice :t

I had some trouble building it, though. Attached a slightly modified version that builds with standard Masm32, in case somebody is interested. No macros, though, you are not even using invoke ;-)