flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to display macro parameter

Author
Thread Post new topic Reply to topic
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 03 Sep 2023, 10:56
Code:
macro x i*&
{
  display `i
}

i mov ax,bx    
This will be precessed as display 'mov' ax,bx.
How to display it correctly?
Post 03 Sep 2023, 10:56
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 03 Sep 2023, 12:52
You need to iterate over the arguments.

Try using irps in the x macro and put display inside irps.
Post 03 Sep 2023, 12:52
View user's profile Send private message Visit poster's website Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 03 Sep 2023, 17:36
revolution wrote:
Try using irps in the x macro and put display inside irps.
The best I found to do is:
Code:
macro displ s& {
    display `s#' '
}

macro x i*&
{
  irps a, i \{
    displ a
  \}
}

x mov eax, [ebx+5]    
But this displays mov eax , [ ebx + 5 ] or moveax,[ebx+5] (if remove #' ')
Both look strange Sad

Can I improve it somehow?
Post 03 Sep 2023, 17:36
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1823
Roman 03 Sep 2023, 20:53
And ignoring command mov eax, [ebx+5]

Very interesting what is mean i*& in macro x ?
Post 03 Sep 2023, 20:53
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 03 Sep 2023, 22:45
Jin X wrote:
Can I improve it somehow?
Yes. You can eliminate the secondary macro.
Code:
macro x i& {
        irps a, i \{
                display \`a \# ' '
        \}
}

x mov eax, [ebx+5]    
Post 03 Sep 2023, 22:45
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1823
Roman 04 Sep 2023, 09:49
I try this but not work.
Code:
macro x i*& {  irps a, i \{
      if \`a = ' '
      display \`a \# ' '
      end if
      display \`a 
      \} } 
x mov eax,10
    


I get text moveax,10.
But i want get text mov eax,10

Fasm it is more magic than logic Smile
Post 04 Sep 2023, 09:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20423
Location: In your JS exploiting you and your system
revolution 04 Sep 2023, 11:08
It might make it more clear what irps does if you try this
Code:
macro x i& {
        irps a, i \{
                display '{',\`a,'}',13,10
        \}
}    
Note that no spaces are produced by irps.
Post 04 Sep 2023, 11:08
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1823
Roman 04 Sep 2023, 11:42
I do this !
Code:
macro x i*& {  irps a, i \{
      if \`a = ':'
      display  ' '
     else
      display \`a
      end if
     
      \} }
;in code
x mov:eax,:[ebx+5]

    

I get text: mov eax, [ebx+5]
Post 04 Sep 2023, 11:42
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1823
Roman 04 Sep 2023, 11:49
Idea !
Some fasm extra commands like irps, must have user setup parameters !
For flexible using irps !

For example
Code:
irps.p1:':'   ;This mean irps ignored symbol ':'

irps.p2:' '   ;this mean irps not ignored spaces, and perceives space as a separate element

;Or this
irps.ignr:':'
irps.sep:' '
    
Post 04 Sep 2023, 11:49
View user's profile Send private message Reply with quote
Jin X



Joined: 06 Mar 2004
Posts: 133
Location: Russia
Jin X 04 Sep 2023, 15:12
As a solution. This displays only instruction name
Code:
macro x i*&
{
  match a b,i+ \{
    display \`a
  \}
}

x mov eax, [ebx+5]    

P.S. Roman, RTFM for * and & Wink
Post 04 Sep 2023, 15:12
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.