flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > problems with equ and define.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 2007
Roman 18 Oct 2025, 06:00
fasmw 1.73
Code:

macro xmDefV4 name { 
if xmmn < 3
name equ xmm\#\xmmn ;first equ
end if
if xmmn >= 3
;name equ [tmpv4@xmm@buf+xmmn*16] ;second problem this equ changed first equ
end if
}
;data
align 16
tmpv4@xmm@buf dd 16*4 dup(0)

;in code
xmmn equ 0
xmDefV4 def1
mov eax,def1 ;fasm error xmm#0. But must be xmm0
addss xmm2,def1
    
Post 18 Oct 2025, 06:00
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2007
Roman 18 Oct 2025, 06:35
I do this variant and this working fine, but its look ugly.
Code:
macro xmDefV4 name {
match =0,xmmn \{ name equ xmm0 \}
match =1,xmmn \{ name equ xmm1 \}
match =2,xmmn \{ name equ xmm2 \}
match =3,xmmn \{ name equ xmm3 \}

match =4,xmmn \{ name equ [tmpv4@xmm@buf+0*16] \}
match =5,xmmn \{ name equ [tmpv4@xmm@buf+1*16] \}
match =6,xmmn \{ name equ [tmpv4@xmm@buf+2*16] \}
match =7,xmmn \{ name equ [tmpv4@xmm@buf+3*16] \}
match =8,xmmn \{ name equ [tmpv4@xmm@buf+4*16] \}
match =9,xmmn \{ name equ [tmpv4@xmm@buf+5*16] \}
match =10,xmmn \{ name equ [tmpv4@xmm@buf+6*16] \}
match =11,xmmn \{ name equ [tmpv4@xmm@buf+7*16] \}
}
;in code
xmmn equ 0
xmDefV4 def1
addss xmm2,def1 ;get addss xmm2,xmm0

xmmn equ 5
xmDefV4 def2
addss xmm2,def2 ;get addss xmm2,[tmpv4@xmm@buf+1*16]

    
Post 18 Oct 2025, 06:35
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 2007
Roman 18 Oct 2025, 07:24
I rewrite macro
Code:
 
macro ifmatch name,a,[b,c] { match =b,xmmn \{ name equ [a+c*16] \} }

macro xmDefV4 name {
;match =0,xmmn \{ name equ xmm0 \}
;match =1,xmmn \{ name equ xmm1 \}
;match =2,xmmn \{ name equ xmm2 \}
;match =3,xmmn \{ name equ xmm3 \}
rept 4 j:0 \{ match =j,xmmn \\{ name equ xmm\#\j \\} \} 

 rept 16 h:4, j:0 \{ ifmatch name,tmpv4@xmm@buf,h,j \}
}
    
Post 18 Oct 2025, 07:24
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.