Add iInvalid enum value for invalid instructions
Various cleanups.
This commit is contained in:
parent
d7acc8cd4d
commit
d6af9c1555
@ -99,7 +99,7 @@ enum icodeType
|
||||
/* LOW_LEVEL icode opcodes */
|
||||
enum llIcode
|
||||
{
|
||||
//iINVALID,
|
||||
iINVALID=-1,
|
||||
iCBW, /* 0 */
|
||||
iAAA,
|
||||
iAAD,
|
||||
|
||||
@ -313,7 +313,7 @@ struct LLOperand
|
||||
struct LLInst
|
||||
{
|
||||
protected:
|
||||
uint32_t m_opcode; // Low level opcode identifier
|
||||
llIcode m_opcode; // Low level opcode identifier
|
||||
uint32_t flg; /* icode flags */
|
||||
LLOperand m_src; /* source operand */
|
||||
public:
|
||||
@ -326,8 +326,8 @@ public:
|
||||
std::vector<uint32_t> caseTbl2;
|
||||
int hllLabNum; /* label # for hll codegen */
|
||||
|
||||
uint32_t getOpcode() const { return m_opcode;}
|
||||
void setOpcode(uint32_t op) { m_opcode=op; }
|
||||
llIcode getOpcode() const { return m_opcode;}
|
||||
void setOpcode(uint32_t op) { m_opcode=(llIcode)op; }
|
||||
bool conditionalJump()
|
||||
{
|
||||
return (getOpcode() >= iJB) and (getOpcode() < iJCXZ);
|
||||
|
||||
@ -28,7 +28,7 @@ struct LLInst;
|
||||
typedef std::list<ICODE>::iterator iICODE;
|
||||
struct IDX_ARRAY : public std::vector<iICODE>
|
||||
{
|
||||
bool inList(iICODE idx)
|
||||
bool inList(iICODE idx) const
|
||||
{
|
||||
return std::find(begin(),end(),idx)!=end();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public:
|
||||
ilFunction createFunction(FunctionType *f, const QString & name);
|
||||
bool valid(ilFunction iter);
|
||||
|
||||
int getSymIdxByAdd(uint32_t adr);
|
||||
int getSymIdxByAddr(uint32_t adr);
|
||||
bool validSymIdx(size_t idx);
|
||||
size_t symbolSize(size_t idx);
|
||||
hlType symbolType(size_t idx);
|
||||
|
||||
72
src/ast.cpp
72
src/ast.cpp
@ -13,6 +13,7 @@
|
||||
#include "project.h"
|
||||
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QtCore/QDebug>
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/range/adaptor/filtered.hpp>
|
||||
#include <boost/range/algorithm.hpp>
|
||||
@ -29,12 +30,15 @@ using namespace boost::adaptors;
|
||||
|
||||
extern int strSize (const uint8_t *, char);
|
||||
extern char *cChar(uint8_t c);
|
||||
|
||||
namespace
|
||||
{
|
||||
// Conditional operator symbols in C. Index by condOp enumeration type
|
||||
static const char * const condOpSym[] = { " <= ", " < ", " == ", " != ", " > ", " >= ",
|
||||
constexpr const char * condOpSym[] = { " <= ", " < ", " == ", " != ", " > ", " >= ",
|
||||
" & ", " | ", " ^ ", " ~ ",
|
||||
" + ", " - ", " * ", " / ",
|
||||
" >> ", " << ", " % ", " && ", " || " };
|
||||
/* Size of hl types */
|
||||
constexpr const int hlSize[] = {2, 1, 1, 2, 2, 4, 4, 4, 2, 2, 1, 4, 4};
|
||||
|
||||
/* Local expression stack */
|
||||
//typedef struct _EXP_STK {
|
||||
@ -43,13 +47,13 @@ static const char * const condOpSym[] = { " <= ", " < ", " == ", " != ", " > ",
|
||||
//} EXP_STK; - for local expression stack
|
||||
|
||||
/* Returns the integer i in C hexadecimal format */
|
||||
static const char *hexStr (uint16_t i)
|
||||
const char *hexStr (uint16_t i)
|
||||
{
|
||||
static char buf[10];
|
||||
sprintf (buf, "%s%x", (i > 9) ? "0x" : "", i);
|
||||
return (buf);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Sets the du record for registers according to the du flag */
|
||||
void ICODE::setRegDU (eReg regi, operDu du_in)
|
||||
@ -124,7 +128,7 @@ GlobalVariable::GlobalVariable(int16_t segValue, int16_t off)
|
||||
valid = true;
|
||||
ident.idType = GLOB_VAR;
|
||||
adr = opAdr(segValue, off);
|
||||
auto i=Project::get()->getSymIdxByAdd(adr);
|
||||
auto i=Project::get()->getSymIdxByAddr(adr);
|
||||
if ( not Project::get()->validSymIdx(i) )
|
||||
{
|
||||
printf ("Error, glob var not found in symtab\n");
|
||||
@ -136,7 +140,7 @@ GlobalVariable::GlobalVariable(int16_t segValue, int16_t off)
|
||||
QString GlobalVariable::walkCondExpr(Function *, int *) const
|
||||
{
|
||||
if(valid)
|
||||
return Project::get()->symtab[globIdx].name;
|
||||
return Project::get()->symbolName(globIdx);
|
||||
return "INVALID GlobalVariable";
|
||||
}
|
||||
|
||||
@ -344,7 +348,6 @@ Expr *AstIdent::id(const LLInst &ll_insn, opLoc sd, Function * pProc, iICODE ix_
|
||||
newExp = AstIdent::Other (pm.seg, pm.regi, pm.off);
|
||||
/**** check long ops, indexed global var *****/
|
||||
}
|
||||
|
||||
else /* (pm->regi >= INDEXBASE and pm->off = 0) => indexed and no off */
|
||||
{
|
||||
if ((pm.seg == rDS) and (pm.regi > INDEX_BP_DI)) /* dereference */
|
||||
@ -367,7 +370,7 @@ Expr *AstIdent::id(const LLInst &ll_insn, opLoc sd, Function * pProc, iICODE ix_
|
||||
else
|
||||
newExp = AstIdent::Other (pm.seg, pm.regi, 0);
|
||||
}
|
||||
return (newExp);
|
||||
return newExp;
|
||||
}
|
||||
|
||||
|
||||
@ -377,31 +380,28 @@ condId LLInst::idType(opLoc sd) const
|
||||
const LLOperand &pm((sd == SRC) ? src() : m_dst);
|
||||
|
||||
if ((sd == SRC) and testFlags(I))
|
||||
return (CONSTANT);
|
||||
return CONSTANT;
|
||||
else if (pm.regi == 0)
|
||||
return (GLOB_VAR);
|
||||
return GLOB_VAR;
|
||||
else if ( pm.isReg() )
|
||||
return (REGISTER);
|
||||
else if ((pm.seg == rSS) and (pm.regi == INDEX_BP))
|
||||
return REGISTER;
|
||||
else if ((pm.seg == rSS) and (pm.regi == INDEX_BP)) // TODO: this assumes BP-based function frames !
|
||||
{
|
||||
//TODO: which pm.seg/pm.regi pairs should produce PARAM/LOCAL_VAR ?
|
||||
if (pm.off >= 0)
|
||||
return (PARAM);
|
||||
else
|
||||
return (LOCAL_VAR);
|
||||
return PARAM;
|
||||
return LOCAL_VAR;
|
||||
}
|
||||
else
|
||||
return (OTHER);
|
||||
return OTHER;
|
||||
}
|
||||
|
||||
|
||||
/* Size of hl types */
|
||||
int hlSize[] = {2, 1, 1, 2, 2, 4, 4, 4, 2, 2, 1, 4, 4};
|
||||
|
||||
int Expr::hlTypeSize(Function * pproc) const
|
||||
{
|
||||
if (this == nullptr)
|
||||
return (2); /* for TYPE_UNKNOWN */
|
||||
return 2; /* for TYPE_UNKNOWN */
|
||||
fprintf(stderr,"hlTypeSize queried for Unkown type %d \n",m_type);
|
||||
return 2; // CC: is this correct?
|
||||
}
|
||||
@ -436,11 +436,11 @@ int AstIdent::hlTypeSize(Function *pproc) const
|
||||
case PARAM:
|
||||
return (hlSize[pproc->args[ident.idNode.paramIdx].type]);
|
||||
case STRING:
|
||||
return (2);
|
||||
return 2;
|
||||
case LONG_VAR:
|
||||
return (4);
|
||||
return 4;
|
||||
case OTHER:
|
||||
return (2);
|
||||
return 2;
|
||||
default:
|
||||
assert(false);
|
||||
return -1;
|
||||
@ -593,6 +593,10 @@ QString AstIdent::walkCondExpr(Function *pProc, int *numLoc) const
|
||||
o << "[" << (id->id.longGlb.seg<<4) + id->id.longGlb.offH <<"]";
|
||||
else if (id->id.longGlb.regi == rBX)
|
||||
o << "[" << (id->id.longGlb.seg<<4) + id->id.longGlb.offH <<"][bx]";
|
||||
else {
|
||||
qCritical() << "AstIdent::walkCondExpr unhandled LONG_VAR in GLB_FRAME";
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OTHER:
|
||||
@ -665,9 +669,6 @@ QString UnaryOperator::walkCondExpr(Function *pProc, int *numLoc) const
|
||||
/* Walks the conditional expression tree and returns the result on a string */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Changes the boolean conditional operator at the root of this expression */
|
||||
void BinaryOperator::changeBoolOp (condOp newOp)
|
||||
{
|
||||
@ -798,9 +799,8 @@ Expr *BinaryOperator::insertSubTreeLongReg(Expr *_expr, int longIdx)
|
||||
Expr *AstIdent::insertSubTreeLongReg(Expr *_expr, int longIdx)
|
||||
{
|
||||
if (ident.idNode.longIdx == longIdx)
|
||||
{
|
||||
return _expr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -816,7 +816,7 @@ Expr *BinaryOperator::clone() const
|
||||
|
||||
Expr *BinaryOperator::inverse() const
|
||||
{
|
||||
static condOp invCondOp[] = {GREATER, GREATER_EQUAL, NOT_EQUAL, EQUAL,
|
||||
constexpr static condOp invCondOp[] = {GREATER, GREATER_EQUAL, NOT_EQUAL, EQUAL,
|
||||
LESS_EQUAL, LESS, DUMMY,DUMMY,DUMMY,DUMMY,
|
||||
DUMMY, DUMMY, DUMMY, DUMMY, DUMMY, DUMMY,
|
||||
DUMMY, DBL_OR, DBL_AND};
|
||||
@ -848,20 +848,18 @@ Expr *AstIdent::performLongRemoval(eReg regi, LOCAL_ID *locId)
|
||||
{
|
||||
eReg otherRegi; /* high or low part of long register */
|
||||
|
||||
if (ident.idType == LONG_VAR)
|
||||
{
|
||||
otherRegi = locId->getPairedRegisterAt(ident.idNode.longIdx,regi);
|
||||
delete this;
|
||||
return new RegisterNode(locId->newByteWordReg(TYPE_WORD_SIGN,otherRegi),WORD_REG,locId);
|
||||
}
|
||||
if (ident.idType != LONG_VAR)
|
||||
return this;
|
||||
otherRegi = locId->getPairedRegisterAt(ident.idNode.longIdx,regi);
|
||||
bool long_was_signed = locId->id_arr[ident.idNode.longIdx].isSigned();
|
||||
delete this;
|
||||
return new RegisterNode(locId->newByteWordReg(long_was_signed ? TYPE_WORD_SIGN : TYPE_WORD_UNSIGN,otherRegi),WORD_REG,locId);
|
||||
}
|
||||
|
||||
QString Constant::walkCondExpr(Function *, int *) const
|
||||
{
|
||||
if (kte.kte < 1000)
|
||||
return QString::number(kte.kte);
|
||||
else
|
||||
return "0x" + QString::number(kte.kte,16);
|
||||
}
|
||||
|
||||
@ -870,8 +868,6 @@ int Constant::hlTypeSize(Function *) const
|
||||
return kte.size;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QString FuncNode::walkCondExpr(Function *pProc, int *numLoc) const
|
||||
{
|
||||
return pProc->writeCall(call.proc,*call.args, numLoc);
|
||||
|
||||
@ -158,9 +158,9 @@ void Project::writeGlobSymTable()
|
||||
else { /* first defined */
|
||||
switch (sym.size) {
|
||||
case 1: ostr<<"uint8_t\t"; break;
|
||||
case 2: ostr<<"int\t"; break;
|
||||
case 2: ostr<<"int16_t\t"; break;
|
||||
case 4: if (sym.type == TYPE_PTR)
|
||||
ostr<<"int\t*";
|
||||
ostr<<"int32_t\t*";
|
||||
else
|
||||
ostr<<"char\t*";
|
||||
break;
|
||||
|
||||
@ -735,7 +735,7 @@ int C_CallingConvention::processCArg (Function * callee, Function * pProc, ICODE
|
||||
callee->args.adjustForArgType (numArgs, _exp->expType (pProc));
|
||||
}
|
||||
}
|
||||
res = picode->newStkArg (_exp, (llIcode)picode->ll()->getOpcode(), pProc);
|
||||
res = picode->newStkArg (_exp, picode->ll()->getOpcode(), pProc);
|
||||
/* Do not update the size of k if the expression was a segment register
|
||||
* in a near call */
|
||||
if (res == false)
|
||||
@ -850,7 +850,7 @@ void Pascal_CallingConvention::processHLI(Function *func,Expr *_exp, iICODE pico
|
||||
{
|
||||
if (pp->args.numArgs > 0)
|
||||
_exp = func->adjustActArgType(_exp, pp->args[numArgs].type);
|
||||
res = picode->newStkArg (_exp, (llIcode)picode->ll()->getOpcode(), func);
|
||||
res = picode->newStkArg (_exp, picode->ll()->getOpcode(), func);
|
||||
}
|
||||
else /* user function */
|
||||
{
|
||||
@ -863,7 +863,7 @@ void Pascal_CallingConvention::processHLI(Function *func,Expr *_exp, iICODE pico
|
||||
else
|
||||
pp->args.adjustForArgType (numArgs,_exp->expType (func));
|
||||
}
|
||||
res = picode->newStkArg (_exp,(llIcode)picode->ll()->getOpcode(), func);
|
||||
res = picode->newStkArg (_exp, picode->ll()->getOpcode(), func);
|
||||
}
|
||||
if (res == false)
|
||||
k += _exp->hlTypeSize (func);
|
||||
|
||||
@ -75,8 +75,7 @@ eReg ID::getPairedRegister(eReg first) const {
|
||||
* ix : index into icode array where this var is used */
|
||||
void LOCAL_ID::newIdent(hlType t, frameType f)
|
||||
{
|
||||
ID newid(t,f);
|
||||
id_arr.push_back(newid);
|
||||
id_arr.emplace_back(t,f);
|
||||
}
|
||||
|
||||
|
||||
@ -92,9 +91,8 @@ int LOCAL_ID::newByteWordReg(hlType t, eReg regi)
|
||||
return found-id_arr.begin();
|
||||
/* Not in table, create new identifier */
|
||||
newIdent (t, REG_FRAME);
|
||||
int idx = id_arr.size() - 1;
|
||||
id_arr[idx].id.regi = regi;
|
||||
return (idx);
|
||||
id_arr.back().id.regi = regi;
|
||||
return id_arr.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,12 +5,11 @@
|
||||
#include "CallGraph.h"
|
||||
#include "project.h"
|
||||
#include "Procedure.h"
|
||||
|
||||
using namespace std;
|
||||
//Project g_proj;
|
||||
|
||||
QString asm1_name, asm2_name; /* Assembler output filenames */
|
||||
SYMTAB symtab; /* Global symbol table */
|
||||
STATS stats; /* cfg statistics */
|
||||
//PROG prog; /* programs fields */
|
||||
OPTION option; /* Command line options */
|
||||
Project *Project::s_instance = nullptr;
|
||||
Project::Project() : callGraph(nullptr)
|
||||
@ -50,7 +49,7 @@ ilFunction Project::findByEntry(uint32_t entry)
|
||||
/* Search procedure list for one with appropriate entry point */
|
||||
ilFunction iter= std::find_if(pProcList.begin(),pProcList.end(),
|
||||
[entry](const Function &f) { return f.procEntry==entry; });
|
||||
return iter;
|
||||
return iter;
|
||||
}
|
||||
|
||||
ilFunction Project::createFunction(FunctionType *f,const QString &name)
|
||||
@ -59,7 +58,7 @@ ilFunction Project::createFunction(FunctionType *f,const QString &name)
|
||||
return (++pProcList.rbegin()).base();
|
||||
}
|
||||
|
||||
int Project::getSymIdxByAdd(uint32_t adr)
|
||||
int Project::getSymIdxByAddr(uint32_t adr)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < symtab.size(); i++)
|
||||
@ -98,8 +97,6 @@ Project *Project::get()
|
||||
s_instance=new Project;
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
|
||||
SourceMachine *Project::machine()
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@ -69,8 +69,8 @@ static bool isLong22 (iICODE pIcode, iICODE pEnd, iICODE &off)
|
||||
// preincrement because pIcode is not checked here
|
||||
iICODE icodes[] = { ++pIcode,++pIcode,++pIcode };
|
||||
if ( icodes[1]->ll()->match(iCMP) and
|
||||
(isJCond ((llIcode)icodes[0]->ll()->getOpcode())) and
|
||||
(isJCond ((llIcode)icodes[2]->ll()->getOpcode())))
|
||||
(isJCond (icodes[0]->ll()->getOpcode())) and
|
||||
(isJCond (icodes[2]->ll()->getOpcode())))
|
||||
{
|
||||
off = initial_icode;
|
||||
advance(off,2);
|
||||
@ -500,7 +500,7 @@ int Function::findForwardLongUses(int loc_ident_idx, const ID &pLocId, iICODE be
|
||||
* JX lab
|
||||
* => HLI_JCOND (regH:regL X 0) lab
|
||||
* This is better code than HLI_JCOND (HI(regH:regL) | LO(regH:regL)) */
|
||||
else if (pIcode->ll()->match(iOR) and (next1 != pEnd) and (isJCond ((llIcode)next1->ll()->getOpcode())))
|
||||
else if (pIcode->ll()->match(iOR) and (next1 != pEnd) and (isJCond (next1->ll()->getOpcode())))
|
||||
{
|
||||
if (pLocId.longId().srcDstRegMatch(pIcode,pIcode))
|
||||
{
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
#define S_EXT 0x000200 /* sign extend */
|
||||
#define OP386 0x000400 /* 386 op-code */
|
||||
#define NSP 0x000800 /* NOT_HLL if SP is src or dst */
|
||||
// defined in Enums.h #define ICODEMASK 0xFF00FF /* Masks off parser flags */
|
||||
|
||||
static void rm(int i);
|
||||
static void modrm(int i);
|
||||
@ -51,15 +50,15 @@ static void none1(int i);
|
||||
static void none2(int i);
|
||||
static void checkInt(int i);
|
||||
|
||||
#define iZERO (llIcode)0 // For neatness
|
||||
#define IC llIcode
|
||||
|
||||
static struct {
|
||||
struct StateTabelEntry {
|
||||
void (*state1)(int);
|
||||
void (*state2)(int);
|
||||
uint32_t flg;
|
||||
llIcode opcode;
|
||||
} stateTable[] = {
|
||||
};
|
||||
static const StateTabelEntry stateTable[] = {
|
||||
{ modrm, none2, B , iADD }, /* 00 */
|
||||
{ modrm, none2, 0 , iADD }, /* 01 */
|
||||
{ modrm, none2, TO_REG | B , iADD }, /* 02 */
|
||||
@ -75,7 +74,7 @@ static struct {
|
||||
{ data1, axImp, B , iOR }, /* 0C */
|
||||
{ data2, axImp, 0 , iOR }, /* 0D */
|
||||
{ segop, none2, NO_SRC , iPUSH }, /* 0E */
|
||||
{ none1, none2, OP386 , iZERO }, /* 0F */
|
||||
{ none1, none2, OP386 , iINVALID }, /* 0F */
|
||||
{ modrm, none2, B , iADC }, /* 10 */
|
||||
{ modrm, none2, NSP , iADC }, /* 11 */
|
||||
{ modrm, none2, TO_REG | B , iADC }, /* 12 */
|
||||
@ -159,11 +158,11 @@ static struct {
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iPUSHA}, /* 60 */
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iPOPA }, /* 61 */
|
||||
{ memOnly, modrm, TO_REG | NSP , iBOUND}, /* 62 */
|
||||
{ none1, none2, OP386 , iZERO }, /* 63 */
|
||||
{ none1, none2, OP386 , iZERO }, /* 64 */
|
||||
{ none1, none2, OP386 , iZERO }, /* 65 */
|
||||
{ none1, none2, OP386 , iZERO }, /* 66 */
|
||||
{ none1, none2, OP386 , iZERO }, /* 67 */
|
||||
{ none1, none2, OP386 , iINVALID }, /* 63 */
|
||||
{ none1, none2, OP386 , iINVALID }, /* 64 */
|
||||
{ none1, none2, OP386 , iINVALID }, /* 65 */
|
||||
{ none1, none2, OP386 , iINVALID }, /* 66 */
|
||||
{ none1, none2, OP386 , iINVALID }, /* 67 */
|
||||
{ data2, none2, NO_SRC , iPUSH }, /* 68 */
|
||||
{ modrm, data2, TO_REG | NSP , iIMUL }, /* 69 */
|
||||
{ data1, none2, S_EXT | NO_SRC , iPUSH }, /* 6A */
|
||||
@ -188,10 +187,10 @@ static struct {
|
||||
{ dispS, none2, 0 , iJGE }, /* 7D */
|
||||
{ dispS, none2, 0 , iJLE }, /* 7E */
|
||||
{ dispS, none2, 0 , iJG }, /* 7F */
|
||||
{ immed, data1, B , iZERO }, /* 80 */
|
||||
{ immed, data2, NSP , iZERO }, /* 81 */
|
||||
{ immed, data1, B , iZERO }, /* 82 */ /* ?? */
|
||||
{ immed, data1, NSP | S_EXT , iZERO }, /* 83 */
|
||||
{ immed, data1, B , iINVALID }, /* 80 */
|
||||
{ immed, data2, NSP , iINVALID }, /* 81 */
|
||||
{ immed, data1, B , iINVALID }, /* 82 */ /* ?? */
|
||||
{ immed, data1, NSP | S_EXT , iINVALID }, /* 83 */
|
||||
{ modrm, none2, TO_REG | B , iTEST }, /* 84 */
|
||||
{ modrm, none2, TO_REG | NSP , iTEST }, /* 85 */
|
||||
{ modrm, none2, TO_REG | B , iXCHG }, /* 86 */
|
||||
@ -252,8 +251,8 @@ static struct {
|
||||
{ regop, data2, 0 , iMOV }, /* BD */
|
||||
{ regop, data2, 0 , iMOV }, /* BE */
|
||||
{ regop, data2, 0 , iMOV }, /* BF */
|
||||
{ shift, data1, B , iZERO }, /* C0 */
|
||||
{ shift, data1, NSP | SRC_B , iZERO }, /* C1 */
|
||||
{ shift, data1, B , iINVALID }, /* C0 */
|
||||
{ shift, data1, NSP | SRC_B , iINVALID }, /* C1 */
|
||||
{ data2, none2, 0 , iRET }, /* C2 */
|
||||
{ none1, none2, NO_OPS , iRET }, /* C3 */
|
||||
{ memOnly, modrm, TO_REG | NSP , iLES }, /* C4 */
|
||||
@ -268,13 +267,13 @@ static struct {
|
||||
{ data1,checkInt, NOT_HLL , iINT }, /* CD */
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iINTO }, /* CE */
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iIRET }, /* Cf */
|
||||
{ shift, const1, B , iZERO }, /* D0 */
|
||||
{ shift, const1, SRC_B , iZERO }, /* D1 */
|
||||
{ shift, none1, B , iZERO }, /* D2 */
|
||||
{ shift, none1, SRC_B , iZERO }, /* D3 */
|
||||
{ shift, const1, B , iINVALID }, /* D0 */
|
||||
{ shift, const1, SRC_B , iINVALID }, /* D1 */
|
||||
{ shift, none1, B , iINVALID }, /* D2 */
|
||||
{ shift, none1, SRC_B , iINVALID }, /* D3 */
|
||||
{ data1, axImp, NOT_HLL , iAAM }, /* D4 */
|
||||
{ data1, axImp, NOT_HLL , iAAD }, /* D5 */
|
||||
{ none1, none2, 0 , iZERO }, /* D6 */
|
||||
{ none1, none2, 0 , iINVALID }, /* D6 */
|
||||
{ memImp, axImp, NOT_HLL | B| IM_OPS , iXLAT }, /* D7 */
|
||||
{ escop, none2, FLOAT_OP , iESC }, /* D8 */
|
||||
{ escop, none2, FLOAT_OP , iESC }, /* D9 */
|
||||
@ -301,21 +300,21 @@ static struct {
|
||||
{ none1, axImp, NOT_HLL | B|NO_SRC , iOUT }, /* EE */
|
||||
{ none1, axImp, NOT_HLL | NO_SRC , iOUT }, /* EF */
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iLOCK }, /* F0 */
|
||||
{ none1, none2, 0 , iZERO }, /* F1 */
|
||||
{ none1, none2, 0 , iINVALID }, /* F1 */
|
||||
{ prefix, none2, 0 , iREPNE}, /* F2 */
|
||||
{ prefix, none2, 0 , iREPE }, /* F3 */
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iHLT }, /* F4 */
|
||||
{ none1, none2, NO_OPS , iCMC }, /* F5 */
|
||||
{ arith, none1, B , iZERO }, /* F6 */
|
||||
{ arith, none1, NSP , iZERO }, /* F7 */
|
||||
{ arith, none1, B , iINVALID }, /* F6 */
|
||||
{ arith, none1, NSP , iINVALID }, /* F7 */
|
||||
{ none1, none2, NO_OPS , iCLC }, /* F8 */
|
||||
{ none1, none2, NO_OPS , iSTC }, /* F9 */
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iCLI }, /* FA */
|
||||
{ none1, none2, NOT_HLL | NO_OPS , iSTI }, /* FB */
|
||||
{ none1, none2, NO_OPS , iCLD }, /* FC */
|
||||
{ none1, none2, NO_OPS , iSTD }, /* FD */
|
||||
{ trans, none1, B , iZERO }, /* FE */
|
||||
{ trans, none1, NSP , iZERO } /* FF */
|
||||
{ trans, none1, B , iINVALID }, /* FE */
|
||||
{ trans, none1, NSP , iINVALID } /* FF */
|
||||
} ;
|
||||
|
||||
static uint16_t SegPrefix, RepPrefix;
|
||||
@ -571,7 +570,7 @@ eErrorId scan(uint32_t ip, ICODE &p)
|
||||
}
|
||||
// LLOperand conv = convertOperand(*p.insn.get_dest());
|
||||
// assert(conv==p.ll()->dst);
|
||||
if (p.ll()->getOpcode())
|
||||
if (p.ll()->getOpcode()!=iINVALID)
|
||||
{
|
||||
/* Save bytes of image used */
|
||||
p.ll()->numBytes = (uint8_t)((pInst - prog.image()) - ip);
|
||||
@ -787,7 +786,7 @@ static void memImp(int i)
|
||||
static void memOnly(int )
|
||||
{
|
||||
if ((*pInst & 0xC0) == 0xC0)
|
||||
pIcode->ll()->setOpcode((llIcode)0);
|
||||
pIcode->ll()->setOpcode(iINVALID);
|
||||
}
|
||||
|
||||
|
||||
@ -797,7 +796,7 @@ static void memOnly(int )
|
||||
static void memReg0(int i)
|
||||
{
|
||||
if (REG(*pInst) or (*pInst & 0xC0) == 0xC0)
|
||||
pIcode->ll()->setOpcode((llIcode)0);
|
||||
pIcode->ll()->setOpcode(iINVALID);
|
||||
else
|
||||
rm(i);
|
||||
}
|
||||
@ -841,8 +840,8 @@ static void trans(int i)
|
||||
{
|
||||
static llIcode transTable[8] =
|
||||
{
|
||||
(llIcode)iINC, iDEC, (llIcode)iCALL, (llIcode)iCALLF,
|
||||
(llIcode)iJMP, (llIcode)iJMPF,(llIcode)iPUSH, (llIcode)0
|
||||
iINC, iDEC, iCALL, iCALLF,
|
||||
iJMP, iJMPF,iPUSH, (llIcode)0
|
||||
};
|
||||
LLInst *ll = pIcode->ll();
|
||||
// if(transTable[REG(*pInst)]==iPUSH) {
|
||||
@ -868,7 +867,7 @@ static void arith(int i)
|
||||
uint8_t opcode;
|
||||
static llIcode arithTable[8] =
|
||||
{
|
||||
iTEST, (llIcode)0, iNOT, iNEG,
|
||||
iTEST, iINVALID, iNOT, iNEG,
|
||||
iMUL , iIMUL, iDIV, iIDIV
|
||||
};
|
||||
opcode = arithTable[REG(*pInst)];
|
||||
@ -985,7 +984,7 @@ static void dispF(int i)
|
||||
****************************************************************************/
|
||||
static void prefix(int )
|
||||
{
|
||||
if (pIcode->ll()->getOpcode() == iREPE or pIcode->ll()->getOpcode() == iREPNE)
|
||||
if ((pIcode->ll()->getOpcode() == iREPE) or (pIcode->ll()->getOpcode() == iREPNE))
|
||||
RepPrefix = pIcode->ll()->getOpcode();
|
||||
else
|
||||
SegPrefix = pIcode->ll()->getOpcode();
|
||||
@ -993,7 +992,7 @@ static void prefix(int )
|
||||
|
||||
inline void BumpOpcode(LLInst &ll)
|
||||
{
|
||||
llIcode ic((llIcode)ll.getOpcode());
|
||||
llIcode ic(ll.getOpcode());
|
||||
ic = (llIcode)(((int)ic)+1); // Bump this icode via the int type
|
||||
ll.setOpcode(ic);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user