flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > REQUEST: iterate over characters of symbol/literate.

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 26 Jan 2010, 05:33
Presently, neither the preprocessor nor assembler is able to iterate over strings:
Code:
irpc c,"ABCDEF" { }
irpc c,symbol { }    
...each iteration c would take on the values "A","B","C",... in the first line.

Why? It would simplify some code/listing generation macros. Symbols are composed of byte array - why not have access to this array? Prior to 1.69.00 the preprocessor strictly operated on symbols, but now can do calculations. Hopefully, this has opened the door for another small addition - no interpretation of bytes should be made by FASM (ex. multi-byte codings).

In a not so ubiquitous manner, it is possible to iterate over a string with the assembler using the VIRTUAL + LOAD control directives, but another method might be desirable here as well (FORC?).

MASM has IRPC and FORC directives in this capacity.

(An alternate naming of IRPB/FORB would explicitly state byte processing - not characters.)

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 26 Jan 2010, 05:33
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20422
Location: In your JS exploiting you and your system
revolution 26 Jan 2010, 05:52
It may help to convince Tomasz if you can provide an example of where this is beneficial.
Post 26 Jan 2010, 05:52
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 26 Jan 2010, 10:23
I already know that IRPC would be a nice addition, and I wanted to add it the same time as IRPS, but there are few decisions I had a trouble with, and since it wasn't a high priority addition, I suspended it.
For example, how should it behave, when fed multiple symbols after the comma - should it signalize an error, or just iterate over characters of the consecutive symbols? People with MASM background may expect "irpc c,2 +1" to iterate space as well, but with fasm it's impossible. To avoid confusion, perhaps error would be a better thing to do - and thus force using IRPS and IRPC in combination for such cases?
Post 26 Jan 2010, 10:23
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4060
Location: vpcmpistri
bitRAKE 26 Jan 2010, 18:17
Current FASM symbolic handling should be respected: to iterate over space would require quotes or <>. Multiple symbols imply concatenation (yeah, kind of confusing).

Edit: I'm wrong about IRPS respecting <>:
Code:
irps x,<s0 s1 s2 s3> {
 display `x
}    
Code:
<s0s1s2s3>    
Post 26 Jan 2010, 18:17
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.