flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > include data only once

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1853
Roman 22 Dec 2024, 13:22
fasmw 1.73
Code:
macro vecAdd v1=we1,v2=we2 { local .a
                             movups xmm0,dqword [v1]
                             movups xmm1,dqword [v2]
                             addps  xmm1,xmm0
if ~defined we1 | @f
jmp .a
we1 dd 0,0,0,0
we2 dd 0,0,0,0
.a:
end if
}
Start:  vecAdd ;ok
        vecAdd  ;fasm error symbol we1 already defined.

    

I want ignored data we1 and we2 in second vecAdd
Post 22 Dec 2024, 13:22
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1044
Location: Russia
macomics 22 Dec 2024, 16:03
Code:
macro vecAdd v1=we1,v2=we2 { local .a
                             movups xmm0,dqword [v1]
                             movups xmm1,dqword [v2]
                             addps  xmm1,xmm0
if ~defined we1 | @f
@@: jmp .a
we1 dd 0,0,0,0
we2 dd 0,0,0,0
.a:
end if
}
Start:  vecAdd ;ok
        vecAdd  ;fasm error symbol we1 already defined.    
Post 22 Dec 2024, 16:03
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1853
Roman 22 Dec 2024, 17:46
this work.
Code:
macro vecAdd v1=we1,v2=we2 { local aa
                             movups xmm0,dqword [v1]
                             movups xmm1,dqword [v2]
                             addps  xmm1,xmm0
if ~definite we1

 jmp aa
we1 dd 0,0,0,0
we2 dd 0,0,0,0
aa:
end if

}
Start:  vecAdd
        vecAdd     
Post 22 Dec 2024, 17:46
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 670
Location: Ukraine
Overclick 23 Jan 2025, 10:08
You can try multisection mode:
Code:
macro vecAdd v1=we1,v2=we2 { local aa
                             movups xmm0,dqword [v1]
                             movups xmm1,dqword [v2]
                             addps  xmm1,xmm0
  .dataonce vecAdd
     we1 dd 0,0,0,0
     we2 dd 0,0,0,0
  .code
}
Start:  vecAdd
        vecAdd 
    

Or even like this:
Code:
macro vecAdd v1=we1,v2=we2 { local aa
                             movups xmm0,dqword [v1]
                             movups xmm1,dqword [v2]
                             addps  xmm1,xmm0
  ..dataonce we1, we1 dd 0,0,0,0
  ..dataonce we2, we2 dd 0,0,0,0
}
Start:  vecAdd
        vecAdd 
    

Or even by stream:
Code:
macro vecAdd v1=we1,v2=we2 { local aa
                             movups xmm0,dqword [v1]
                             movups xmm1,dqword [v2]
                             addps  xmm1,xmm0
  .frameonce vecAdd
     we1 dd 0,0,0,0
     we2 dd 0,0,0,0
  .code
}
.multisection
section .data data readable writeable
  .stream vecAdd
section .code code readable executable
Start:  vecAdd
        vecAdd 
    

Any of this examples will free your code from using extra jumps at least
Post 23 Jan 2025, 10:08
View user's profile Send private message Visit poster's website 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.