flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [solved]macro how get next equ register ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1791
Roman 14 Dec 2023, 09:58
Code:
forRegs_1 equ eax
forRegs_2 equ ecx
forRegs_3 equ edx
forRegs_4 equ [esi]
macro for num {
      match  _forNxtEq,_forNxtEq \{     
      mov forRegs_\#_forNxtEq,num      
      _forNxtEq equ  _forNxtEq+1      
      \}      
      } 
_forNxtEq equ  1
          for2 10
          for2 20
          for2 30
    

I get all mov eax
But expected
mov eax,10
mov ecx,20
mov edx,30


Last edited by Roman on 14 Dec 2023, 10:25; edited 1 time in total
Post 14 Dec 2023, 09:58
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20333
Location: In your JS exploiting you and your system
revolution 14 Dec 2023, 10:02
Code:
_forNxtEq =      
You can't use = with the preprocessor. Try with equ

Another problem is this "_forNxtEq equ _forNxtEq+1". The preprocessor doesn't compute results with equ, all it does is keep appending "+1" to the end. Try with rept instead.
Post 14 Dec 2023, 10:02
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: 20333
Location: In your JS exploiting you and your system
revolution 14 Dec 2023, 10:15
To illustrate the effect of using + with equ, see this:
Code:
a equ 1
a equ a+1
a equ a+1
a equ a+1
a equ a+1
a equ a+1

match A,a {
        irps x,A \{
                display \`x
        \}
}    
Code:
~ fasm test.asm 
flat assembler  version 1.73.31  (16384 kilobytes memory)
1+1+1+1+1+1
1 passes, 0 bytes.    
Post 14 Dec 2023, 10:15
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1791
Roman 14 Dec 2023, 10:16
Thanks.
Rept help me.
Post 14 Dec 2023, 10:16
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.