flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Need to know the type of parameter in a macro.

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 27 May 2009, 18:23
I'm writing a macro for simple vector math and need to know the type of variable that is passed. In the example below, I need to know what kind of variable fscalar is, a direct float 5.0, or a variable [fscalar]:
Code:
;Vector3 operator*(Vector3 v, Scalar a)
macro MULTVECTORSCALAR vectora, fscalar
      if eqtype fscalar, 1.0
         fldd    fscalar
         fld     st0
         fld     st0
      else
         fld     [fscalar]
         fld     st0
         fld     st0
      end if

      fmul    [vectora + D3DVECTOR.x]
      fstp    [vectora + D3DVECTOR.x]
      fmul    [vectora + D3DVECTOR.y]
      fstp    [vectora + D3DVECTOR.y]
      fmul    [vectora + D3DVECTOR.z]
      fstp    [vectora + D3DVECTOR.z]
}    

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 27 May 2009, 18:23
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 27 May 2009, 19:24
Code:
macro type [arg]
{
  if arg eqtype 1.0
    display "It's a float constant", 13, 10
  else if arg eqtype 0
    display "May be an address", 13, 10
  else if arg eqtype []
    display "It is an address", 13, 10
  else
    display "It is something else", 13, 10
  end if
}

type 1.0
type aLabel
type 5
type [eax+ebx]

aLabel:    
Question
Post 27 May 2009, 19:24
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 27 May 2009, 19:56
Yeh, thanks for the help, everything is working now.
Post 27 May 2009, 19:56
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 28 May 2009, 12:03
Why not:
Code:
struct D3DVECTOR
  x dd ?
  y dd ?
  z dd ?
  dummy dd ?
ends
;Vector3 operator*(Vector3 v, Scalar a)
macro MULTVECTORSCALAR vectora, fscalar
{
      pshufd  xmm0,dqword[fscalar],00000000b
      mulps   xmm0,dqword[vectora + D3DVECTOR.x]
      movaps  dqword[vectora + D3DVECTOR.x],xmm0
}
MULTVECTORSCALAR blah1,blah2
    

or compatibility-issues?
Post 28 May 2009, 12:03
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 01 Jun 2009, 10:02
Thanks Madis731,
I do need to learn sse programming much better than I do now.
Post 01 Jun 2009, 10:02
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.