flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > problem with < in macro. How fix this ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 22 Jun 2022, 09:19
Fasmw 1.73
Code:
macro jif ar1,ar2,mtk {
     match =+X, ar1 \{ inc X
                       jifR equ X\}
     match =-X, ar1 \{ dec X
                       jifR equ X\}
     match =>X, ar2 \{ cmp jifR,X
                       ja mtk \}
     match =<X, ar2 \{ cmp jifR,X
                       jb mtk \}
     match =~X, ar2 \{ cmp jifR,X
                       jnz mtk \}
     match ==X, ar2 \{ cmp jifR,X
                       jz mtk \}
      } 
;in code 
  jif -edx,<11,.lb1  ;fasm get error invalid macro argument because < 
    
Post 22 Jun 2022, 09:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 22 Jun 2022, 09:23
Escape it with a backslash.
Code:
  jif -edx,\<11,.lb1    
Post 22 Jun 2022, 09:23
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 22 Jun 2022, 09:40
You can use fasmg-like greedy argument and then MATCH to cut the things yourself:
Code:
macro jif agrs&  {
     match ar1=,ar2=,mtk, args \{    
Post 22 Jun 2022, 09:40
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 22 Jun 2022, 12:38
revolution wrote:
Escape it with a backslash.
Code:
  jif -edx,\<11,.lb1    

Compile but no jb asm instruction. macro jif failed
Only ebx.
Post 22 Jun 2022, 12:38
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 22 Jun 2022, 12:40
Quote:

macro jif agrs& {
match ar1=,ar2=,mtk, args \{

And how this help ?
For this
Code:
jif  +ebx,<10,.lb1 ;Because fasm used this < and macro failed
    
Post 22 Jun 2022, 12:40
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1040
Location: Russia
macomics 22 Jun 2022, 12:48
Code:
format binary as "txt"

macro jif args& { restore jifR
  match ar1=,ar2=,mtk, args \{
     match =+X, ar1 \\{ inc X
                       jifR equ X\\}
     match =-X, ar1 \\{ dec X
                       jifR equ X\\}
     match =jifR, jifR \\{ jifR equ ar1 \\}
     match =>X, ar2 \\{ cmp jifR,X
                       ja mtk \\}
     match =<X, ar2 \\{ cmp jifR,X
                       jb mtk \\}
     match =~X, ar2 \\{ cmp jifR,X
                       jnz mtk \\}
     match ==X, ar2 \\{ cmp jifR,X
                       jz mtk \\}
 \} }
use32
test0:  jif ebx,<10,.lb1 ; <- works fine
        nop
        nop
        nop
.lb1:   jif +ebx,<10,.lb2 ; <- works fine
        nop
        nop
        nop
.lb2:   jif -ebx,<10,.lb3 ; <- works fine
        nop
        nop
        nop
.lb3:   jif ebx,>10,.lb4 ; <- works fine
        nop
        nop
        nop
.lb4:   jif +ebx,>10,.lb5 ; <- works fine
        nop
        nop
        nop
.lb5:   jif -ebx,>10,.lb6 ; <- works fine
        nop
        nop
        nop
.lb6:
use64
test1:  jif ebx,<10,.lb1 ; <- works fine
        nop
        nop
        nop
.lb1:   jif +ebx,<10,.lb2 ; <- works fine
        nop
        nop
        nop
.lb2:   jif -ebx,<10,.lb3 ; <- works fine
        nop
        nop
        nop
.lb3:   jif ebx,>10,.lb4 ; <- works fine
        nop
        nop
        nop
.lb4:   jif +ebx,>10,.lb5 ; <- works fine
        nop
        nop
        nop
.lb5:   jif -ebx,>10,.lb6 ; <- works fine
        nop
        nop
        nop
.lb6:    


Last edited by macomics on 13 Nov 2024, 20:44; edited 1 time in total
Post 22 Jun 2022, 12:48
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1847
Roman 22 Jun 2022, 14:40
Big thanks.
Good job !
All work fine.
Post 22 Jun 2022, 14:40
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.