I build this macro to determ the size of operand:
macro Size argi,argo
{
virtual
origin = $
if argi eqtype word 0 | argi eqtype 0
push argi
else
inc argi
end if
load opcode byte from origin
if opcode = 66h ;66 3
argo=4
else if (opcode or 7) = 47h ;4X:0-7
argo=2
else if opcode = 0FFh | opcode = 068h ;ff | 68
argo=2
else if opcode = 0FEh ;fe
argo=1
else
err ;"not implemented 64bit or invalid argument"
end if
end virtual
}
macro TestSize [sou]
{
forward
Size sou,siz
if sou eqtype 0 | sou eqtype word 0
if (siz = 1)
push 1
else if (siz = 2)
push 2
else if (siz = 4)
push 4
else
err ;"not implemented 64bit or invalid argument"
end if
else
if (siz = 1)
add sou,1
else if (siz = 2)
add sou,2
else if (siz = 4)
add sou,4
else
err ;"not implemented 64bit or invalid argument"
end if
end if
}
I call with this parameters:
TestSize al,cl,dl,bl,ah,ch,dh,bh,byte [b2],[b1];,byte 0xaa
TestSize ax,cx,dx,bx,sp,bp,si,di,word 0xbbcc,word [w2],[w1],0xbbcc
TestSize eax,ecx,edx,ebx,esp,ebp,esi,edi,dword [d2],[d1],dword 0xddeeff00
Work fine, except when I call with a byte constant "TestSize byte 0xaa" because try to push a byte in the stack, I try to filter this case to avoid the error but I can not found the way.
Could helpme anyone???
In the picture you can see the code generated, for every register o variable add operand,size, for every const push size
One idea is catch de exception and put a correct code to make the macro work fine, but I dont know it is possible
Try to filter if operand begin with "byte" and avoid the exception, but I can not resolve yet:
if (argi eqtype byte 0) not cathch, it is a bug this???