News:

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

Main Menu

macro for transfer a real value to a local variable

Started by Mikl__, October 27, 2015, 07:12:47 PM

Previous topic - Next topic

Mikl__

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!

jj2007

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

Mikl__

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

jj2007

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...

Mikl__

macro by KyberMax
movr MACRO x, y
      MOV   x, 0
      ORG   $ - SizeOf REAL4
      dd y
ENDM

jj2007

Yes, that works. But so does this built-in Masm32 macro:

  mov ecx, FP4(111.222)

Mikl__


jj2007

And I did not know that the assemblers (Masm, JWasm, AsmC) accept a mov eax, somereal4 ::)

jj2007

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 ;-)