flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > repeat and "already defined"

Author
Thread Post new topic Reply to topic
omega_red



Joined: 13 Mar 2004
Posts: 19
Location: Poland
omega_red
I have a macro:
Code:
macro timing INNER_LOOP_COUNT
{
...
@@:
   times INNER_LOOP_COUNT          add     eax, ebx
    loop    @b
...
}    


Then, in main program I'm using this:
Code:
repeat 16
   timing %
end repeat    

to make 16 blocks with incrementing INNER_LOOP_COUNT. However, it gives me an error:
Code:
C:\asm\test.asm [51]:
    timing %
C:\asm\test.asm [17] timing [9]:
@@:
error: symbol already defined.
    

Well, @@ is supposed to be anonymous label? How to do it properly without manually 'unrolling' repeat construction?

_________________
Vulnerant omnes, ultima necat
Post 28 Nov 2004, 18:47
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Code:
macro timing INNER_LOOP_COUNT
{
...
local a     ; a is a local label
label a    ; this is where it's used 
        times INNER_LOOP_COUNT          add     eax, ebx
        loop    a    ; loop to a
...
}    


Try that and see if it works. @@: probably doesn't work within macros.
Post 28 Nov 2004, 20:08
View user's profile Send private message Visit poster's website Reply with quote
omega_red



Joined: 13 Mar 2004
Posts: 19
Location: Poland
omega_red
Code:
label outer_loop
error: symbol already defined.    


Weird...
Post 28 Nov 2004, 21:24
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Maybe doing this:

Code:
macro timing INNER_LOOP_COUNT
{
...
local a     ; a is a local label
a:           ; this is where it's used 
        times INNER_LOOP_COUNT          add     eax, ebx
        loop    a    ; loop to a
...
}    


would work?
Post 28 Nov 2004, 21:58
View user's profile Send private message Visit poster's website Reply with quote
omega_red



Joined: 13 Mar 2004
Posts: 19
Location: Poland
omega_red
I've tried it earlier - with the same result..
Post 29 Nov 2004, 01:32
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
Code:
macro timing INNER_LOOP_COUNT
{
local a 
a:
        times INNER_LOOP_COUNT          add     eax, ebx
        loop    a
}


main:
  timing 22
  timing 23
ret    


That compiles without fail for me. Can you paste more of the code that's causing the problem?
Post 29 Nov 2004, 02:09
View user's profile Send private message Visit poster's website Reply with quote
omega_red



Joined: 13 Mar 2004
Posts: 19
Location: Poland
omega_red
Yeah, thats exactly ok. But this fail:
Code:
main: 
repeat 2
  timing %
end repeat
ret    
Post 29 Nov 2004, 11:03
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
What does the % imply?
Post 29 Nov 2004, 11:06
View user's profile Send private message Visit poster's website Reply with quote
omega_red



Joined: 13 Mar 2004
Posts: 19
Location: Poland
omega_red
Quote:
Second is "%", which is the number of current repeat in parts of code
that are repeated using some special directives (see 2.2).

My goal is to shorten
Code:
 timing  1
   timing  2
   timing  3
   timing  4
   timing  5
   timing  6
   timing  7
   timing  8
   ...    

with repeat construction. Maybe there is another way to do it?

_________________
Vulnerant omnes, ultima necat
Post 29 Nov 2004, 13:36
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
vid
try this:
Code:
local here
here = $          ;not "here:", because that way it cannot be redefined
times SOME_CONSTANT add eax,ebx
loop here
    


If it won't work, than you can hardcode lenght of jump:
Code:
times SOME_CONSTANT add eax,ebx
loop $-(SOMECONSTANT*2) ;i quess size of "add eax,ebx" is 2, easy to hceck
    
Post 29 Nov 2004, 15:02
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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-2019, Tomasz Grysztar.

Powered by rwasa.