flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Basic / Newbie question about irp (+similar irps, irpv)

Author
Thread Post new topic Reply to topic
fabbel



Joined: 30 Oct 2012
Posts: 84
fabbel 21 Nov 2017, 16:22
Hello

Can someone pls help in understanding why this does not iterate :

Code:
-----
list equ 'X','Y','Z'

display "list=", list, 0Dh, 0Ah
irp item, list {display item,"-",0Dh, 0Ah}
-----


=> this displays :
list=XYZ
XYZ-

so 1st line with display directive looks to view 'list' symbols as a list of comma separated arguments,
but second line using irp looks to fail.


I expected to get output as follows :
list=XYZ
X- <followed by newline>
Y- <followed by newline>
Z- <followed by newline>


What am i doing wrong ? what am i missing ?
Can u pls help / advise about the best way to iterate such 'list' symbol, processing individual item one at a time.
wud other macro directives be more suited to the task ==> irps and/or irpv maybe ?
I've read the manual but somehow can't figure it out.. could someone pls kindly
(re)explain/clarify the differences betw. those and how to use them.

Sorry for the newbie questions...

Thx
Post 21 Nov 2017, 16:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20357
Location: In your JS exploiting you and your system
revolution 21 Nov 2017, 16:40
IRP doesn't evaluate symbolic equates for the second operand. You can use MATCH to translate:
Code:
match x,list {
        irp item, x \{display item,"-",0Dh, 0Ah \}
}    
Post 21 Nov 2017, 16:40
View user's profile Send private message Visit poster's website Reply with quote
fabbel



Joined: 30 Oct 2012
Posts: 84
fabbel 21 Nov 2017, 17:14
Hello

Thx revolution for the quick answer.

What about using irps and / or iprv (for me to get idea of situations where one of those may be preferred over the others..) ?
Post 21 Nov 2017, 17:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20357
Location: In your JS exploiting you and your system
revolution 21 Nov 2017, 17:34
IRPS is a symbol version of IRP so each symbol is iterated including commas, whereas IRP uses commas as a separator. Try this:
Code:
irp x, foo,bar {display `x,13,10}
display '------------------------------',13,10
irps x, foo,bar {display `x,13,10}    
IRPV is different though. It is used to iterate through overloaded equates. Try this:
Code:
y equ 1
y equ 2
y equ 3
irpv x, y {display `x,13,10}    
Post 21 Nov 2017, 17:34
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.