flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [Solved] Macroinstruction argument in label?

Author
Thread Post new topic Reply to topic
ticamai



Joined: 25 Jun 2014
Posts: 2
ticamai 25 Jun 2014, 01:55
I'm essentially trying to do the following:

Code:
macro specialprocedure label, flags=0 {
    labeldef equ label
    section '.rodata' data readable
    proc_labeldef: ;The 'labeldef' here needs to be replaced
    db 0xA1
    db flags
labeldef: ;This works properly - labeldef is replaced with what is passed to the macro.
    section '.text' code readable executable
    ;code follows
}

specialprocedure do_the_thing, 0
    xchg eax, eax ;do some super important work!
    ret

_main:
    mov ax, [proc_do_the_thing]
    push ax
    call do_the_thing
    ret
    

I can't figure out how to replace only part of the label name with what I pass to the macro as an argument. In GAS, for example, the macro would look like this:
Code:
.macro specialprocedure label, flags=0
    .rodata
    .globl proc_\label
proc_label:
    .byte 0xA1
    .byte flags
    .globl \label
label:
    section '.text' code readable executable
    ;code follows
.endm
    

Is this possible in FASM? Doing the same as I would in GAS, it ends up placing, for example, 'proc_ do_the_thing:' on the line. Notice the extra space, which causes it not to compile.
Post 25 Jun 2014, 01:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20413
Location: In your JS exploiting you and your system
revolution 25 Jun 2014, 02:06
Use the hash (#):
Code:
proc_#labeldef: ;The 'labeldef' here needs to be replaced    
Post 25 Jun 2014, 02:06
View user's profile Send private message Visit poster's website Reply with quote
ticamai



Joined: 25 Jun 2014
Posts: 2
ticamai 25 Jun 2014, 02:10
revolution, that's exactly what I was looking for. Only now that you mentioned that do I see it in the documentation. Thanks a ton!
Post 25 Jun 2014, 02:10
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.