flat assembler
Message board for the users of flat assembler.

 Index > Macroinstructions > How fix rept in match ?
Author
Roman

Joined: 21 Apr 2012
Posts: 1735
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
\}
}     ```
05 Apr 2023, 07:53
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20248
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. But no matter, here it makes no difference, the problem you have here has nothing to do with fix at all.
05 Apr 2023, 08:06
Roman

Joined: 21 Apr 2012
Posts: 1735
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
\}
}
```
05 Apr 2023, 08:17
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20248
revolution 05 Apr 2023, 08:50
Use irp. You can use pairs of values for each iteration.
05 Apr 2023, 08:50
Roman

Joined: 21 Apr 2012
Posts: 1735
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
}
```
05 Apr 2023, 09:33
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20248
revolution 05 Apr 2023, 10:29
Use irp with angle brackets around each pair, then match to separate the pairs into values.
05 Apr 2023, 10:29
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8347
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.
05 Apr 2023, 11:19
Roman

Joined: 21 Apr 2012
Posts: 1735
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
\} }
```
05 Apr 2023, 15:10
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum