flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [content deleted]

Author
Thread Post new topic Reply to topic
asmcoder



Joined: 02 Jun 2008
Posts: 784
asmcoder
[content deleted]


Last edited by asmcoder on 14 Aug 2009, 14:49; edited 1 time in total
Post 06 Jul 2009, 20:00
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Don't use @@
Code:
@@:
.1:
jmp @b    

_________________
Previously known as The_Grey_Beast
Post 06 Jul 2009, 20:10
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7795
Location: Kraków, Poland
Tomasz Grysztar
Post 06 Jul 2009, 20:18
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Cool! With the new rept trick you can even use something like "@b5" Smile

_________________
Previously known as The_Grey_Beast
Post 06 Jul 2009, 23:30
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7795
Location: Kraków, Poland
Tomasz Grysztar
Well, this can be done even with the old "rept" only:
Code:
; this should work with older versions of fasm, too

rept 10 i:0 { @f#i equ ..@@#i }
@@max equ 9

macro @@ dummy
{
  @f0:
  rept 9 i:0,j:1
  \{
    reverse @b\#j equ @b\#i
    common @b0 equ @f0
    forward @f\#i equ @f\#j
  \}
  match max,@@max \{ rept 2 i:max \\{ @@max equ i \\}  \}
  match max,@@max \{ @f9 equ ..@@\#max \}
}

@f fix @f0
@b fix @b0    

But with new improved "rept" it can be cleaned up a little:
Code:
; this does the same in a bit cleaner way, using the new REPT capabilities

rept 10 i:0 { @f#i equ ..@@#i }
@@max equ 9

macro @@ dummy
{
  @f0:
  rept 9 i:0,j:1
  \{
    reverse @b\#j equ @b\#i
    common @b0 equ @f0
    forward @f\#i equ @f\#j
  \}
  rept 1 i:@@max+1
  \{
     @@max equ i
     @f9 equ ..@@\#i
  \}
}

@f fix @f0
@b fix @b0    

Usage like:
Code:
jmp @f ; goes to (A)
jmp @f1 ; goes to (B)
@@: ; (A)
@@: ; (B)
@@: ; (C)
jmp @b ; goes to (C)
jmp @b2 ; goes to (A)    
Post 07 Jul 2009, 04:25
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 GitHub, YouTube, Twitter.

Website powered by rwasa.