flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > Fasm 1.73 How do in one EQU many EQU ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 476
Code:
        regstr EQU EBP
        z1 EQU [regstr+4]
        z2 EQU [regstr+8]
        z3 EQU [regstr+12]
        zg EQU  mov eax,z1
        zz EQU  add eax,ebx
        zh EQU  mov z2,eax
        zk EQU  mov z3,eax
    


I want do:
Code:
apply EQU zg,zz,zh
;And write in some place of code
apply
    


How do this ?
I think about macro but apply EQU can be changed dynamically.
For example:
Code:
apply EQU zg,zz,zh
;And write in some place of code
apply
....
applyB EQU apply,zk
;And write in some place of code
applyB
....
apply EQU zg,zz,zz,zh,zg,zk
;And write in some place of code
apply
    

Its gives interesting practical things.
Post 21 Jan 2019, 17:48
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7300
Location: Kraków, Poland
I'm not sure if I understood what you mean, but here is something that comes to my mind:
Code:
template.regstr EQU EBP
template.z1 EQU [template.regstr+4]
template.z2 EQU [template.regstr+8]
template.z3 EQU [template.regstr+12]
template.zg EQU  mov eax,template.z1
template.zz EQU  add eax,ebx
template.zh EQU  mov template.z2,eax
template.zk EQU  mov template.z3,eax

macro apply [v] {
       define  __applied v
       v equ template.#v
}

macro end.apply {
       irpv v,__applied \{
                restore v
                restore __applied
       \}
}


apply zg,zz,zh
        zz
end.apply

apply zk
        zk
end.apply    
Post 22 Jan 2019, 08:41
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
All ways i need do this in code ?
apply zg,zz,zh
zz
end.apply

Need in code write simple apply. And not allways write:
apply zg,zz,zh
zz
end.apply

Because more then 40 EQUs.
Some:
apply namenewmacro,zg,zz,zh
zz
end.apply
in code simple write namenewmacro.
Code:
;create new macro. Lets say macroPut
apply macroPut,zg,zz,zh
        zz
end.apply
;create macro Put2
apply Put2
    zg,zz,zz,zh      
end.apply
;And in code write
macroPut
Put2
    
Post 22 Jan 2019, 09:07
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
Tomasz i try in code:
Code:
 
mydata dd 1,2,3,4,5
template.regstr EQU EBP
template.z1 EQU [template.regstr+4]
template.z2 EQU [template.regstr+8]
template.z3 EQU [template.regstr+12]
template.zg EQU  mov eax,template.z1
template.zz EQU  add eax,ebx
template.zh EQU  mov template.z2,eax
template.zk EQU  mov template.z3,eax

mov template.regstr,mydata ;mov ebp,mydata
apply zg,zh        
end.apply                       ;as I expected must change mydata dd 1,2,2,4,5
    

And after i print mydata. And get 1,2,3,4,5 but not 1,2,2,4,5
Post 22 Jan 2019, 09:44
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7300
Location: Kraków, Poland
OK, then I most certainly misunderstood what you were trying to do. Can you explain it in more detail?
Post 22 Jan 2019, 10:27
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 476
Tomasz Grysztar you write me:
Code:
template.regstr EQU EBP
template.z1 EQU [template.regstr+4]
template.z2 EQU [template.regstr+8]
template.z3 EQU [template.regstr+12]
template.zg EQU  mov eax,template.z1
template.zz EQU  add eax,ebx
template.zh EQU  mov template.z2,eax
template.zk EQU  mov template.z3,eax

macro apply [v] {
       define  __applied v
       v equ template.#v
}

macro end.apply {
       irpv v,__applied \{
                restore v
                restore __applied
       \}
}


apply zg,zz,zh
        zz
end.apply

apply zk
        zk
end.apply
    

My question. What must do macro apply and end.apply ?
How did its works ? And how right using this macro ?

I write in my code:
Code:
mov template.regstr,zyt
        apply regstr,zg,zh
        end.apply
    

Then i look in IDA Pro 7 asm code. And see only mov ebp,zyt
But not see code from macro apply.
Post 23 Jan 2019, 06:15
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 1421
Roman wrote:
I want do:
Code:
apply EQU zg,zz,zh
;And write in some place of code
apply
    


How do this ?
I think about macro but apply EQU can be changed dynamically.
For example:
Code:
apply EQU zg,zz,zh
;And write in some place of code
apply
....
applyB EQU apply,zk
;And write in some place of code
applyB
....
apply EQU zg,zz,zz,zh,zg,zk
;And write in some place of code
apply
    

Its gives interesting practical things.
Just purge the macro and re-define it:
Code:
macro apply
{
  zg
  zz
  zh
}
;And write in some place of code
apply
....
macro applyB
{
  apply
  zk
}
;And write in some place of code
applyB
....
purge apply
macro apply
{
  zg
  zz
  zz
  zh
  zg
  zk
}
;And write in some place of code
apply    
Post 23 Jan 2019, 21:36
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-2019, Tomasz Grysztar.

Powered by rwasa.