flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macro label how do ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 03 Jan 2021, 18:25
Code:
lb_cnt EQU 0
macro mlbCount {
      ;if ~ defined lb_cnt
      ;  lb_cnt = 0
      ;end if
   .lb_cnt:
        lb_cnt EQU lb_cnt+1
      } 

In code:
mlbCount 
mlbCount
mlbCount
    

fasm get error: '.lb_cnt: symbol already defined'

I expected this:
.0:
.1:
.2:
Post 03 Jan 2021, 18:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 04 Jan 2021, 13:19
Use REPT to convert numeric value to decimal token that can be used to form the name:
Code:
lb_cnt EQU 0
macro mlbCount {
  rept 1 this:lb_cnt, next:lb_cnt+1 \{

   .\#this:
        lb_cnt EQU next
      \} }    
Post 04 Jan 2021, 13:19
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 04 Jan 2021, 13:32
Thanks
Post 04 Jan 2021, 13:32
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.