flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > problem with rept inside macro

Author
Thread Post new topic Reply to topic
daluca



Joined: 05 Nov 2005
Posts: 86
daluca 05 Feb 2007, 17:37
Hi: I want a macro to create a variable number of buffers,all of the same
size,one after the other and labeled sequentialy stating with 'buffer'

so i make this macro:
Code:
macro makebuffers   number,size      {

           rept number n { buffer#n  rb size   \}
            
                                                       }


    


so when i want to create 10 buffers of 40 bytes each i do:

Code:

makebuffers 10,40

    


but the asembler give the error : symbol already defined

instruction: buffern rb 40

so it looks like the counter symbol n is replaced literally and not with
the counter value

how can i solve this? thanks.
Post 05 Feb 2007, 17:37
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 05 Feb 2007, 17:59
Code:
macro makeBuffers number, size
{
  rept number n \{buffer\#n rb size\}
}
    

Or
Code:
macro makeBuffers baseName, number, size
{
  rept number n \{baseName\#n rb size\}
}    

So you can choose diferents names

PS: Your problem was that you forgot to escape the #
Post 05 Feb 2007, 17:59
View user's profile Send private message Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
daluca 05 Feb 2007, 18:52
Thank you LocoDelAssembly
but I didn`t forgot is more like i didn't knew

do i have to scape every single symbol
tha i use inside a macro tha is inside another macro?

i don't understand this escaping mechanism very well.

thanks again.
Post 05 Feb 2007, 18:52
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 05 Feb 2007, 19:06
http://flatassembler.net/docs.php?article=ufasm

Read the "Macroinstructions" part which has a great demostration about escaping.
Post 05 Feb 2007, 19:06
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.