def format_operand_type(operand): """Returns string representation of the operand type in assembly language""" from peachpy.x86_64.registers import GeneralPurposeRegister64, GeneralPurposeRegister32, GeneralPurposeRegister16,\ GeneralPurposeRegister8, MMXRegister, XMMRegister, YMMRegister,\ al, ax, eax, rax, cl, xmm0 from peachpy.x86_64.pseudo import Label from peachpy.util import is_int64, is_int32, is_int16, is_int8 if is_int8(operand): return "imm8" elif is_int16(operand): return "imm16" elif is_int32(operand): return "imm32" elif is_int64(operand): return "imm64" elif al == operand: return "al" elif ax == operand: return "ax" elif eax == operand: return "eax" elif rax == operand: return "rax" elif cl == operand: return "cl" elif xmm0 == operand: return "xmm0" elif isinstance(operand, GeneralPurposeRegister64): return "r64" elif isinstance(operand, GeneralPurposeRegister32): return "r32" elif isinstance(operand, GeneralPurposeRegister16): return "r16" elif isinstance(operand, GeneralPurposeRegister8): return "r8" elif isinstance(operand, MMXRegister): return "mm" elif isinstance(operand, XMMRegister): return "xmm" elif isinstance(operand, YMMRegister): return "ymm" elif isinstance(operand, MemoryOperand): if operand.size is None: return "m" else: return "m" + str(operand.size) elif isinstance(operand, Label): return "rel" else: return operand.__class__.__name__