flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > generate a symbol

Author
Thread Post new topic Reply to topic
sts-q



Joined: 29 Nov 2018
Posts: 30
sts-q
In fasm, how can i generate a symbol like:

sym_1 sym_2 sym_3 .... sym_n

count = count + 1
sym_#count
current_symbol equ sym_#count

In other words, is there a way to convert a number to string?
Or is there an other way to create new, unique symbols?

regards
Confused
Post 10 Feb 2020, 14:33
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: 17011
Location: In your JS exploiting you and your system
revolution
Use the rept.
Code:
rept 50 x:1 {
  label sym1_#x at x*4
  sym2_#x: mov eax,[sym1_#x]
}
mov ebx,[sym1_15]
mov ebx,[sym2_37]    
Post 10 Feb 2020, 15:20
View user's profile Send private message Visit poster's website Reply with quote
sts-q



Joined: 29 Nov 2018
Posts: 30
sts-q
It works,
... but not for me, because counter-variable x gets not replaced when i use it inside an other macro.

Code:
macro m {
    rept 1 x:0 \{  mysym equ sym_#x  \}
mysym:
}

it creates
   sym_x:
and not 
   sym_0:
    


Rolling Eyes
Post 10 Feb 2020, 20:01
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: 17011
Location: In your JS exploiting you and your system
revolution
You need to escape the # also.
Code:
macro m {
    rept 1 x:0 \{  mysym equ sym_\#x  \}
mysym:
}    
Post 10 Feb 2020, 20:09
View user's profile Send private message Visit poster's website Reply with quote
sts-q



Joined: 29 Nov 2018
Posts: 30
sts-q
Very Happy Very Happy

Thank you!
Post 11 Feb 2020, 04:49
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar.

Powered by rwasa.