flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > If val match problem.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 11 Feb 2024, 09:41
Fasmw 1.73

Code:
macro maaa1 a,b { addss a,b }
macro maaa2 a,b { addsd a,b }
macro maaa3 a,b { addps a,b } 

macro aa h {
local ppp
      if h#_typ eq int
              cvtsi2ss xmm0,[h]

      else if h#_typ eq flt
              movss xmm0,[h]
               ;define ppp 1
               ;ppp equ 1
               mmmm = 1
              ;display 'ff'
      else if h#_typ eq vc2
              movsd xmm0,[h]
               ;ppp equ 2
               mmmm = 2
      else if h#_typ eq vc4
              movups xmm0,dqword [h]
               ;ppp equ 3
               mmmm = 3
      end if 
 ppp equ mmmm
        match ppp2,ppp \{ display  ppp2+48 ;this show fine: 1 or 2 or 3
         maaa\#\\ppp2 xmm0,xmm1  ;get error undefined maaappp2
        \}      
}

val dd 10f,20f,30f,40f
val_typ equ vc4

aa val    ;display 3 mean vector4, but get fasm error undefined maaappp2


    
Post 11 Feb 2024, 09:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 11 Feb 2024, 09:57
There is no need for all the extra complication. Just directly use addss and forget about the mmmm and ppp stuff.

Code:
macro aa h {
      if h#_typ eq int
              cvtsi2ss xmm0,[h]
      else if h#_typ eq flt
              movss xmm0,[h]
              addss xmm0,xmm1
      else if h#_typ eq vc2
              movsd xmm0,[h]
              addsd xmm0,xmm1
      else if h#_typ eq vc4
              movups xmm0,dqword [h]
              addps xmm0,xmm1
      end if 
}

val dd 10f,20f,30f,40f
val_typ equ vc4

aa val    ;display 3 mean vector4, but get fasm error undefined maaappp2    
Post 11 Feb 2024, 09:57
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 11 Feb 2024, 10:05
I need my variant, because I have many operations(mul,sub,div,sqrt,rsqrt).
Not only add.

I want do this:
Code:
If op eq add
        match ppp2,ppp \{ 
         maaa\#\\ppp2 xmm0,xmm1  ;get error undefined maaappp2
        \}      
End if

If op eq mul
        match ppp2,ppp \{ 
         muu\#\\ppp2 xmm0,xmm1  ;get error undefined maaappp2
        \}      
End if

If op eq sqr
        match ppp2,ppp \{ 
         msqr\#\\ppp2 xmm0,xmm1  ;get error undefined maaappp2
        \}      
End if
    


Last edited by Roman on 11 Feb 2024, 10:09; edited 1 time in total
Post 11 Feb 2024, 10:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 11 Feb 2024, 10:07
The you can use the macro instead.
Code:
      else if h#_typ eq flt
              movss xmm0,[h]
              maaa1 xmm0,xmm1    
Post 11 Feb 2024, 10:07
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 926
Location: Russia
macomics 11 Feb 2024, 11:45
Code:
macro maaa1 a,b { addss a,b }
macro maaa2 a,b { addsd a,b }
macro maaa3 a,b { addps a,b }
macro aa h {
local ppp
      irpv mmmm,mm \{ restore mm \}
      match =flt, h#_typ \{
            movss xmm0,[h]
            mmmm equ 1
      \}
      match =mmmm, mmmm \{ match =vc2, h\#_typ \{
            movsd xmm0,[h]
            mmmm equ 2
      \} \}
      match =mmmm, mmmm \{ match =vc4, h\#_typ \\{
            movups xmm0,dqword [h]
            mmmm equ 3
      \\} \}
      match =mmmm, mmmm \{ match =int, h\#_typ \\{
            cvtsi2ss xmm0,[h]
            mmmm equ
      \\} \}
      match any, mmmm \{
            maaa\#any xmm0,xmm1
      \}
      restore mmmm
}
val dd 10f,20f,30f,40f
val_typ equ vc4

aa val    
Post 11 Feb 2024, 11:45
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.