flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How fix rept in match ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 05 Apr 2023, 07:53
Fasmw 1.73
Code:
pupz equ edx,ecx,edi,ebp
ykkk fix p1=, p2=, pout1=, pout2
match ykkk  , pupz {  
     rept 2 n:1 \{
      mov al,[p\#n]            ;fasm error undefined p1 ! Why ?!
      mov [pout\#n],al 
      \}      
      }     
Post 05 Apr 2023, 07:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 05 Apr 2023, 08:06
The outer match sees "p#n" and does nothing to it.

The inner rept sees p1 and correctly tells you p1 is undefined.

BTW: If you ever find yourself using fix then you are probably doing something wrong. Razz But no matter, here it makes no difference, the problem you have here has nothing to do with fix at all.
Post 05 Apr 2023, 08:06
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 05 Apr 2023, 08:17
This not work too.
Code:
match p1=, p2=, pout1=, pout2  , edx,ecx,edi,ebp {   
     rept 2 n:1 \{
      mov al,[p\#n]            ;fasm error undefined p1
      mov [pout\#n],al       ;fasm error undefined pout1
      \}
      } 
    
Post 05 Apr 2023, 08:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 05 Apr 2023, 08:50
Use irp. You can use pairs of values for each iteration.
Post 05 Apr 2023, 08:50
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 05 Apr 2023, 09:33
Not work if I using equ.
Code:
pupz equ edx,ecx,edi,ebp    ;i want this variant
irp t, pupz {   mov al,[t]  } ;fasm error mov al,[edx,ecx,edi,ebp]
    


This work
Code:
irp t, edx,ecx,edi,ebp {   mov al,[t]
      display #`t,13,10
      }  
    


You say fix is wrong.
But what can I do ? Only using fix
Code:
pupza fix edx,ecx,edi,ebp
      irp t, pupza {   mov al,[t]
      display #`v,13,10
      } 
    


Bad irp not get many params. Like this
Code:
irp t1 t2, ecx,edx esi,edi { 
mov al,[t1]   ;t1=ecx than edx
mov [t2],al   ;t2=esi than edi
}
    
Post 05 Apr 2023, 09:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 05 Apr 2023, 10:29
Use irp with angle brackets around each pair, then match to separate the pairs into values.
Post 05 Apr 2023, 10:29
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 05 Apr 2023, 11:19
Roman wrote:
Bad irp not get many params. Like this
Code:
irp t1 t2, ecx,edx esi,edi { 
mov al,[t1]   ;t1=ecx than edx
mov [t2],al   ;t2=esi than edi
}
    
It's a feature present in fasmg:
Code:
include 'cpu/x64.inc'
use32
include 'listing.inc'

irp <t1,t2>, ecx,esi, edx,edi
        mov al,[t1]
        mov [t2],al
end irp    
result.lst:
Code:
[0000000000000000] 00000000: 8A 01                    mov al,[ecx]
[0000000000000002] 00000002: 88 06                    mov [esi],al
[0000000000000004] 00000004: 8A 02                    mov al,[edx]
[0000000000000006] 00000006: 88 07                    mov [edi],al    
But in general, as revolution pointed out, you can combine IRP with MATCH to handle more complex cases.
Post 05 Apr 2023, 11:19
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 05 Apr 2023, 15:10
revolution
Use irp with angle brackets around each pair, then match to separate the pairs into values.
Code:
irp t1, ecx:esi,edx:edi {
   match t2=: x, t1 \{ 
   mov al,[\t2]
   mov [\x],al 
   \} } 
    
Post 05 Apr 2023, 15:10
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.