flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > How to define lists of labels/variables?

Author
Thread Post new topic Reply to topic
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 11 Jan 2005, 10:34
I recently wanted to abreviate something like
Code:
;This is a simplified example
 Lab0:
 Lab1:
 Lab2:
 Lab3:
 Lab4:
 Lab5:
 Lab6:
 Lab7:
 Lab8:
 Lab9:
    

into
Code:
repeat        10
 Tmp= %-1 + "0"
 Lab#Tmp:
end repeat
    

but unfortunately the second variant doesn't work.
Has anyone an idea how to do this?

_________________
MCD - the inevitable return of the Mad Computer Doggy

-||__/
.|+-~
.|| ||
Post 11 Jan 2005, 10:34
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 11 Jan 2005, 11:22
What you actually want to achieve? (you can't simply define such labels arrays)
Post 11 Jan 2005, 11:22
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 11 Jan 2005, 11:33
I actually have to repeat a piece of code, but the code is slightly different in each repeat; so I use the % a lot. Furthermore, I must define labels like those stated above.

_________________
MCD - the inevitable return of the Mad Computer Doggy

-||__/
.|+-~
.|| ||
Post 11 Jan 2005, 11:33
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 11 Jan 2005, 11:45
MCD wrote:
I actually have to repeat a piece of code, but the code is slightly different in each repeat; so I use the % a lot. Furthermore, I must define labels like those stated above.


You can't, because all the labels are defined during preprocessing while the repeat directive is executed during assembling when all labels are already defined.

Try using @@: label with @f and @b references instead. (edit: No, you can't inside "repeat" because of the same reason...) Also, you can try to create the loop in the preprocessing stage, where you still can define labels: some macro with needed count of arguments and your code defined in "forward" section - inside the macroses you can use local labels as well.



Regards.
Post 11 Jan 2005, 11:45
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 11 Jan 2005, 11:49
Quote:

You can't, because all the labels are defined during preprocessing while the repeat directive is executed during assembling when all labels are already defined.
This is as far as I knew it too. Isn't there another solution except using those difficult to maintain @f and @@ stuff?
Post 11 Jan 2005, 11:49
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 15 Jan 2005, 22:08
Some discussion about similar problem: http://board.flatassembler.net/topic.php?t=1111
Post 15 Jan 2005, 22:08
View user's profile Send private message Visit poster's website Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 17 Jan 2005, 17:28
thanks, Privalov
Post 17 Jan 2005, 17:28
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode 21 Jul 2008, 16:16
Is this a solution ?
...
Code:
rept 10 mylabel {
     label L#mylabel                 ; create L1 bis L10
         nop
         nop
 }
              
    display_decimal L1      ;4202496
            display 13,10
       display_decimal L2      ;4202498
            display 13,10                           
    display_decimal L3      ;4202500
            display 13,10
       display_decimal L4      ;4202502
            display 13,10
               nop
         nop
         nop
         nop
         nop
 ;----------And....when you need one of them
 ;----------use it after redefinition with equ
       ;----------because they ar label.
   foo:
    L4 equ foo
  display_decimal L4      ;4202521
    ret
    

...
Gruß
hopcode[mrk]
Post 21 Jul 2008, 16:16
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8358
Location: Kraków, Poland
Tomasz Grysztar 21 Jul 2008, 17:13
This is a very old thread - the REPT directive was not available at the time (it was introduced in version 1.62, 16 June 2005).
Post 21 Jul 2008, 17:13
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.