flat assembler
Message board for the users of flat assembler.

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

Joined: 24 Mar 2012
Posts: 671
Location: Russian Federation, Sochi
ProMiNick
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
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,...(7(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,...(7(56)(34)(12)
db d
if ~% mod 8
db " "
end if
end repeat
db 9
irps a,opcode \{
db \`a," "
\}
db 0Dh,0Ah
}
```
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
27 May 2016, 08:22
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 18591
Location: In your JS exploiting you and your system
revolution
When using 'repeat' the value for % begins at 1, not 0.
Code:
```repeat 8
display %+'0'
end repeat    ```
Output:
Code:
`12345678    `
27 May 2016, 08:49
ProMiNick

Joined: 24 Mar 2012
Posts: 671
Location: Russian Federation, Sochi
ProMiNick
Code:
```macro instr [opcode]
{ common
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
}     ```

In most common case it is enough.
But how to update macro to support instructions up to 16 bytes long
27 May 2016, 09:46
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 18591
Location: In your JS exploiting you and your system
revolution
Use two qword loads.
Code:
```load op0 from x+0
load op1 from x+8    ```
27 May 2016, 09:49
l_inc

Joined: 23 Oct 2009
Posts: 881
l_inc
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
27 May 2016, 10:13
ProMiNick

Joined: 24 Mar 2012
Posts: 671
Location: Russian Federation, Sochi
ProMiNick
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!
27 May 2016, 11:03
l_inc

Joined: 23 Oct 2009
Posts: 881
l_inc
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
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
{
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
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
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,\
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,\
blsi,blsr,bzhi,call,cdqe,clac,clgi,clts,\
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,\
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,\
fistp,fisub,fldcw,fldpi,fmulp,fneni,fprem,fptan,\
fsave,fsqrt,fstcw,fstsw,fsubp,fsubr,fucom,fwait,\
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,\
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,\
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,\
phsubw,pinsrb,pinsrd,pinsrq,pinsrw,pmaxsb,pmaxsd,pmaxsw,\
pmaxub,pmaxud,pmaxuw,pminsb,pminsd,pminsw,pminub,pminud,\
pshufd,pshufw,psignb,psignd,psignw,pslldq,psrldq,psubsb,\
rdpkru,rdrand,rdseed,rdtscp,setalc,setnae,setnbe,setnge,\
setnle,sfence,shufpd,shufps,skinit,slwpcb,sqrtpd,sqrtps,\
vdivps,vdivsd,vdivss,vlddqu,vmaxpd,vmaxps,vmaxsd,vmaxss,\
vpandd,vpandn,vpandq,vpavgb,vpavgw,vpcmov,vpcmpb,vpcmpd,\
vpcmpq,vpcmpw,vpcomb,vpcomd,vpcomq,vpcomw,vpermb,vpermd,\
vpermq,vpermw,vpperm,vprold,vprolq,vprord,vprorq,vprotb,\
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,\
palignr,pavgusb,pblendw,pcmpeqb,pcmpeqd,pcmpeqq,pcmpeqw,pcmpgtb,\
pcmpgtd,pcmpgtq,pcmpgtw,pcommit,pfcmpeq,pfcmpge,pfcmpgt,pfpnacc,\
pshuflw,psubusb,psubusw,roundpd,roundps,roundsd,roundss,rsqrtps,\
rsqrtss,stmxcsr,syscall,sysexit,sysretq,ucomisd,ucomiss,vaesdec,\
vaesenc,vaesimc,valignd,valignq,vandnpd,vandnps,vcomisd,vcomiss,\
vhsubpd,vhsubps,vmclear,vmmcall,vmovapd,vmovaps,vmovdqa,vmovdqu,\
vmovhpd,vmovhps,vmovlpd,vmovlps,vmovupd,vmovups,vmptrld,vmptrst,\
vpcmpuw,vpcomub,vpcomud,vpcomuq,vpcomuw,vpermpd,vpermps,vpextrb,\
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,\
vpslldq,vpsllvd,vpsllvq,vpsllvw,vpsravd,vpsravq,vpsravw,vpsrldq,\
vpsrlvd,vpsrlvq,vpsrlvw,vpsubsb,vpsubsw,vshufpd,vshufps,vsqrtpd,\
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,\
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,\
vfmsubps,vfmsubsd,vfmsubss,vldmxcsr,vmlaunch,vmovddup,vmovdqu8,vmovhlps,\
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,\
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,\
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,\
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,\
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,\
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,\
vpcmpnequb,vpcmpnequd,vpcmpnequq,vpcmpnequw,vpcmpnleub,vpcmpnleud,vpcmpnleuq,vpcmpnleuw,\
vpcmpnltub,vpcmpnltud,vpcmpnltuq,vpcmpnltuw,vpcomnequb,vpcomnequd,vpcomnequq,vpcomnequw,\
vpcomtrueb,vpcomtrued,vpcomtrueq,vpcomtruew,vperm2f128,vperm2i128,vpermil2pd,vpermil2ps,\
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,\
vrndscaleps,vrndscalesd,vrndscaless,vscatterdpd,vscatterdps,vscatterqpd,vscatterqps,pclmulhqhqdq,\
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,\
vfnmsub132ps,vfnmsub132sd,vfnmsub132ss,vfnmsub213pd,vfnmsub213ps,vfnmsub213sd,vfnmsub213ss,vfnmsub231pd,\
vfnmsub231ps,vfnmsub231sd,vfnmsub231ss,vinsertf32x4,vinsertf32x8,vinsertf64x2,vinsertf64x4,vinserti32x4,\
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,\
vscatterpf0dpd,vscatterpf0dps,vscatterpf0qpd,vscatterpf0qps,vscatterpf1dpd,vscatterpf1dps,vscatterpf1qpd,vscatterpf1qps,\

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
i args
match =omit,omit
\\\\\{
if inmacro ;inmacro might have become 0
totalSize = totalSize+iSize
if iSize > maxSizeVar
maxSizeVar = iSize
end if

if iAddr relativeto 0
else
end if
display ': '
times -((iSize/10)-1)shr 64 : display ' '
dispDec iSize
display ' | '
repeat iSize
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_
_ilen    ```

_________________
Faith is a superposition of knowledge and fallacy
27 May 2016, 21:57
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum