flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macro and % how using ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 11 Apr 2023, 13:29
Fasmw 1.73
I know repeat and while and times using % as counter.
But how using % in macro or in match ?
Code:
macro oo [c] {
      forward
      mov al,c
;macro see % but not incremented %
;or how set % = 7 ?
     mov ah,%  ;how inc value in % ? Always %=0
      } 

oo  5,5,5 
;IDA Pro show asm out
mov al,5
mov ah,0
mov al,5
mov ah,0
mov al,5
mov ah,0

;I think this
mov al,5
mov ah,1
mov al,5
mov ah,2
mov al,5
mov ah,3
    
Post 11 Apr 2023, 13:29
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 921
Location: Russia
macomics 11 Apr 2023, 14:04
What does % (cycle counter) and match or macro have to do with it?
Post 11 Apr 2023, 14:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20210
Location: In your JS exploiting you and your system
revolution 11 Apr 2023, 14:12
% is an assembler variable.

The preprocessor doesn't process it at all.
Post 11 Apr 2023, 14:12
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: 20210
Location: In your JS exploiting you and your system
revolution 11 Apr 2023, 14:13
To use % you need an assembler loop:
Code:
while % <= 6
  display % + '0'
end while    
Post 11 Apr 2023, 14:13
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 11 Apr 2023, 14:28
Sad.
After while % <= 6 end while %=0
Not %=6
Post 11 Apr 2023, 14:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20210
Location: In your JS exploiting you and your system
revolution 11 Apr 2023, 15:06
You can use that to know if your code is inside a loop. Since % is 1 based the only time you see 0 is outside a loop.
Code:
if % = 0
  display 'I am not inside a loop', 13, 10
else
  display 'I am inside a loop. Do you see me multiple times?', 13, 10
end if    
Post 11 Apr 2023, 15:06
View user's profile Send private message Visit poster's website Reply with quote
Hrstka



Joined: 05 May 2008
Posts: 55
Location: Czech republic
Hrstka 11 Apr 2023, 15:15
What about this?
Code:
macro oo [c] {
  common
    local v
    v = 0
  forward
    v = v + 1
    mov al,c
    mov ah,v
}    
Post 11 Apr 2023, 15:15
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1718
Roman 11 Apr 2023, 15:23
Hrstka
This variant I know.
Post 11 Apr 2023, 15:23
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.