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: 1251
Roman
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: 18846
Location: In your JS exploiting you and your system
revolution
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: 8028
Location: Kraków, Poland
Tomasz Grysztar
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: 1251
Roman
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: 1251
Roman
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: 652
Location: Russia
macomics
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:    


Description: hexdump -C test0.txt > test0.doc
Download
Filename: test0.doc
Filesize: 558 Bytes
Downloaded: 35 Time(s)

Description: result: fasm -m 102400 ./test0.asm
flat assembler version 1.73.30 (102400 kilobytes memory)
2 passes, 108 bytes.

Download
Filename: test0.txt
Filesize: 108 Bytes
Downloaded: 31 Time(s)

Post 22 Jun 2022, 12:48
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1251
Roman
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.