flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Dynamic formation label and macro

Author
Thread Post new topic Reply to topic
xubej



Joined: 12 Oct 2015
Posts: 2
xubej 12 Oct 2015, 08:11
Hi all.

There is:
Code:
lab_1:
    mov eax, 1
lab_2:
    mov eax, 2    


Then i do so:
Code:
macro jmp a { jmp lab_#a }

rept 10 c { jmp 1 + c mod 2 }    


Comes:
Image

and be:
Image

What am i doing wrong?
Post 12 Oct 2015, 08:11
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19488
Location: In your JS exploiting you and your system
revolution 12 Oct 2015, 08:15
To do arithmetic with macro arguments you need to use rept:
Code:
lab_1:
    mov eax, 1
lab_2:
    mov eax, 2

macro jmp a { jmp lab_#a }

rept 10 c {
        rept 1 v:1 + c mod 2 \{jmp v\}
}    
Post 12 Oct 2015, 08:15
View user's profile Send private message Visit poster's website Reply with quote
xubej



Joined: 12 Oct 2015
Posts: 2
xubej 12 Oct 2015, 08:19
Thank you very much!
Post 12 Oct 2015, 08:19
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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.