flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to iterate through each character in symbol

Author
Thread Post new topic Reply to topic
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
OK, so I'm the wierd guy with new directives Smile

I actually ran into a problem with a little macro, I want to be able to iterate through a symbol.. get each character in the symbol separately. Like:

Code:
define _symbol cso    


and iterate trough each character in this symbol, like:

Code:
irpc x, _symbol
{
  match =c, x \{ ... \}
  match =s, x \{ ... \}
  ; or anything else, using x as character
}    


First iteration will be x=c, second x=s and third x=o.. something like irps, but iterates through a given symbol's characters.

If this is possible via macro it will be great, but I can't find a way to do it.
I know a new directive will not be a good idea, but...
Post 10 Jan 2006, 19:04
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
tell whole problem, new directives really are not needed.
Post 10 Jan 2006, 19:43
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
It's not really a program, but a macro... it accepts a parameter which are some 'flag' characters (at least for now, just playin' around a bit):

Code:
flg cso    


will give some information to another macro (that one has no problemo Wink ) for the carry flag, the sign flag and the overflow flag...

I know, using another syntax:

Code:
flg c s o    


will work with irps but I might want to make 'advanced' use of this technique maybe sometime later. (and the second syntax is a bit unclear, if you ask me)

The main reason is because you can also do:

Code:
flg sco    


which does the same thing.

If this irpc or whatever works without new directive (via macro or whatever) it would be great.


another example would be that I posted:

Code:
ah equ a h
al equ a l
...    


sure, Tomasz posted a new way for that macro (thanks again Smile), but this split might still be useful in other macros (mainly syntax-oriented macros Very Happy ). Sure I don't need that split right now, but it may be useful.


Thanks.. any reply appreciated Very Happy
Post 10 Jan 2006, 19:51
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7718
Location: Kraków, Poland
Tomasz Grysztar
But do you need it at preprocessing time? Maybe the assembler mechanism would be enough?
Code:
macro flg x
{
  virtual at 0
   db `x
   repeat $
    load c byte from %-1
    if c = 'c'
     display 'CF',13,10
    else if c = 's'
     display 'SF',13,10
    else if c = 'o'
     display 'OF',13,10
    end if
   end repeat
  end virtual
}    
Post 10 Jan 2006, 20:06
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Maybe, I can't say for sure.. this macro is just a toy now, so i can't be sure.. I think I'll need a bit in preprocessor (if I can't find a way 'till then Smile).

Interesting macro you posted.. Didn't know virtual can be so powerful. I understand it better now. Wink

Just wanted to know if this can be done in preprocessor with current directives. dunno, maybe some macros? It's mainly some syntax-adjustment



Thanks
Post 10 Jan 2006, 20:12
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
cannot be done with current preprocessor (only in theory), there is no way to alter preprocessor's symbols right now. Symbol is entity for preprocessor.
Post 10 Jan 2006, 21:31
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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-2020, Tomasz Grysztar.

Powered by rwasa.