flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > an ask for irp,irps

Author
Thread Post new topic Reply to topic
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body
maybe it will be usefull, if inside irp(irps) there will be a value to check number of current circle.
like % in while.
Code:
irp value,a,a1,b,b2,c,c3,d,d4,e,e5,f,f6,g,g7,h,h8
        {
           if ~ defined a__
             a__ = 0
           end if
           if a__ = 0
             mov eax,[work.#value]
             a__ = 1
           else
             add [Hashes.#value],eax
             a__ = 0
           end if
        }    

in this code i try to know if the parametr is divide to 2 or not. With help of % it will be more compact and readeble.
Post 26 Mar 2006, 13:32
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
It still can be more compact anyway:
Code:
irp value,a,a1,b,b2,c,c3,d,d4,e,e5,f,f6,g,g7,h,h8
        {  common a__ = 0
           forward a__ = a__ + 1
           if a__ mod 2
             add [Hashes.#value],eax
           else
             mov eax,[work.#value]
           end if
        }    
Post 26 Mar 2006, 14:23
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
is that documented? I can't find were the documentation says that I can use "common" and "forward" in an IRP.

Anyway, good feature Very Happy
Post 26 Mar 2006, 15:02
View user's profile Send private message Reply with quote
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body
thanks Tomasz!
maybe it will be useful to add it to document.(common in irp)
Post 26 Mar 2006, 17:13
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
Remember that REPT, IRP, IRPS and even MATCH are simply a special kinds of macros.

Manual, section 2.3.5 wrote:
The rept directive is a special kind of macroinstruction (...)
The repetition mechanism applied to rept blocks is the same as the one used to process multiple groups of arguments for macroinstructions, so directives like forward, common and reverse can be used in their usual meaning. (...)
The blocks defined by the irp and irps directives are also processed in the same way as any macroinstructions, so operators and directives specific to macroinstructions may be freely used also in this case.


See also the (well, not finished yet) "Intantaneous macroinstructions" section in the Understanding fasm article.
Post 26 Mar 2006, 17:16
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Embarassed With the iczelion's multithreading tutorial this is the second time that I don't see what I'm looking for. I need to buy eyeglasses...

Sorry Embarassed
Post 26 Mar 2006, 17:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
Actually perhaps the best would be to use the regular macro instead of IRP here:
Code:
macro _t [value,value1]
        {
           mov eax,[work.#value]
           add [Hashes.#value1],eax
        }

_t a,a1,b,b2,c,c3,d,d4,e,e5,f,f6,g,g7,h,h8    

IRP itself is in some way redundant directive, I provided it more for the completness that real need.
Post 28 Mar 2006, 18:04
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
But does that works fine when the amount of parameters is not even?
Post 28 Mar 2006, 20:45
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7802
Location: Kraków, Poland
Tomasz Grysztar
The last pair of "value,value1" then has an empty value of "value1", just like when you define macro that takes two parameters but provide only one. To make preprocessor complain when the count of parameters is not even, do it like:
Code:
macro _t [value*,value1*]    
Post 28 Mar 2006, 21:31
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.