flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > why...

Author
Thread Post new topic Reply to topic
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 01 Aug 2005, 01:33
Why it's work?
Code:
macro irp p,[plist]
{
common ..c = 0
reverse
  ..c = ..c+1
  p equ plist
}

macro foo plist
{
local .p
    irp .p,plist    
     display .p+0x30
     restore .p    
     display .p+0x30
     restore .p
     display .p+0x30
}
foo <3,5,9>    

and it's can't
Code:
macro irp p,[plist]
{
common ..c = 0
reverse
  ..c = ..c+1
  p equ plist
}

macro foo plist
{
local .p
    irp .p,plist
    repeat ..c
      display .p+0x30
      restore .p
    end repeat
}
foo <3,5,9>    
Post 01 Aug 2005, 01:33
View user's profile Send private message Reply with quote
Ancient One



Joined: 28 Feb 2005
Posts: 55
Ancient One 01 Aug 2005, 01:45
repeat cannot be use to repeat preprocessor directive. use rept instead
Post 01 Aug 2005, 01:45
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 01 Aug 2005, 08:47
"repeat" is one of the control directives, that are processed after the preprocessing is already finished (you can read about it in the manual!). The preprocessor itself does only operations on the text symbols, and - as opposed to assembler - doesn't do any calculations. So you should do it rather this way:
Code:
macro irp p,[plist]
{
  reverse
   p equ plist
}

macro foo [plist]
{
  common
    local .p
    irp .p,plist
  forward
    display .p+0x30
    restore .p
}

foo 3,5,9    
Post 01 Aug 2005, 08:47
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 01 Aug 2005, 09:26
Thanks and sorry for my not very accurate question. Embarassed

My tasm program use this macro:
Code:
subm macro plist,subparam
     irp p,<plist>
       sub p,subparam
     endm
endm
.code 
 ...
  subm <[var1],[var2],[var3]>,constant    
and i decided to create a such(repeating first param.) for my fasm programs - not like:
Code:
macro subm subparam,[plist]{sub plist,subparam}    
I tryed and blocked to the first post example Confused macro irp work fine, but I dont know how to continue.


Last edited by Nikolay Petrov on 01 Aug 2005, 09:44; edited 2 times in total
Post 01 Aug 2005, 09:26
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 01 Aug 2005, 09:42
Why not like the "subm" sample? It does exactly what you need.
What you request looks, however, like the recently discussed FOR directive: http://board.flatassembler.net/topic.php?t=3823&postdays=0&postorder=asc&start=25#28033
(IRP was an old name for FOR in MASM).
Post 01 Aug 2005, 09:42
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 01 Aug 2005, 11:15
The discusion is interesting for me at this moment. Smile
Post 01 Aug 2005, 11:15
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 01 Aug 2005, 15:07
I find a solution for my problem. It was under my eays.
Code:
macro subp subparam,[params]
{sub params,subparam}

macro subm params,subparam
{subp subparam,params}
.code 
... 
 subm <eax,ebx,ecx>,edx
...    
will be compile
Code:
sub eax,edx
sub ebx,edx
sub ecx,edx    

To make it better - must checking params for it's type, equates and nonsenses.
Thanks again
Post 01 Aug 2005, 15:07
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8376
Location: Kraków, Poland
Tomasz Grysztar 01 Aug 2005, 15:25
Oh, that was what was troubling you - I'm sorry, I did not understand what really your problem was. And you wanted just to convert the single parameter into multiple parameters (exactly what your solution does).

Anyway, I have just implemented the IRP in fasm, check out the 1.63.5 release when I upload it.
Post 01 Aug 2005, 15:25
View user's profile Send private message Visit poster's website Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 01 Aug 2005, 15:54
great
Post 01 Aug 2005, 15:54
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.