# 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)
                retVal = regOpcode['r16'][self.RM]
            elif typ == 'r/m32':
                retVal = regOpcode['r32'][self.RM]
            else:
                raise RuntimeError("Invalid r/m type")
        else:
            raise RuntimeError("Invalid Mode")
        return retVal

    def GetDisplacementSize(self):
        "We only know this at runtime with real values"
        if self.Mode == 0 and self.RM == 5:
            return 4
        elif self.Mode == 1:
            return 1
        elif self.Mode == 2:
            return 4
        else:
            return 0
        
class instruction:
    def __init__(self,opstr,inststr,desc):
        self.OpcodeString = opstr
        self.InstructionString = inststr
        self.Description = desc

        self.Opcode = []
        self.OpcodeSize = 0
        self.OpcodeFlags = []


# 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)

                retVal = regOpcode['r16'][self.RM]
            elif typ == 'r/m32':
                retVal = regOpcode['r32'][self.RM]
            else:
                raise RuntimeError("Invalid r/m type")
        else:
            raise RuntimeError("Invalid Mode")
        return retVal

    def GetDisplacementSize(self):
        "We only know this at runtime with real values"
        if self.Mode == 0 and self.RM == 5:
            return 4
        elif self.Mode == 1:
            return 1
        elif self.Mode == 2:
            return 4
        else:
            return 0
        
class instruction:
    def __init__(self,opstr,inststr,desc):
        self.OpcodeString = opstr
        self.InstructionString = inststr
        self.Description = desc

        self.Opcode = []
        self.OpcodeSize = 0
        self.OpcodeFlags = []


        self.InstructionDef = tokenizeInstDef(self.InstructionString)