flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Macroinstructions > break out early of repetition macros: rept, irp, irps, irpv?

Author
Thread Post new topic Reply to topic
fabbel



Joined: 30 Oct 2012
Posts: 9

break out early of repetition macros: rept, irp, irps, irpv?

Hello

Is there a way to break out early, upon some condition (e.g. dep on some successful match{..}), from repetition macros such as rept, irp, irps, irpv... ?

basically sthg similar to following assembly construct, but available at the preprocessing stage :
repeat
(..)
if (..)
break
end if
(..)
end repeat


Tx
[/b]
Post 09 Feb 2018, 07:54
View user's profile Send private message Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 263
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop

"break" is possible only in "repeat", "while"

_________________
smaller is better
Post 09 Feb 2018, 08:41
View user's profile Send private message Reply with quote
fabbel



Joined: 30 Oct 2012
Posts: 9

i see.. really too bad.. is there any alternative way to replicates sthg roughly simililar a while / end while loop at preprocessing stage ?
e.G. use case :
1/build a list of values using a symbolic constant, redefining it several time
(multiple EQU's / DEFINEs)
2/ lookup a particular value in that list
=>easy to iterate thru the values using irpv till i find the searched item,
but then how can i exit the loop once the value is found ?
i am forced to iterate anyway till the end of the list....
Post 09 Feb 2018, 14:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15734
Location: Crossing the Cauchy horizon


fabbel wrote:
i am forced to iterate anyway till the end of the list....

I would think for what you want you need to set some variable to say "found", and ignore future iterations based upon that variable. And, yes, the preprocessor would continue to iterate through the remaining values because there is not any method to stop it, aside from halting assembly completely with an error condition.

The preprocessor only runs once, unlike the assembler, so if list is very large you might notice some slowdown.
Post 09 Feb 2018, 17:04
View user's profile Send private message Visit poster's website Reply with quote
fabbel



Joined: 30 Oct 2012
Posts: 9

indeed, i had devised this workaround (i.e. set some variable to say "found", and ignore future iterations based upon that variable)... but that just looks a bit silly to me. Would such feature be so tricky to add to fasm preprocessor ? i am having a hard time understanding why it would make less sense to have it in preprocessing stage loop constructs, while it was seen very sensible and implemented for assembly time loop constructs .. and after all, that looks very much like a very basic feature of any kind of automated processing...
Post 09 Feb 2018, 17:22
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 611

Does a macro that remain input help if "break" change it into an empty one
Post 03 Apr 2018, 03:06
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15734
Location: Crossing the Cauchy horizon


l4m2 wrote:
Does a macro that remain input help if "break" change it into an empty one

I don't understand your query. Can you post an example of what you mean?
Post 03 Apr 2018, 04:29
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


Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.