flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Please help to find solution of 1 bug in macro

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 802
Location: Russian Federation, Sochi
ProMiNick 27 May 2016, 08:22
Code:
format binary as "txt"
use32    
Code:
macro db_Hex bits,value
{   repeat bits/4
        d = '0' + value shr (bits-%*4) and 0Fh 
        if d > '9' 
            d = d + 'A'-'9'-1 
        end if 
        db d
      end repeat }
    
Code:
macro instr [opcode]
{ common
  local size,addr
    addr:
    db_Hex 32,addr
    db ':',9
  virtual at 0
    opcode
    size:
    db 16-$ dup (0)
    load opcd qword from 0 ; there`s a problem too - what to do with 16-byte instructions
  end virtual
    repeat size*2
        d = '0' + opcd shr (((%+1)/2-1)*8+4*(% mod 2)) and 0Fh  ;(n-1,n,n-3,n-2,...(7Cool(56)(34)(12)
        if d > '9'                               ;
            d = d + 'A'-'9'-1 
        end if 
        db d
        if ~% mod 2
         db " "
        end if
    end repeat
    repeat size*8
        d = '0' + opcd shr (((%+7)/8)*8-((% mod 8))) and 01h  ;(n-1,n,n-3,n-2,...(7Cool(56)(34)(12)
        db d
        if ~% mod 8
         db " "
        end if
    end repeat
    db 9
    irps a,opcode \{
    db \`a," "
    \}
  db 0Dh,0Ah
  org addr+size
} 
    
Code:
org 000030DBh
instr lodsb
instr lodsw
instr lodsd
;instr mov     edi,edi
;instr push    ebp
;instr mov     ebp, esp
;instr push    ebx
;instr mov     ebx, [ebp+8]
;instr push    esi
;instr mov     esi, [ebp+0Ch]
;instr test    esi, esi     


in output file we have
Code:
000030DB:       AC 10101100     lodsb 
000030DC:       66 AD 01100111 10101100         lodsw 
000030DE:       AD 10101100     lodsd    

as we see
there `s bitmask not corresponds to hex:
AC=10101100, but 66!=01100111 and AD!=10101100
I`m understand that error is stubid. but...
...Thanks for help
Post 27 May 2016, 08:22
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20413
Location: In your JS exploiting you and your system
revolution 27 May 2016, 08:49
When using 'repeat' the value for % begins at 1, not 0.
Code:
repeat 8
  display %+'0'
end repeat    
Output:
Code:
12345678    
Post 27 May 2016, 08:49
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 802
Location: Russian Federation, Sochi
ProMiNick 27 May 2016, 09:46
Code:
macro instr [opcode]
{ common 
  local size,addr 
    addr: 
    db_Hex 32,addr 
    db ':',9 
  virtual at 0 
    opcode 
    size: 
    db 16-$ dup (0) 
    load opcd qword from 0 ; there`s a problem too - what to do with 16-byte instructions 
  end virtual 
    repeat size*2 
        d = '0' + opcd shr (((%+1)/2-1)*8+4*(% mod 2)) and 0Fh  
        if d > '9'                              
            d = d + 'A'-'9'-1  
        end if
        db d 
        if ~% mod 2 
         db " " 
        end if 
    end repeat
    db 9
    repeat size*8 
        d = '0' + opcd shr (((%-1)/8)*8+((8-(% mod 8)) mod 8)) and 1 ; not elegant but works
        db d
        if ~% mod 8 
         db " " 
        end if 
    end repeat 
    db 9 
    irps a,opcode \{ 
    db \`a," " 
    \} 
  db 0Dh,0Ah 
  org addr+size 
}     


In most common case it is enough.
But how to update macro to support instructions up to 16 bytes long
Post 27 May 2016, 09:46
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20413
Location: In your JS exploiting you and your system
revolution 27 May 2016, 09:49
Use two qword loads.
Code:
load op0 from x+0
load op1 from x+8    
Post 27 May 2016, 09:49
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 27 May 2016, 10:13
ProMiNick
I'm guessing you're trying to do this. That macro needs a little fix because of a backward compatibility break introduced in one of the recent fasm versions. I'll be able to post the current version of the macro in about 10-11 hours if you're interested.

_________________
Faith is a superposition of knowledge and fallacy
Post 27 May 2016, 10:13
View user's profile Send private message Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 802
Location: Russian Federation, Sochi
ProMiNick 27 May 2016, 11:03
Thanks I_ink. I have to comment that piece
Code:
;times ((iSize/10)-1)shr 63 display ' '    

and it works with no errors.
I gues your macros should be included in official release of fasm!
Post 27 May 2016, 11:03
View user's profile Send private message Send e-mail Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 27 May 2016, 21:57
ProMiNick
Quote:
I have to comment that piece

That piece is responsible for aligning the instruction length values in case there are instructions longer than 9 bytes. So it would better stay there, just in a different form. Here is a discussion on why the backward compatibility had to be broken. Listing alignment that takes different address value lengths into account has always been deliberately omitted for simplicity.

Meanwhile I added some more little fixes and changes so here's the full set again:
Code:
;Displays a binary representation of a number
macro dispBin num*, padding, leader, trailer, size
{
    local digCount,number,lastdig
    number = size num
    lastdig = number

    if number < 0
        display '-'
        number = -(number shr 1 + number and 1)
        lastdig = -(lastdig + number + number)
    else
        number = number shr 1
        lastdig = lastdig and 1
    end if
    digCount = 0
    while number shr digCount > 0
        digCount = digCount + 1
    end while
    if ~ leader eq
        display leader
    end if
    if ~ padding eq
        if digCount < padding
            times (padding-digCount-1) : display '0'
        end if
    end if
    times digCount : display number shr (digCount-%) and 1+'0'
    display lastdig+'0'
    if ~ trailer eq
        display trailer
    end if
}

;Displays a decimal representation of a number
macro dispDec num*, padding, leader, trailer
{
    local digCount,tenPow,number,lastdig
    number = num
    lastdig = number
    
    if number < 0
        display '-'
        number = (-(number shr 1 + number and 1)) / 5
        lastdig = -(lastdig + number*5 + number*5)
    else
        number = number/10
        lastdig = lastdig mod 10
    end if
    digCount = 0
    tenPow = 1
    while tenPow <= number
        tenPow = tenPow*10
        digCount = digCount + 1
    end while
    if ~ leader eq
        display leader
    end if
    if ~ padding eq
        if digCount < padding
            times (padding-digCount-1) : display '0'
        end if
    end if
    repeat digCount
        tenPow = tenPow/10
        display number/tenPow+'0'
        number = number mod tenPow
    end repeat
    display lastdig+'0'
    if ~ trailer eq
        display trailer
    end if
}

;Displays a hexadecimal representation of a number
macro dispHex num*, padding, leader, trailer, size
{
    local digCount,dig,number,lastdig
    number = size num
    lastdig = number
    
    if number < 0
        display '-'
        number = (-(number shr 1 + number and 1)) shr 3
        lastdig = -(lastdig + number shl 3 + number shl 3)
    else
        number = number shr 4
        lastdig = lastdig and 0xF
    end if
    digCount = 0
    while number shr (digCount*4) > 0
        digCount = digCount + 1
    end while
    if ~ leader eq
        display leader
    end if
    if ~ padding eq
        if digCount < padding
            times (padding-digCount-1) : display '0'
        end if
    end if
    repeat digCount
        dig = number shr ((digCount-%)*4) and 0Fh
        if dig > 9
            dig = dig-'0'+('A'-10)
        end if
        display dig+'0'
    end repeat
    if lastdig > 9
        lastdig = lastdig-'0'+('A'-10)
    end if
    display lastdig+'0'
    if ~ trailer eq
        display trailer
    end if
}

;Displays a string with binary, decimal and hexadecimal values
;usage: mdisplay d=number,":",9,b=number,9,h=number,13,10
macro mdisplay [token]
{
    forward
        match type==n,token \{ match l =type r, + b d h bb bw bd bq hb hw hd hq + \\{ rept 0 \\\{ \\} \}
        match,\{ display token \}
        match =b==number,token \{ dispBin number,,,'b' \}
        match =d==number,token \{ dispDec number \}
        match =h==number,token \{ dispHex number,,'0x' \}
        match =bb==number,token \{ dispBin number,,,'b',byte \}
        match =bw==number,token \{ dispBin number,,,'b',word \}
        match =bd==number,token \{ dispBin number,,,'b',dword \}
        match =bq==number,token \{ dispBin number,,,'b',qword \}
        match =hb==number,token \{ dispHex number,,'0x',,byte \}
        match =hw==number,token \{ dispHex number,,'0x',,word \}
        match =hd==number,token \{ dispHex number,,'0x',,dword \}
        match =hq==number,token \{ dispHex number,,'0x',,qword \}
}

iset equ bt,in,ja,jb,jc,je,jg,jl,\
jo,jp,js,jz,or,aaa,aad,aam,\
aas,adc,add,and,bnd,bsf,bsr,btc,\
btr,bts,cbw,cdq,clc,cld,cli,cmc,\
cmp,cqo,cwd,daa,das,dec,div,fld,\
fst,hlt,inc,ins,int,jae,jbe,jge,\
jle,jmp,jna,jnb,jnc,jne,jng,jnl,\
jno,jnp,jns,jnz,jpe,jpo,lar,lds,\
lea,les,lfs,lgs,lsl,lss,ltr,mov,\
mul,neg,nop,not,out,pop,por,rcl,\
rcr,rep,ret,rol,ror,rsm,sal,sar,\
sbb,shl,shr,stc,std,sti,str,sub,\
ud2,xor,adcx,adox,andn,arpl,blci,blcs,\
blsi,blsr,bzhi,call,cdqe,clac,clgi,clts,\
clwb,cmps,cwde,dppd,dpps,emms,fabs,fadd,\
fbld,fchs,fcom,fcos,fdiv,feni,fild,fist,\
fld1,fldz,fmul,fnop,fsin,fstp,fsub,ftst,\
fxam,fxch,idiv,imul,insb,insd,insw,int1,\
int3,into,invd,iret,jcxz,jnae,jnbe,jnge,\
jnle,korb,kord,korq,korw,lahf,lgdt,lidt,\
lldt,lmsw,lock,lods,loop,movd,movq,movs,\
mulx,orpd,orps,outs,pand,pdep,pext,popa,\
popd,popf,popq,popw,push,pxor,repe,repz,\
retd,retf,retn,retq,retw,rorx,sahf,salc,\
sarx,scas,seta,setb,setc,sete,setg,setl,\
seto,setp,sets,setz,sgdt,shld,shlx,shrd,\
shrx,sidt,sldt,smsw,stac,stgi,stos,test,\
verr,verw,vpor,wait,xadd,xchg,xend,xlat,\
addpd,addps,addsd,addss,andpd,andps,bextr,blcic,\
blsic,bndcl,bndcn,bndcu,bndmk,bound,bswap,cmova,\
cmovb,cmovc,cmove,cmovg,cmovl,cmovo,cmovp,cmovs,\
cmovz,cmppd,cmpps,cmpsb,cmpsd,cmpsq,cmpss,cmpsw,\
cpuid,crc32,divpd,divps,divsd,divss,enter,extrq,\
f2xm1,faddp,fbstp,fclex,fcomi,fcomp,fdisi,fdivp,\
fdivr,femms,ffree,fiadd,ficom,fidiv,fimul,finit,\
fistp,fisub,fldcw,fldpi,fmulp,fneni,fprem,fptan,\
fsave,fsqrt,fstcw,fstsw,fsubp,fsubr,fucom,fwait,\
fyl2x,icebp,iretd,iretq,iretw,jecxz,jrcxz,kaddb,\
kaddd,kaddq,kaddw,kandb,kandd,kandq,kandw,kmovb,\
kmovd,kmovq,kmovw,knotb,knotd,knotq,knotw,kxorb,\
kxord,kxorq,kxorw,lddqu,leave,lodsb,lodsd,lodsq,\
lodsw,loopd,loope,loopq,loopw,loopz,lzcnt,maxpd,\
maxps,maxsd,maxss,minpd,minps,minsd,minss,movbe,\
movsb,movsd,movsq,movss,movsw,movsx,movzx,mulpd,\
mulps,mulsd,mulss,mwait,outsb,outsd,outsw,pabsb,\
pabsd,pabsw,paddb,paddd,paddq,paddw,pandn,pause,\
pavgb,pavgw,pf2id,pf2iw,pfacc,pfadd,pfmax,pfmin,\
pfmul,pfrcp,pfsub,pi2fd,pi2fw,popad,popaw,popfd,\
popfq,popfw,pslld,psllq,psllw,psrad,psraw,psrld,\
psrlq,psrlw,psubb,psubd,psubq,psubw,ptest,pusha,\
pushd,pushf,pushq,pushw,rcpps,rcpss,rdmsr,rdpmc,\
rdtsc,repne,repnz,retfd,retfq,retfw,retnd,retnq,\
retnw,scasb,scasd,scasq,scasw,setae,setbe,setge,\
setle,setna,setnb,setnc,setne,setng,setnl,setno,\
setnp,setns,setnz,setpe,setpo,stosb,stosd,stosq,\
stosw,subpd,subps,subsd,subss,tzcnt,tzmsk,vdppd,\
vdpps,vmovd,vmovq,vmrun,vmxon,vorpd,vorps,vpand,\
vpord,vporq,vpxor,wrmsr,xlatb,xorpd,xorps,xsave,\
xtest,aesdec,aesenc,aesimc,andnpd,andnps,blcmsk,blsmsk,\
bndldx,bndmov,bndstx,cmovae,cmovbe,cmovge,cmovle,cmovna,\
cmovnb,cmovnc,cmovne,cmovng,cmovnl,cmovno,cmovnp,cmovns,\
cmovnz,cmovpe,cmovpo,comisd,comiss,fcmovb,fcmove,fcmovu,\
fcomip,fcompp,fdivrp,ffreep,ficomp,fidivr,fisttp,fisubr,\
fldenv,fldl2e,fldl2t,fldlg2,fldln2,fnclex,fndisi,fninit,\
fnsave,fnstcw,fnstsw,fpatan,fprem1,frstor,frstpm,fsaved,\
fsavew,fscale,fsetpm,fstenv,fsubrp,fucomi,fucomp,fxsave,\
getsec,haddpd,haddps,hsubpd,hsubps,invept,invlpg,kandnb,\
kandnd,kandnq,kandnw,ktestb,ktestd,ktestq,ktestw,kxnorb,\
kxnord,kxnorq,kxnorw,lfence,llwpcb,looped,loopeq,loopew,\
loopne,loopnz,loopzd,loopzq,loopzw,lwpins,lwpval,mfence,\
movapd,movaps,movdqa,movdqu,movhpd,movhps,movlpd,movlps,\
movnti,movntq,movsxd,movupd,movups,paddsb,paddsw,pextrb,\
pextrd,pextrq,pextrw,pfnacc,pfsubr,phaddd,phaddw,phsubd,\
phsubw,pinsrb,pinsrd,pinsrq,pinsrw,pmaxsb,pmaxsd,pmaxsw,\
pmaxub,pmaxud,pmaxuw,pminsb,pminsd,pminsw,pminub,pminud,\
pminuw,pmuldq,pmulhw,pmulld,pmullw,popcnt,psadbw,pshufb,\
pshufd,pshufw,psignb,psignd,psignw,pslldq,psrldq,psubsb,\
psubsw,pswapd,pushad,pushaw,pushfd,pushfq,pushfw,rdmsrq,\
rdpkru,rdrand,rdseed,rdtscp,setalc,setnae,setnbe,setnge,\
setnle,sfence,shufpd,shufps,skinit,slwpcb,sqrtpd,sqrtps,\
sqrtsd,sqrtss,swapgs,sysret,t1mskc,vaddpd,vaddps,vaddsd,\
vaddss,vandpd,vandps,vcmppd,vcmpps,vcmpsd,vcmpss,vdivpd,\
vdivps,vdivsd,vdivss,vlddqu,vmaxpd,vmaxps,vmaxsd,vmaxss,\
vmcall,vmfunc,vminpd,vminps,vminsd,vminss,vmload,vmovsd,\
vmovss,vmread,vmsave,vmulpd,vmulps,vmulsd,vmulss,vmxoff,\
vpabsb,vpabsd,vpabsq,vpabsw,vpaddb,vpaddd,vpaddq,vpaddw,\
vpandd,vpandn,vpandq,vpavgb,vpavgw,vpcmov,vpcmpb,vpcmpd,\
vpcmpq,vpcmpw,vpcomb,vpcomd,vpcomq,vpcomw,vpermb,vpermd,\
vpermq,vpermw,vpperm,vprold,vprolq,vprord,vprorq,vprotb,\
vprotd,vprotq,vprotw,vpshab,vpshad,vpshaq,vpshaw,vpshlb,\
vpshld,vpshlq,vpshlw,vpslld,vpsllq,vpsllw,vpsrad,vpsraq,\
vpsraw,vpsrld,vpsrlq,vpsrlw,vpsubb,vpsubd,vpsubq,vpsubw,\
vptest,vpxord,vpxorq,vrcpps,vrcpss,vsubpd,vsubps,vsubsd,\
vsubss,vxorpd,vxorps,wbinvd,wrmsrq,wrpkru,xabort,xbegin,\
xgetbv,xrstor,xsetbv,blcfill,blendpd,blendps,blsfill,clflush,\
cmovnae,cmovnbe,cmovnge,cmovnle,cmpeqpd,cmpeqps,cmpeqsd,cmpeqss,\
cmplepd,cmpleps,cmplesd,cmpless,cmpltpd,cmpltps,cmpltsd,cmpltss,\
cmpxchg,fcmovbe,fcmovnb,fcmovne,fcmovnu,fdecstp,fincstp,fldenvd,\
fldenvw,fnsaved,fnsavew,fnstenv,frndint,frstord,frstorw,fsincos,\
fstenvd,fstenvw,fucomip,fucompp,fxrstor,fxtract,fyl2xp1,insertq,\
invlpga,invpcid,invvpid,ldmxcsr,loopned,loopneq,loopnew,loopnzd,\
loopnzq,loopnzw,monitor,movddup,movdq2q,movhlps,movlhps,movntdq,\
movntpd,movntps,movntsd,movntss,movq2dq,mpsadbw,paddusb,paddusw,\
palignr,pavgusb,pblendw,pcmpeqb,pcmpeqd,pcmpeqq,pcmpeqw,pcmpgtb,\
pcmpgtd,pcmpgtq,pcmpgtw,pcommit,pfcmpeq,pfcmpge,pfcmpgt,pfpnacc,\
pfrsqrt,phaddsw,phsubsw,pmaddwd,pmulhrw,pmulhuw,pmuludq,pshufhw,\
pshuflw,psubusb,psubusw,roundpd,roundps,roundsd,roundss,rsqrtps,\
rsqrtss,stmxcsr,syscall,sysexit,sysretq,ucomisd,ucomiss,vaesdec,\
vaesenc,vaesimc,valignd,valignq,vandnpd,vandnps,vcomisd,vcomiss,\
vexp2pd,vexp2ps,vfrczpd,vfrczps,vfrczsd,vfrczss,vhaddpd,vhaddps,\
vhsubpd,vhsubps,vmclear,vmmcall,vmovapd,vmovaps,vmovdqa,vmovdqu,\
vmovhpd,vmovhps,vmovlpd,vmovlps,vmovupd,vmovups,vmptrld,vmptrst,\
vmwrite,vpaddsb,vpaddsw,vpandnd,vpandnq,vpcmpub,vpcmpud,vpcmpuq,\
vpcmpuw,vpcomub,vpcomud,vpcomuq,vpcomuw,vpermpd,vpermps,vpextrb,\
vpextrd,vpextrq,vpextrw,vphaddd,vphaddw,vphsubd,vphsubw,vpinsrb,\
vpinsrd,vpinsrq,vpinsrw,vpmaxsb,vpmaxsd,vpmaxsq,vpmaxsw,vpmaxub,\
vpmaxud,vpmaxuq,vpmaxuw,vpminsb,vpminsd,vpminsq,vpminsw,vpminub,\
vpminud,vpminuq,vpminuw,vpmovdb,vpmovdw,vpmovqb,vpmovqd,vpmovqw,\
vpmovwb,vpmuldq,vpmulhw,vpmulld,vpmullq,vpmullw,vprolvd,vprolvq,\
vprorvd,vprorvq,vpsadbw,vpshufb,vpshufd,vpsignb,vpsignd,vpsignw,\
vpslldq,vpsllvd,vpsllvq,vpsllvw,vpsravd,vpsravq,vpsravw,vpsrldq,\
vpsrlvd,vpsrlvq,vpsrlvw,vpsubsb,vpsubsw,vshufpd,vshufps,vsqrtpd,\
vsqrtps,vsqrtsd,vsqrtss,vtestpd,vtestps,xsave64,addsubpd,addsubps,\
blendvpd,blendvps,cmpneqpd,cmpneqps,cmpneqsd,cmpneqss,cmpnlepd,cmpnleps,\
cmpnlesd,cmpnless,cmpnltpd,cmpnltps,cmpnltsd,cmpnltss,cmpordpd,cmpordps,\
cmpordsd,cmpordss,cvtdq2pd,cvtdq2ps,cvtpd2dq,cvtpd2pi,cvtpd2ps,cvtpi2pd,\
cvtpi2ps,cvtps2dq,cvtps2pd,cvtps2pi,cvtsd2si,cvtsd2ss,cvtsi2sd,cvtsi2ss,\
cvtss2sd,cvtss2si,fcmovnbe,fnstenvd,fnstenvw,fxsave64,insertps,kortestb,\
kortestd,kortestq,kortestw,kshiftlb,kshiftld,kshiftlq,kshiftlw,kshiftrb,\
kshiftrd,kshiftrq,kshiftrw,kunpckbw,kunpckdq,kunpckwd,maskmovq,movmskpd,\
movmskps,movntdqa,movshdup,movsldup,packssdw,packsswb,packusdw,packuswb,\
pblendvb,pfrcpit1,pfrcpit2,pfrsqit1,pmovmskb,pmovsxbd,pmovsxbq,pmovsxbw,\
pmovsxdq,pmovsxwd,pmovsxwq,pmovzxbd,pmovzxbq,pmovzxbw,pmovzxdq,pmovzxwd,\
pmovzxwq,pmulhrsw,prefetch,rdfsbase,rdgsbase,sha1msg1,sha1msg2,sysenter,\
sysexitq,unpckhpd,unpckhps,unpcklpd,unpcklps,vblendpd,vblendps,vcmpeqpd,\
vcmpeqps,vcmpeqsd,vcmpeqss,vcmpgepd,vcmpgeps,vcmpgesd,vcmpgess,vcmpgtpd,\
vcmpgtps,vcmpgtsd,vcmpgtss,vcmplepd,vcmpleps,vcmplesd,vcmpless,vcmpltpd,\
vcmpltps,vcmpltsd,vcmpltss,vfmaddpd,vfmaddps,vfmaddsd,vfmaddss,vfmsubpd,\
vfmsubps,vfmsubsd,vfmsubss,vldmxcsr,vmlaunch,vmovddup,vmovdqu8,vmovhlps,\
vmovlhps,vmovntdq,vmovntpd,vmovntps,vmpsadbw,vmresume,vpaddusb,vpaddusw,\
vpalignr,vpblendd,vpblendw,vpcmpeqb,vpcmpeqd,vpcmpeqq,vpcmpeqw,vpcmpgtb,\
vpcmpgtd,vpcmpgtq,vpcmpgtw,vpcmpleb,vpcmpled,vpcmpleq,vpcmplew,vpcmpltb,\
vpcmpltd,vpcmpltq,vpcmpltw,vpcomeqb,vpcomeqd,vpcomeqq,vpcomeqw,vpcomgeb,\
vpcomged,vpcomgeq,vpcomgew,vpcomgtb,vpcomgtd,vpcomgtq,vpcomgtw,vpcomleb,\
vpcomled,vpcomleq,vpcomlew,vpcomltb,vpcomltd,vpcomltq,vpcomltw,vpermi2b,\
vpermi2d,vpermi2q,vpermi2w,vpermt2b,vpermt2d,vpermt2q,vpermt2w,vphaddbd,\
vphaddbq,vphaddbw,vphadddq,vphaddsw,vphaddwd,vphaddwq,vphsubbw,vphsubdq,\
vphsubsw,vphsubwd,vplzcntd,vplzcntq,vpmacsdd,vpmacswd,vpmacsww,vpmaddwd,\
vpmovb2m,vpmovd2m,vpmovm2b,vpmovm2d,vpmovm2q,vpmovm2w,vpmovq2m,vpmovsdb,\
vpmovsdw,vpmovsqb,vpmovsqd,vpmovsqw,vpmovswb,vpmovw2m,vpmulhuw,vpmuludq,\
vpshufhw,vpshuflw,vpsubusb,vpsubusw,vptestmb,vptestmd,vptestmq,vptestmw,\
vrangepd,vrangeps,vrangesd,vrangess,vrcp14pd,vrcp14ps,vrcp14sd,vrcp14ss,\
vrcp28pd,vrcp28ps,vrcp28sd,vrcp28ss,vroundpd,vroundps,vroundsd,vroundss,\
vrsqrtps,vrsqrtss,vstmxcsr,vucomisd,vucomiss,vzeroall,wrfsbase,wrgsbase,\
xacquire,xrelease,xrstor64,xsaveopt,cmpxchg8b,cvttpd2dq,cvttpd2pi,cvttps2dq,\
cvttps2pi,cvttsd2si,cvttss2si,extractps,fxrstor64,pclmulqdq,pcmpestri,pcmpestrm,\
pcmpistri,pcmpistrm,pmaddubsw,prefetchw,punpckhbw,punpckhdq,punpckhwd,punpcklbw,\
punpckldq,punpcklwd,sha1nexte,sha1rnds4,vaddsubpd,vaddsubps,vblendmpd,vblendmps,\
vblendvpd,vblendvps,vcmpneqpd,vcmpneqps,vcmpneqsd,vcmpneqss,vcmpngepd,vcmpngeps,\
vcmpngesd,vcmpngess,vcmpngtpd,vcmpngtps,vcmpngtsd,vcmpngtss,vcmpnlepd,vcmpnleps,\
vcmpnlesd,vcmpnless,vcmpnltpd,vcmpnltps,vcmpnltsd,vcmpnltss,vcmpordpd,vcmpordps,\
vcmpordsd,vcmpordss,vcvtdq2pd,vcvtdq2ps,vcvtpd2dq,vcvtpd2ps,vcvtpd2qq,vcvtph2ps,\
vcvtps2dq,vcvtps2pd,vcvtps2ph,vcvtps2qq,vcvtqq2pd,vcvtqq2ps,vcvtsd2si,vcvtsd2ss,\
vcvtsi2sd,vcvtsi2ss,vcvtss2sd,vcvtss2si,vdbpsadbw,vexpandpd,vexpandps,vfnmaddpd,\
vfnmaddps,vfnmaddsd,vfnmaddss,vfnmsubpd,vfnmsubps,vfnmsubsd,vfnmsubss,vgetexppd,\
vgetexpps,vgetexpsd,vgetexpss,vinsertps,vmovdqa32,vmovdqa64,vmovdqu16,vmovdqu32,\
vmovdqu64,vmovmskpd,vmovmskps,vmovntdqa,vmovshdup,vmovsldup,vpackssdw,vpacksswb,\
vpackusdw,vpackuswb,vpblendmb,vpblendmd,vpblendmq,vpblendmw,vpblendvb,vpcmpleub,\
vpcmpleud,vpcmpleuq,vpcmpleuw,vpcmpltub,vpcmpltud,vpcmpltuq,vpcmpltuw,vpcmpneqb,\
vpcmpneqd,vpcmpneqq,vpcmpneqw,vpcmpnleb,vpcmpnled,vpcmpnleq,vpcmpnlew,vpcmpnltb,\
vpcmpnltd,vpcmpnltq,vpcmpnltw,vpcomequb,vpcomequd,vpcomequq,vpcomequw,vpcomgeub,\
vpcomgeud,vpcomgeuq,vpcomgeuw,vpcomgtub,vpcomgtud,vpcomgtuq,vpcomgtuw,vpcomleub,\
vpcomleud,vpcomleuq,vpcomleuw,vpcomltub,vpcomltud,vpcomltuq,vpcomltuw,vpcomneqb,\
vpcomneqd,vpcomneqq,vpcomneqw,vpermi2pd,vpermi2ps,vpermilpd,vpermilps,vpermt2pd,\
vpermt2ps,vpexpandd,vpexpandq,vphaddubd,vphaddubq,vphaddubw,vphaddudq,vphadduwd,\
vphadduwq,vpmacsdqh,vpmacsdql,vpmacssdd,vpmacsswd,vpmacssww,vpmadcswd,vpmovmskb,\
vpmovsxbd,vpmovsxbq,vpmovsxbw,vpmovsxdq,vpmovsxwd,vpmovsxwq,vpmovusdb,vpmovusdw,\
vpmovusqb,vpmovusqd,vpmovusqw,vpmovuswb,vpmovzxbd,vpmovzxbq,vpmovzxbw,vpmovzxdq,\
vpmovzxwd,vpmovzxwq,vpmulhrsw,vptestnmb,vptestnmd,vptestnmq,vptestnmw,vreducepd,\
vreduceps,vreducesd,vreducess,vscalefpd,vscalefps,vscalefsd,vscalefss,vunpckhpd,\
vunpckhps,vunpcklpd,vunpcklps,aesdeclast,aesenclast,clflushopt,cmpunordpd,cmpunordps,\
cmpunordsd,cmpunordss,cmpxchg16b,loadall286,loadall386,maskmovdqu,phminposuw,prefetcht0,\
prefetcht1,prefetcht2,punpckhqdq,punpcklqdq,sha256msg1,sha256msg2,vcmptruepd,vcmptrueps,\
vcmptruesd,vcmptruess,vcvtpd2udq,vcvtpd2uqq,vcvtps2udq,vcvtps2uqq,vcvtsd2usi,vcvtss2usi,\
vcvttpd2dq,vcvttpd2qq,vcvttps2dq,vcvttps2qq,vcvttsd2si,vcvttss2si,vcvtudq2pd,vcvtudq2ps,\
vcvtuqq2pd,vcvtuqq2ps,vcvtusi2sd,vcvtusi2ss,vextractps,vfpclasspd,vfpclassps,vfpclasssd,\
vfpclassss,vgatherdpd,vgatherdps,vgatherqpd,vgatherqps,vgetmantpd,vgetmantps,vgetmantsd,\
vgetmantss,vmaskmovpd,vmaskmovps,vpclmulqdq,vpcmpestri,vpcmpestrm,vpcmpistri,vpcmpistrm,\
vpcmpnequb,vpcmpnequd,vpcmpnequq,vpcmpnequw,vpcmpnleub,vpcmpnleud,vpcmpnleuq,vpcmpnleuw,\
vpcmpnltub,vpcmpnltud,vpcmpnltuq,vpcmpnltuw,vpcomnequb,vpcomnequd,vpcomnequq,vpcomnequw,\
vpcomtrueb,vpcomtrued,vpcomtrueq,vpcomtruew,vperm2f128,vperm2i128,vpermil2pd,vpermil2ps,\
vpgatherdd,vpgatherdq,vpgatherqd,vpgatherqq,vpmacssdqh,vpmacssdql,vpmadcsswd,vpmaddubsw,\
vpmaskmovd,vpmaskmovq,vpternlogd,vpternlogq,vpunpckhbw,vpunpckhdq,vpunpckhwd,vpunpcklbw,\
vpunpckldq,vpunpcklwd,vrsqrt14pd,vrsqrt14ps,vrsqrt14sd,vrsqrt14ss,vrsqrt28pd,vrsqrt28ps,\
vrsqrt28sd,vrsqrt28ss,vshuff32x4,vshuff64x2,vshufi32x4,vshufi64x2,vzeroupper,xsaveopt64,\
pclmulhqhdq,pclmullqhdq,prefetchnta,prefetchwt1,sha256rnds2,vaesdeclast,vaesenclast,vcmpeq_ospd,\
vcmpeq_osps,vcmpeq_ossd,vcmpeq_osss,vcmpeq_uqpd,vcmpeq_uqps,vcmpeq_uqsd,vcmpeq_uqss,vcmpeq_uspd,\
vcmpeq_usps,vcmpeq_ussd,vcmpeq_usss,vcmpfalsepd,vcmpfalseps,vcmpfalsesd,vcmpfalsess,vcmpge_oqpd,\
vcmpge_oqps,vcmpge_oqsd,vcmpge_oqss,vcmpgt_oqpd,vcmpgt_oqps,vcmpgt_oqsd,vcmpgt_oqss,vcmple_oqpd,\
vcmple_oqps,vcmple_oqsd,vcmple_oqss,vcmplt_oqpd,vcmplt_oqps,vcmplt_oqsd,vcmplt_oqss,vcmpord_spd,\
vcmpord_sps,vcmpord_ssd,vcmpord_sss,vcmpunordpd,vcmpunordps,vcmpunordsd,vcmpunordss,vcompresspd,\
vcompressps,vcvttpd2udq,vcvttpd2uqq,vcvttps2udq,vcvttps2uqq,vcvttsd2usi,vcvttss2usi,vfixupimmpd,\
vfixupimmps,vfixupimmsd,vfixupimmss,vfmadd132pd,vfmadd132ps,vfmadd132sd,vfmadd132ss,vfmadd213pd,\
vfmadd213ps,vfmadd213sd,vfmadd213ss,vfmadd231pd,vfmadd231ps,vfmadd231sd,vfmadd231ss,vfmaddsubpd,\
vfmaddsubps,vfmsub132pd,vfmsub132ps,vfmsub132sd,vfmsub132ss,vfmsub213pd,vfmsub213ps,vfmsub213sd,\
vfmsub213ss,vfmsub231pd,vfmsub231ps,vfmsub231sd,vfmsub231ss,vfmsubaddpd,vfmsubaddps,vinsertf128,\
vinserti128,vmaskmovdqu,vpcomfalseb,vpcomfalsed,vpcomfalseq,vpcomfalsew,vpcompressd,vpcompressq,\
vpcomtrueub,vpcomtrueud,vpcomtrueuq,vpcomtrueuw,vpconflictd,vpconflictq,vphminposuw,vpmadd52huq,\
vpmadd52luq,vpscatterdd,vpscatterdq,vpscatterqd,vpscatterqq,vpunpckhqdq,vpunpcklqdq,vrndscalepd,\
vrndscaleps,vrndscalesd,vrndscaless,vscatterdpd,vscatterdps,vscatterqpd,vscatterqps,pclmulhqhqdq,\
pclmulhqlqdq,pclmullqhqdq,pclmullqlqdq,vbroadcastsd,vbroadcastss,vcmpneq_oqpd,vcmpneq_oqps,vcmpneq_oqsd,\
vcmpneq_oqss,vcmpneq_ospd,vcmpneq_osps,vcmpneq_ossd,vcmpneq_osss,vcmpneq_uspd,vcmpneq_usps,vcmpneq_ussd,\
vcmpneq_usss,vcmpnge_uqpd,vcmpnge_uqps,vcmpnge_uqsd,vcmpnge_uqss,vcmpngt_uqpd,vcmpngt_uqps,vcmpngt_uqsd,\
vcmpngt_uqss,vcmpnle_uqpd,vcmpnle_uqps,vcmpnle_uqsd,vcmpnle_uqss,vcmpnlt_uqpd,vcmpnlt_uqps,vcmpnlt_uqsd,\
vcmpnlt_uqss,vextractf128,vextracti128,vfnmadd132pd,vfnmadd132ps,vfnmadd132sd,vfnmadd132ss,vfnmadd213pd,\
vfnmadd213ps,vfnmadd213sd,vfnmadd213ss,vfnmadd231pd,vfnmadd231ps,vfnmadd231sd,vfnmadd231ss,vfnmsub132pd,\
vfnmsub132ps,vfnmsub132sd,vfnmsub132ss,vfnmsub213pd,vfnmsub213ps,vfnmsub213sd,vfnmsub213ss,vfnmsub231pd,\
vfnmsub231ps,vfnmsub231sd,vfnmsub231ss,vinsertf32x4,vinsertf32x8,vinsertf64x2,vinsertf64x4,vinserti32x4,\
vinserti32x8,vinserti64x2,vinserti64x4,vpbroadcastb,vpbroadcastd,vpbroadcastq,vpbroadcastw,vpclmulhqhdq,\
vpclmullqhdq,vpcomfalseub,vpcomfalseud,vpcomfalseuq,vpcomfalseuw,vpermilmo2pd,vpermilmo2ps,vpermilmz2pd,\
vpermilmz2ps,vpermiltd2pd,vpermiltd2ps,vcmptrue_uspd,vcmptrue_usps,vcmptrue_ussd,vcmptrue_usss,vcmpunord_spd,\
vcmpunord_sps,vcmpunord_ssd,vcmpunord_sss,vextractf32x4,vextractf32x8,vextractf64x2,vextractf64x4,vextracti32x4,\
vextracti32x8,vextracti64x2,vextracti64x4,vgatherpf0dpd,vgatherpf0dps,vgatherpf0qpd,vgatherpf0qps,vgatherpf1dpd,\
vgatherpf1dps,vgatherpf1qpd,vgatherpf1qps,vpclmulhqlqdq,vpclmullqlqdq,vbroadcastf128,vbroadcasti128,vcmpfalse_ospd,\
vcmpfalse_osps,vcmpfalse_ossd,vcmpfalse_osss,vfmaddsub132pd,vfmaddsub132ps,vfmaddsub213pd,vfmaddsub213ps,vfmaddsub231pd,\
vfmaddsub231ps,vfmsubadd132pd,vfmsubadd132ps,vfmsubadd213pd,vfmsubadd213ps,vfmsubadd231pd,vfmsubadd231ps,vpmultishiftqb,\
vscatterpf0dpd,vscatterpf0dps,vscatterpf0qpd,vscatterpf0qps,vscatterpf1dpd,vscatterpf1dps,vscatterpf1qpd,vscatterpf1qps,\
aeskeygenassist,vbroadcastf32x2,vbroadcastf32x4,vbroadcastf32x8,vbroadcastf64x2,vbroadcastf64x4,vbroadcasti32x2,vbroadcasti32x4,\
vbroadcasti32x8,vbroadcasti64x2,vbroadcasti64x4,vpbroadcastmb2q,vpbroadcastmw2d,vaeskeygenassist

match ,
{
    local iset_s, totalSize_s, maxSize_s, maxSizeVar_s
    macro ilen_ [iset=iset]
    \{
        \common \local totalSize, maxSize, maxSizeVar, inmacro, omit
        define totalSize_s totalSize
        define maxSize_s maxSize
        define maxSizeVar_s maxSizeVar
        iset_s equ iset
        
        totalSize = 0
        maxSizeVar = 0
        match \\iset,iset \\{ irp i,\\iset
        \\\{
            macro i [args]
            \\\\{
                \\\\common \\\\local iAddr, iSize, buf
                    inmacro = 1
                    iAddr = $
                    i args
                    match =omit,omit
                    \\\\\{
                        if inmacro ;inmacro might have become 0
                            iSize = $-iAddr
                            totalSize = totalSize+iSize
                            if iSize > maxSizeVar
                                maxSizeVar = iSize
                            end if
                            
                            if iAddr relativeto 0
                                dispHex iAddr,,'0x'
                            else
                                dispHex rva iAddr,,'0x'
                            end if
                            display ': '
                            times -((iSize/10)-1)shr 64 : display ' '
                            dispDec iSize
                            display ' | '
                            repeat iSize
                                load buf byte from iAddr+(%-1)
                                dispHex buf,2,,' '
                            end repeat
                            times maxSize-iSize : display '   '
                            display '| ',\\\\\`i
                            
                            define _token +
                            irps arg,args
                            \\\\\\{
                                \\\\\\common display ' '
                                \\\\\\forward
                                    match \\\\\\`arg,arg \\\\\\\{ rept 0 { \\\\\\\}
                                    match l \\\\\\`arg t,'' '+' '-' '*' '/' '=' '(' ')' '[' ']' '{' '}' ':' ',' '|' '&' '~' ''
                                    \\\\\\\{
                                        define token +
                                        rept 0 {
                                    \\\\\\\}
                                    define token -
                                    match -,_token \\\\\\\{ display ' ' \\\\\\\}
                                    restore _token
                                    _token equ token
                                    restore token
                                    match \\\\\\`arg,arg \\\\\\\{ display "'" \\\\\\\}
                                    display \\\\\\`arg
                                    match \\\\\\`arg,arg \\\\\\\{ display "'" \\\\\\\}
                            \\\\\\}
                            restore _token
                            display 13,10
                        end if
                    \\\\\}
                    inmacro = 0
            \\\\}
        \\\} \\}
        macro virtual [arg]
        \\{
            \\common virtual arg
            define omit +
        \\}
        struc virtual [arg]
        \\{
            \\common . virtual arg
            match =end,. \\\{ restore omit \\\}
        \\}
        macro ilen_ [arg]
        \\{
            \\common
                display 'Error: _ilen missing',13,10
                err
        \\}
    \}
    macro _ilen
    \{
        match iset,iset_s \\{ purge iset \\}
        purge virtual, ilen_
        restruc virtual

        match =totalSize_s,totalSize_s
        \\{
            display "Error: ilen_ missing",13,10
            err
        \\}
        maxSize_s = maxSizeVar_s
        mdisplay 'Total size of the shown instructions: ',d=totalSize_s,13,10
        restore iset_s, totalSize_s, maxSize_s
    \}
}    

Also you can omit the iset argument now:
Code:
ilen_
;your code
_ilen    

_________________
Faith is a superposition of knowledge and fallacy
Post 27 May 2016, 21:57
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.