flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > The macro is unnamed and executed immediately. How do?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 04 Apr 2023, 10:05
Fasmw 1.73
In some cases usefull have macro without name, like match or irps.

For generate asm code from another program.
Code:
mov edx, buffer1
;this code generate my script language. 
macro_ p1=esi, p2=ebx, out=edx {
inc byte [p1] 
mov al, [p2] 
add al, [p1] 
mov [out], al
} 
    
Post 04 Apr 2023, 10:05
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 04 Apr 2023, 10:29
You can use MATCH like this:
Code:
match p1:p2:p3, esi:ebx:edx {
inc byte [p1]
mov al, [p2]
add al, [p1]
mov [p3], al
}    
or, playing with syntax a little bit:
Code:
match p2+p1 -> p3, esi+ebx -> edx {
inc byte [p1]
mov al, [p2]
add al, [p1]
mov [p3], al
}    
Post 04 Apr 2023, 10:29
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 04 Apr 2023, 10:32
Thanks.
How I sayed weird match Smile
Post 04 Apr 2023, 10:32
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 04 Apr 2023, 11:29
Problem with include file.
Code:
;code in file ingen.txt
mov al,[p1]     ;fasm error undefined symbol p1
add al,[p2]     ;fasm error undefined symbol p2
mov [pout],al   ;fasm error undefined symbol pout


;code in main.asm 
pupz equ edx,ecx,edi
match p1=, p2=, pout , pupz {  
      include 'ingen.txt'      
      } 
    
Post 04 Apr 2023, 11:29
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 04 Apr 2023, 12:06
That wouldn't work with regular macro either.
Post 04 Apr 2023, 12:06
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 04 Apr 2023, 12:45
Only way is include file must contains match ?
And no exist any others variants fix this ?
Post 04 Apr 2023, 12:45
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 04 Apr 2023, 12:48
Code:
p1 equ edx
p2 equ ecx
p3 equ edi
include 'ingen.txt'
restore p1, p2, p3    
Post 04 Apr 2023, 12:48
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 04 Apr 2023, 12:52
Sometimes its not convenient to use.
Code:
p1 equ edx ;because its in main.asm
p2 equ ecx ;and I must personal write\rewrite\comment hands,
p3 equ edi  ;new equs.

;if my generator put in ingen.txt new p4 or p5.
;I must write or comment in main.asm new equs
include 'ingen.txt' 
restore p1, p2, p3     


Best way this is all equs and matchs contains in file 'ingen.txt'
Post 04 Apr 2023, 12:52
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1766
Roman 04 Apr 2023, 19:31
Possible do this for match ?
Code:
kk equ p1=, p2=, pout    ;i want equ using for match. But this not work
pp equ edx,ecx,edi       ;this work.

match kk  , pp {  
      mov al,[p1]   ;fasm error undefined p1
      add al,[p2]    
      mov [pout+1],al
      }    


O ! fix work !
kk fix p1=, p2=, pout
Post 04 Apr 2023, 19:31
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.