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: 57
sts-q 10 Feb 2020, 14:33
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: 20430
Location: In your JS exploiting you and your system
revolution 10 Feb 2020, 15:20
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: 57
sts-q 10 Feb 2020, 20:01
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: 20430
Location: In your JS exploiting you and your system
revolution 10 Feb 2020, 20:09
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: 57
sts-q 11 Feb 2020, 04:49
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.