flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Nested macro problem: T nop, <T cli, sti>

Author
Thread Post new topic Reply to topic
Devel99



Joined: 26 Oct 2015
Posts: 30
Devel99 12 Nov 2015, 00:42
does anyone know how make that compilable?

I have T macto with two arguments. Both args are asm commands:

Code:
macro T op1, op2
{
  op1
  op2
}

T clc, cld
T nop, <T cli, sti>
    


the first macro compiled correctly but the last one fails with "Illegal instruction: T cli,sti"

if I add T2 clone macro all is ok. What do you think is the problem with nested macro?

Code:
macro T op1, op2
{
  op1
  op2
}
macro T2 op1, op2
{
  op1
  op2
}
T clc, cld
T nop, <T2 cli, sti>
    


thanks in advance
Post 12 Nov 2015, 00:42
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20343
Location: In your JS exploiting you and your system
revolution 12 Nov 2015, 00:58
You can't have a macro call itself. But you can make another macro of the same name and call that:
Code:
macro T op1, op2
{
  op1
  op2
}

macro T op1, op2
{
  op1
  op2
}

T clc, cld
T nop, <T cli, sti>    
And there is another way also. You can make a new macro inside the macro which allows for infinite nesting:
Code:
macro make_T {
        macro T op1, op2 \{
                make_T
                op1
                op2
                purge T
        \}
}make_T

T clc, cld
T nop, <T cli, <T int3, <mov eax,ebx>>>    
Post 12 Nov 2015, 00:58
View user's profile Send private message Visit poster's website Reply with quote
Devel99



Joined: 26 Oct 2015
Posts: 30
Devel99 12 Nov 2015, 02:17
revolution damn that's awesome! you're the best macro engineer ever

T <T <T iret, db 0xCC>, cld>, <T cli, <T int3, <mov eax,ebx>>> Very Happy Very Happy

yay thanks a lot, you rock! Wink
Post 12 Nov 2015, 02:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20343
Location: In your JS exploiting you and your system
revolution 12 Nov 2015, 02:28
You don't need to limit yourself to two opcodes.
Code:
macro make_T {
        macro T [ops] \{
            \common
                make_T
            \forward
                ops
            \common
                purge T
        \}
}make_T

T clc
T iret, cld, int3, inc eax, stosb, jmp $
T nop, <T cli, <T int3, <mov eax,ebx>, <T cmpsb, <T retn, <aam>,<T db 1, db 2>>>>>    
Post 12 Nov 2015, 02:28
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: 20343
Location: In your JS exploiting you and your system
revolution 12 Nov 2015, 02:35
Devel99 wrote:
revolution damn that's awesome! you're the best macro engineer ever
No, this idea comes from the win32ax.inc include that Tomasz made. See the macro 'allow_nesting'.
Post 12 Nov 2015, 02:35
View user's profile Send private message Visit poster's website Reply with quote
Devel99



Joined: 26 Oct 2015
Posts: 30
Devel99 12 Nov 2015, 03:14
yeah, but my program's logic implicates using only two macro parameters where each one is an argument in two-operand instruction like add x1, x2 )) Cool
Post 12 Nov 2015, 03:14
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 674
l4m2 09 Dec 2015, 01:48
Code:
rept 1 {mov ax, 3 } mov bx, 2       
Post 09 Dec 2015, 01:48
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.