flat assembler
Message board for the users of flat assembler.

 Index > Macroinstructions > How compare two irpv lists?
Author
Roman

Joined: 21 Apr 2012
Posts: 1363
Roman 14 Mar 2023, 12:51
Code:
```A equ in1
A equ in2 ;many values 35
B equ in1
B equ in2 ;many values 35
C equ call procA
C equ call procB ;many values 35

irpv v, A { compare v with B
and if equal do C}     ```

Or something else way compare A with B.
14 Mar 2023, 12:51
Roman

Joined: 21 Apr 2012
Posts: 1363
Roman 14 Mar 2023, 14:15
I try this, but doubled c
Code:
```AA equ ccc
AA equ ccc3
BB equ ccc
BB equ ccc3
CC equ inc eax
CC equ inc ebx

irpv c, CC    {   urr = 1
irpv b, AA    \{
irpv v, BB \\{

if v eq b
display 'ok;;'
if urr = 1
c
urr = 0
end if
end if
\\}
\}
}
```
14 Mar 2023, 14:15
bitRAKE

Joined: 21 Jul 2003
Posts: 3624
Location: vpcmipstrm
bitRAKE 14 Mar 2023, 14:30
We have eight copies of the inner branch, and four cases that pass the first if.
14 Mar 2023, 14:30
ProMiNick

Joined: 24 Mar 2012
Posts: 728
Location: Russian Federation, Sochi
ProMiNick 14 Mar 2023, 14:31
Code:
```field@struct equ hello
field@struct equ hello2
field2@struct equ hello
field2@struct equ hello2
field3@struct equ hello3
field3@struct equ hello2
irpv fields,field@struct { common define fields@name fields } ; taken from struct macroset
irpv fields,field2@struct { common define fields2@name fields }
irpv fields,field3@struct { common define fields3@name fields }
if fields@name eq fields2@name
display 'OK',13,10
end if
if fields3@name eq fields2@name
display 'noOK',13,10
end if
if fields3@name eq fields@name
display 'noOKtoo',13,10
end if     ```
14 Mar 2023, 14:31
Roman

Joined: 21 Apr 2012
Posts: 1363
Roman 14 Mar 2023, 14:46
ProMiNick
Your joined all names to one.
And this geting problems with compare different names.

You variant compare
hello,hello2 with hello,hello2

This variant not for my case.
14 Mar 2023, 14:46
Roman

Joined: 21 Apr 2012
Posts: 1363
Roman 14 Mar 2023, 14:54
bitRAKE wrote:
We have eight copies of the inner branch, and four cases that pass the first if.

We needed normal irpvs ! And we might compared many lists(More then two).

Then code look like this
Code:
```A equ in1
A equ in2 ;many values 35
B equ in1
B equ in2 ;many values 35
C equ call procA
C equ call procB ;many values 35

irpvs x,y,z A B C {
if x eq y
z
end if
}
```
14 Mar 2023, 14:54
Tomasz Grysztar

Joined: 16 Jun 2003
Posts: 8132
Location: Kraków, Poland
Tomasz Grysztar 14 Mar 2023, 15:08
As I understand, you want to iterate several lists in parallel. You could do that with numbered names:
Code:
```struc equs value&
{
match =.#%, .#% \{ .#% equ 0 \}
rept 1 i:.#%+1 \{ .#% equ i
.\#i equ value \}
}

A equs in1 ; A1 equ 1
A equs in2 ; A2 equ 2
; ...
B equs in1
B equs in2
; ...
C equs call procA
C equs call procB
; ...

; A%, B%, C% are counts of values in each list
rept A% i:1 {
if A#i eq B#i
C#i
end if
}    ```
14 Mar 2023, 15:08
Roman

Joined: 21 Apr 2012
Posts: 1363
Roman 14 Mar 2023, 15:10
Wow !

Thanks Tomasz Grysztar.
This is i wanted.
14 Mar 2023, 15:10
Roman

Joined: 21 Apr 2012
Posts: 1363
Roman 14 Mar 2023, 17:28
Problem with macro.
Code:
```macro attt  { invoke MessageBox,0,0,0,0 }
C equs attt

rept A% i:1 {
if A#i eq B#i
C#i  ;fasm error illegal instruction attt
end if
}    ```
14 Mar 2023, 17:28
macomics

Joined: 26 Jan 2021
Posts: 723
Location: Russia
macomics 14 Mar 2023, 17:34
Code:
```struc equs value&
{
match =.#%, .#% \{ .#% equ 0 \}
rept 1 i:.#%+1 \{ .#% equ i
.\#i equ value \}
}
macro invoke [name] {}
macro attt { invoke MessageBox,0,0,0,0 }

A equs in1 ; A1 equ 1
A equs in2 ; A2 equ 2

B equs in1
B equs in2

C equs attt
C equs attt

rept A% i:1 {
if A#i eq B#i
match x,C#i \{ x \};fasm error illegal instruction
end if
}    ```
14 Mar 2023, 17:34
Roman

Joined: 21 Apr 2012
Posts: 1363
Roman 14 Mar 2023, 17:39
macomics
Thanks.
Now work fine.

And work without macro invoke [name] {}
14 Mar 2023, 17:39
 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