flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [SOLVED]auto count in macro ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1791
Roman 31 Aug 2024, 20:15
fasmw 1.73
Code:
macro ode_ name,pr=0 { invoke name
      mov [eqToData+_nxt_*4],eax
      ;nn equ _nxt_
      match h,_nxt_ \{ _#name\#\h equ eqToData+h*4  \}
     
      if pr = 2
         display _nxt_+48
      end if
      _nxt_ equ _nxt_+1      
      } 
;in code
pData dd 20 dup(0)

eqToData equ pData                ;set out [pData],eax
        _nxt_ equ 0 

ode_ dGeomTriMeshDataCreate,2          ;this ok
mov eax,[_dGeomTriMeshDataCreate0] ;this ok
        ode_ dGeomTriMeshDataCreate,2  ;but this fasm error !    
mov eax,[_dGeomTriMeshDataCreate1]
    

Error: pData+0*4+1 equ pData+0+1*4


Last edited by Roman on 01 Sep 2024, 02:45; edited 1 time in total
Post 31 Aug 2024, 20:15
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4036
Location: vpcmpistri
bitRAKE 31 Aug 2024, 22:11
Don't you need to use that trick - to do math in the preprocessing stage?
Code:
      rept 1 h:_nxt_ \{ _#name\#\h equ eqToData+\h*4 \}    
... you don't want the text of _nxt_, but its value.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 31 Aug 2024, 22:11
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 01 Sep 2024, 01:06
The problem is "_nxt_ equ _nxt_+1".

You get _nxt_ with the text "8+1+1+1+1+1". equ doesn't do arithmetic, it only appends +1 each time.

Use rept.
Code:
rept 1 x:_nxt_+1 { _nxt_ equ x }    
Post 01 Sep 2024, 01:06
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.