flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
ProMiNick 30 Nov 2019, 17:30
for that reason exist eqtype
look at example I workaround of ability of push(pop) to get reg sequence or usual operand: Code: ; Macroinstructions for defining and calling procedures include 'proc32.inc' espFixer=0 macro parameters [arg] { common local argsize,localbytes,espPos,..retaddr virtual at 0 ..retaddr dd ? define retaddr ..retaddr+esp+espFixer define localbase ..retaddr+esp+espFixer-localbytes if ~arg eq forward local ..arg ..arg dd ? define arg ..arg+esp+espFixer common end if argsize = $-4 end virtual espPos = 0 macro locals \{ \local espPosInner espPosInner = espPos virtual at espPosInner macro label def \\{ match . type,def> \\\{ esplocal@proc .,label,<type \\\} \\} struc db [val] \\{ \\common esplocal@proc .,db,val \\} struc du [val] \\{ \\common esplocal@proc .,du,val \\} struc dw [val] \\{ \\common esplocal@proc .,dw,val \\} struc dp [val] \\{ \\common esplocal@proc .,dp,val \\} struc dd [val] \\{ \\common esplocal@proc .,dd,val \\} struc dt [val] \\{ \\common esplocal@proc .,dt,val \\} struc dq [val] \\{ \\common esplocal@proc .,dq,val \\} struc rb cnt \\{ esplocal@proc .,rb cnt, \\} struc rw cnt \\{ esplocal@proc .,rw cnt, \\} struc rp cnt \\{ esplocal@proc .,rp cnt, \\} struc rd cnt \\{ esplocal@proc .,rd cnt, \\} struc rt cnt \\{ esplocal@proc .,rt cnt, \\} struc rq cnt \\{ esplocal@proc .,rq cnt, \\} \} macro endl \{ purge label restruc db,du,dw,dp,dd,dt,dq restruc rb,rw,rp,rd,rt,rq espPos = espPos+(($-$$+3) and (not 3)) end virtual \} macro endp \{ localbytes = espPos match any,arg \\{ forward restore arg common \\} restore retaddr,localbase purge endp,push,pushd,pop,sub,add,invoke,cominvk,comcall,stdcall,ret,locals,endl match all,all@vars \\{ restore all \\} restore all@vars espFixer=0 \} macro pushd [arg1] \{ \common \local ..tmp \forward ..tmp = espFixer pushd arg1 espFixer =..tmp+4 \} macro push [arg1] \{ \common \local ..tmp \forward if (arg1 eqtype [0]) | (arg1 eqtype byte[0]) | (arg1 eqtype eax) | (arg1 eqtype 0) ..tmp = espFixer push arg1 espFixer =..tmp+4 else irps ..arg1, arg1 \\{ ..tmp = espFixer push ..arg1 espFixer =..tmp+4 \\} end if \} macro pop [arg1] \{ \common \local ..tmp \forward if (arg1 eqtype [0]) | (arg1 eqtype byte[0]) | (arg1 eqtype eax) | (arg1 eqtype 0) ..tmp = espFixer pop arg1 espFixer =..tmp-4 else irps ..arg1, arg1 \\{ ..tmp = espFixer pop ..arg1 espFixer =..tmp-4 \\} end if \} macro sub arg1,arg2 \{ sub arg1,arg2 match =esp,arg1 \\{ espFixer =espFixer+arg2 \\} \} macro add arg1,arg2 \{ add arg1,arg2 match =esp,arg1 \\{ espFixer =espFixer-arg2 \\} \} macro invoke proc,[arg1] \{ \common \local ..tmp ..tmp = espFixer invoke proc,arg1 espFixer =..tmp \} macro invoks proc,[arg1] \{ \common if ~ arg1 eq \reverse if ~ arg1 eq stack pushd arg1 end if \common end if call dword [proc] \forward if ~ arg1 eq espFixer =espFixer-4 end if \} macro cominvk object,proc,[arg1] \{ \common \local ..tmp ..tmp = espFixer cominvk object,proc,arg1 espFixer =..tmp \} macro comcall handle,interface,proc,[arg1] \{ \common \local ..tmp ..tmp = espFixer comcall handle,interface,proc,arg1 espFixer =..tmp \} macro stdcall proc,[arg1] \{ \common \local ..tmp ..tmp = espFixer stdcall proc,arg1 espFixer =..tmp \} macro ret arg1:argsize \{ if localbytes add esp, localbytes end if ret arg1 \} if localbytes sub esp, localbytes end if } macro esplocal@proc name,def,[val] { common name def val } macro esplocal@proc name,def,[val] { common match vars, all@vars \{ all@vars equ all@vars, \} all@vars equ all@vars name local ..var ..var def val define name ..var} macro procedure definition& { match (args),definition \{ parameters args \} match (),definition \{ parameters \} } macro prepare dummy,[arg] { common if ~ arg eq reverse pushd arg common end if } macro unstack dummy,[arg] { common local counter if ~ arg eq counter = 0 forward counter = counter + 1 common add esp, counter*4 end if } there is more eqtype '' eqtype 1f eqtype dword 1f but there is no expression solving before eqtype compare: ebx-ebx+4 eqtype 0 will return false. eax+eax eqtype eax*2 will return false too |
|||
![]() |
|
maxas70912 30 Nov 2019, 20:00
Thank you very much, your answer helped a lot
Quote:
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.