flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > nested rept counter -- bug or feature?

Author
Thread Post new topic Reply to topic
RIxRIpt



Joined: 18 Apr 2013
Posts: 50
RIxRIpt
Code:
rept 3 num1 {
        rept 3 num2 \{
                display `num1, '  ', `num2, 13, 10
        \}
}
    

Output:
Code:
flat assembler  version 1.71.21  (1048576 kilobytes memory)
1  num2
1  num2
1  num2
2  num2
2  num2
2  num2
3  num2
3  num2
3  num2
1 passes, 0 bytes.
    

Shouldn't num2 be replaced with a number?

As a result the following macro doesn't compile:
Code:
rept 3 num1 {
        rept 3 num2 \{
                if num2 + 1 = num1
                        .L#num1:
                        db num1 dup '0' + num1
                        .sizeof.L#num1 = $ - .L#num1
                        display 'Next size: ', '0' + .sizeof.L#num2, 13, 10
                end if
        \}
}
    

I find it the only way how to access label that will be defined in the next rept iteration (for ex. .sizeof.L#num2). Is there any other way?

_________________
Привет =3
Admins, please activate my account "RIscRIpt"
Post 26 Jul 2014, 08:32
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: 17279
Location: In your JS exploiting you and your system
revolution
Firstly remove the backticks (`).

Secondly when using the concatenation operator (#) you need to escape it with a backslash (\) to the proper level:
Code:
.L\#num2:    
Post 26 Jul 2014, 08:48
View user's profile Send private message Visit poster's website Reply with quote
RIxRIpt



Joined: 18 Apr 2013
Posts: 50
RIxRIpt
revolution wrote:
Firstly remove the backticks (`).

Secondly when using the concatenation operator (#) you need to escape it with a backslash (\) to the proper level:
Code:
.L\#num2:    


Thank you.
Removing backticks (`) wasn't required. Escaping inner iterator helped.
The following code works fine for me
Code:
rept 4 j {
        rept 3 i \{
                if i + 1 = j
                        display \`i, '  ', `j, 13, 10
                        display '0' + i, '  ', '0' + j, 13, 10
                        
                        .L\#i:
                        db i dup '0' + i
                        .sizeof.L\#i = $ - .L\#i
                        
                        display 'Curr size: ', '0' + .sizeof.L\#i, 13, 10
                        if j < 4
                                display 'Next size: ', '0' + .sizeof.L#j, 13, 10
                        end if
                end if
        \}
}
    

Output:
Code:
flat assembler  version 1.71.21  (1048576 kilobytes memory)
1  2
1  2
Curr size: 1
Next size: 2
2  3
2  3
Curr size: 2
Next size: 3
3  4
3  4
Curr size: 3
2 passes, 6 bytes.
    


But is there any other way to access the label that is defined in the next rept iteration?

_________________
Привет =3
Admins, please activate my account "RIscRIpt"
Post 26 Jul 2014, 09:59
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. Also on YouTube, Twitter.

Website powered by rwasa.