# Path: x86tokenizer.py
# class tokenizeError(Exception):pass
# REGISTER,OPCODE,COMMA,OPERAND,LBRACKET,RBRACKET,NUMBER,SYMBOL,STRING = range(1,10)
# def tokenizeString(s,reToProcess):
# def tokenizeInstDef(s):
# def tokenizeInst(s):


import logging
import struct
from pickle import decode_long, encode_long
from x86tokenizer import (tokenizeInstDef,tokenizeInst,
                          REGISTER,OPCODE,COMMA,OPERAND,
                          LBRACKET, RBRACKET,NUMBER,SYMBOL)
            else:
                raise RuntimeError("Invalid Displacement size")

        if self.Instruction.HasImmediate:
            if self.Instruction.ImmediateSize == 1:
                first,rest = rest[0],rest[1:]
                self.Immediate = struct.unpack("<b",first)[0]
            elif self.Instruction.ImmediateSize == 2:
                first,rest = rest[:2],rest[2:]
                self.Immediate = struct.unpack("<s",first)[0]
            elif self.Instruction.ImmediateSize == 4:
                first,rest = rest[:4],rest[4:]
                self.Immediate = struct.unpack('<l',first)[0]
            else:
                raise RuntimeError("Invalid Immdediate size [%s]" % \
                                   self.InstructionImmediateSize)

        if rest:
            raise RuntimeError("Couldn't unpack all data")

    def DataText(self,data,size,skip=False):
        retVal = ''
        if skip:
            return retVal
        if size >= 1:
            retVal += "%02X " % (data % 0xFF)
        return retVal

    def LoadConcreteValues(self, toks):
        if type(toks) == type(""):

# Path: x86tokenizer.py
# class tokenizeError(Exception):pass
# REGISTER,OPCODE,COMMA,OPERAND,LBRACKET,RBRACKET,NUMBER,SYMBOL,STRING = range(1,10)
# def tokenizeString(s,reToProcess):
# def tokenizeInstDef(s):
# def tokenizeInst(s):


# Path: x86inst.py
import logging
import struct
from pickle import decode_long, encode_long
from x86tokenizer import (tokenizeInstDef,tokenizeInst,
                          REGISTER,OPCODE,COMMA,OPERAND,
                          LBRACKET, RBRACKET,NUMBER,SYMBOL)

            else:
                raise RuntimeError("Invalid Displacement size")

        if self.Instruction.HasImmediate:
            if self.Instruction.ImmediateSize == 1:
                first,rest = rest[0],rest[1:]
                self.Immediate = struct.unpack("<b",first)[0]
            elif self.Instruction.ImmediateSize == 2:
                first,rest = rest[:2],rest[2:]
                self.Immediate = struct.unpack("<s",first)[0]
            elif self.Instruction.ImmediateSize == 4:
                first,rest = rest[:4],rest[4:]
                self.Immediate = struct.unpack('<l',first)[0]
            else:
                raise RuntimeError("Invalid Immdediate size [%s]" % \
                                   self.InstructionImmediateSize)

        if rest:
            raise RuntimeError("Couldn't unpack all data")

    def DataText(self,data,size,skip=False):
        retVal = ''
        if skip:
            return retVal
        if size >= 1:
            retVal += "%02X " % (data % 0xFF)
        return retVal

    def LoadConcreteValues(self, toks):
        if type(toks) == type(""):

            toks = tokenizeInst(toks)