mooing on

This commit is contained in:
Artur K 2012-02-22 20:56:27 +01:00
parent ed6f24a79a
commit 8cb5449591
32 changed files with 1481 additions and 1449 deletions

View File

@ -1,13 +1,14 @@
PROJECT(dcc_original)
cmake_minimum_required(VERSION 2.8)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D__UNIX__ -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
ADD_DEFINITIONS(-D__UNIX__ -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
if(CMAKE_BUILD_TOOL MATCHES "(msdev|devenv|nmake)")
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D__UNIX__ -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(/W4)
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall --std=c++0x")
SET(CMAKE_CXX_FLAGS_DEBUG "-D_GLIBCXX_DEBUG --coverage ${CMAKE_CXX_FLAGS_DEBUG}" )
#-D_GLIBCXX_DEBUG
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra --std=c++0x")
SET(CMAKE_CXX_FLAGS_DEBUG "--coverage ${CMAKE_CXX_FLAGS_DEBUG}" )
endif()
FIND_PACKAGE(LLVM)
@ -63,9 +64,11 @@ set(dcc_HEADERS
include/state.h
include/symtab.h
include/types.h
include/BasicBlock.h
include/Enums.h
include/IdentType.h
include/Procedure.h
include/StackFrame.h
include/BasicBlock.h
)
ADD_EXECUTABLE(dcc_original ${dcc_SOURCES} ${dcc_HEADERS})
TARGET_LINK_LIBRARIES(dcc_original ${REQ_LLVM_LIBRARIES})

View File

@ -25,7 +25,7 @@ struct BB : public llvm::ilist_node<BB>
{
private:
BB(const BB&);
BB() : nodeType(0),traversed(0),start(0),length(0),
BB() : start(0),length(0),nodeType(0),traversed(0),
numHlIcodes(0),flg(0),
inEdges(0),
edges(0),beenOnH(0),inEdgeCount(0),reachingInt(0),

View File

@ -115,10 +115,11 @@ public:
void newRegArg(ICODE *picode, ICODE *ticode);
protected:
// TODO: replace those with friend visitor ?
void propLongReg(Int i, ID *pLocId);
void propLongReg(Int loc_ident_idx, ID *pLocId);
void propLongStk(Int i, ID *pLocId);
void propLongGlb(Int i, ID *pLocId);
int checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx);
void structCases();
void findExps();
void genDU1();

View File

@ -40,6 +40,5 @@ struct STKFRAME
{
}
public:
Int getLocVar(Int off);
};

View File

@ -74,9 +74,8 @@ public:
type=other.type;
expr=other.expr;
}
COND_EXPR()
COND_EXPR(condNodeType t=UNKNOWN_OP) : type(t)
{
type=UNKNOWN_OP;
memset(&expr,0,sizeof(_exprNode));
}
public:

View File

@ -23,7 +23,6 @@ public:
#define lineSize 360 /* 3 lines in the mean time */
void newBundle (bundle *procCode);
//void appendStrTab (strTable *strTab, const char *format, ...);
Int nextBundleIdx (strTable *strTab);
void addLabelBundle (strTable &strTab, Int idx, Int label);
void writeBundle (std::ostream &ios, bundle procCode);

View File

@ -60,32 +60,29 @@ extern bundle cCode; /* Output C procedure's declaration and code */
/* Procedure FLAGS */
enum PROC_FLAGS
{
PROC_BADINST=0x000100,/* Proc contains invalid or 386 instruction */
PROC_IJMP =0x000200,/* Proc incomplete due to indirect jmp */
PROC_ICALL =0x000400, /* Proc incomplete due to indirect call */
PROC_HLL=0x001000, /* Proc is likely to be from a HLL */
CALL_PASCAL=0x002000, /* Proc uses Pascal calling convention */
CALL_C=0x004000, /* Proc uses C calling convention */
CALL_UNKNOWN=0x008000, /* Proc uses unknown calling convention */
PROC_NEAR=0x010000, /* Proc exits with near return */
PROC_FAR=0x020000, /* Proc exits with far return */
GRAPH_IRRED=0x100000, /* Proc generates an irreducible graph */
SI_REGVAR=0x200000, /* SI is used as a stack variable */
DI_REGVAR=0x400000, /* DI is used as a stack variable */
PROC_IS_FUNC=0x800000, /* Proc is a function */
REG_ARGS=0x1000000, /* Proc has registers as arguments */
PROC_VARARG=0x2000000, /* Proc has variable arguments */
PROC_OUTPUT=0x4000000, /* C for this proc has been output */
PROC_RUNTIME=0x8000000, /* Proc is part of the runtime support */
PROC_BADINST=0x00000100,/* Proc contains invalid or 386 instruction */
PROC_IJMP =0x00000200,/* Proc incomplete due to indirect jmp */
PROC_ICALL =0x00000400, /* Proc incomplete due to indirect call */
PROC_HLL =0x00001000, /* Proc is likely to be from a HLL */
CALL_PASCAL =0x00002000, /* Proc uses Pascal calling convention */
CALL_C =0x00004000, /* Proc uses C calling convention */
CALL_UNKNOWN=0x00008000, /* Proc uses unknown calling convention */
PROC_NEAR =0x00010000, /* Proc exits with near return */
PROC_FAR =0x00020000, /* Proc exits with far return */
GRAPH_IRRED =0x00100000, /* Proc generates an irreducible graph */
SI_REGVAR =0x00200000, /* SI is used as a stack variable */
DI_REGVAR =0x00400000, /* DI is used as a stack variable */
PROC_IS_FUNC=0x00800000, /* Proc is a function */
REG_ARGS =0x01000000, /* Proc has registers as arguments */
PROC_VARARG =0x02000000, /* Proc has variable arguments */
PROC_OUTPUT =0x04000000, /* C for this proc has been output */
PROC_RUNTIME=0x08000000, /* Proc is part of the runtime support */
PROC_ISLIB =0x10000000, /* Proc is a library function */
PROC_ASM =0x20000000, /* Proc is an intrinsic assembler routine */
PROC_IS_HLL =0x40000000 /* Proc has HLL prolog code */
};
#define CALL_MASK 0xFFFF9FFF /* Masks off CALL_C and CALL_PASCAL */
/**** Global variables ****/
extern char *asm1_name, *asm2_name; /* Assembler output filenames */
@ -125,13 +122,11 @@ struct PROG /* Loaded program image parameters */
};
extern PROG prog; /* Loaded program image parameters */
extern char condExp[200]; /* Conditional expression buffer */
extern char callBuf[100]; /* Function call buffer */
extern dword duReg[30]; /* def/use bits for registers */
extern dword maskDuReg[30]; /* masks off du bits for regs */
/* Registers used by icode instructions */
static const char *allRegs[21] = {"ax", "cx", "dx", "bx", "sp", "bp",
static constexpr const char *allRegs[21] = {"ax", "cx", "dx", "bx", "sp", "bp",
"si", "di", "es", "cs", "ss", "ds",
"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
"tmp"};
@ -161,24 +156,24 @@ extern STATS stats; /* Icode statistics */
void FrontEnd(char *filename, CALL_GRAPH * *); /* frontend.c */
void *allocMem(Int cb); /* frontend.c */
void *reallocVar(void *p, Int newsize); /* frontend.c */
void udm(void); /* udm.c */
void freeCFG(BB * cfg); /* graph.c */
BB * newBB(BB *, Int, Int, byte, Int, Function *); /* graph.c */
void BackEnd(char *filename, CALL_GRAPH *); /* backend.c */
char *cChar(byte c); /* backend.c */
Int scan(dword ip, ICODE * p); /* scanner.c */
eErrorId scan(dword ip, ICODE * p); /* scanner.c */
void parse (CALL_GRAPH * *); /* parser.c */
boolT labelSrch(CIcodeRec &pIc, Int n, dword tg, Int *pIdx); /* parser.c */
Int strSize (byte *, char); /* parser.c */
void disassem(Int pass, Function * pProc); /* disassem.c */
void interactDis(Function * initProc, Int initIC); /* disassem.c */
boolT JmpInst(llIcode opcode); /* idioms.c */
bool JmpInst(llIcode opcode); /* idioms.c */
queue::iterator appendQueue(queue &Q, BB *node); /* reducible.c */
void SetupLibCheck(void); /* chklib.c */
void CleanupLibCheck(void); /* chklib.c */
boolT LibCheck(Function &p); /* chklib.c */
bool LibCheck(Function &p); /* chklib.c */
/* Exported functions from procs.c */
boolT insertCallGraph (CALL_GRAPH *, ilFunction, ilFunction);
@ -192,8 +187,8 @@ void removeRegFromLong (byte, LOCAL_ID *, COND_EXPR *);
std::string walkCondExpr (const COND_EXPR *exp, Function * pProc, Int *);
Int hlTypeSize (const COND_EXPR *, Function *);
hlType expType (const COND_EXPR *, Function *);
boolT insertSubTreeReg (COND_EXPR *, COND_EXPR **, byte, LOCAL_ID *);
boolT insertSubTreeLongReg (COND_EXPR *, COND_EXPR **, Int);
bool insertSubTreeReg(COND_EXPR *, COND_EXPR **, byte, LOCAL_ID *);
bool insertSubTreeLongReg (COND_EXPR *, COND_EXPR **, Int);
/* Exported functions from hlicode.c */

View File

@ -5,29 +5,32 @@
#pragma once
/* These definitions refer to errorMessage in error.c */
enum eErrorId
{
NO_ERR =0,
USAGE,
INVALID_ARG,
INVALID_OPCODE,
INVALID_386OP,
FUNNY_SEGOVR,
FUNNY_REP,
CANNOT_OPEN,
CANNOT_READ,
MALLOC_FAILED,
NEWEXE_FORMAT,
#define USAGE 0
#define INVALID_ARG 1
#define INVALID_OPCODE 2
#define INVALID_386OP 3
#define FUNNY_SEGOVR 4
#define FUNNY_REP 5
#define CANNOT_OPEN 6
#define CANNOT_READ 7
#define MALLOC_FAILED 8
#define NEWEXE_FORMAT 9
#define NO_BB 10
#define INVALID_SYNTHETIC_BB 11
#define INVALID_INT_BB 12
#define IP_OUT_OF_RANGE 13
#define DEF_NOT_FOUND 14
#define JX_NOT_DEF 15
#define NOT_DEF_USE 16
#define REPEAT_FAIL 17
#define WHILE_FAIL 18
NO_BB,
INVALID_SYNTHETIC_BB,
INVALID_INT_BB,
IP_OUT_OF_RANGE,
DEF_NOT_FOUND,
JX_NOT_DEF,
NOT_DEF_USE,
REPEAT_FAIL,
WHILE_FAIL
};
void fatalError(Int errId, ...);
void reportError(Int errId, ...);
void fatalError(eErrorId errId, ...);
void reportError(eErrorId errId, ...);

View File

@ -301,6 +301,7 @@ struct LLTYPE
struct { /* Case table if op==JMP && !I */
Int numEntries; /* # entries in case table */
dword *entries; /* array of offsets */
} caseTbl;
Int hllLabNum; /* label # for hll codegen */
bool conditionalJump()
@ -375,7 +376,7 @@ public:
void SetLlInvalid(int ip, boolT fInv);
dword GetLlLabel(int ip);
llIcode GetLlOpcode(int ip);
boolT labelSrch(dword target, Int *pIndex);
bool labelSrch(dword target, dword &pIndex);
ICODE * GetIcode(int ip);
};
typedef CIcodeRec::iterator iICODE;

View File

@ -34,7 +34,7 @@ typedef enum {
TYPE_DOUBLE /* double precision float */
} hlType;
static const char *hlTypes[13] = {"", "char", "unsigned char", "int", "unsigned int",
static constexpr const char *hlTypes[13] = {"", "char", "unsigned char", "int", "unsigned int",
"long", "unsigned long", "record", "int *", "char *",
"", "float", "double"};

View File

@ -6,7 +6,7 @@
#define TRUE 1
#define FALSE 0
#define bool unsigned char
//#define bool unsigned char
#define byte unsigned char
#define word unsigned short

View File

@ -3,36 +3,5 @@
*/
#define LH(p) ((int)((byte *)(p))[0] + ((int)((byte *)(p))[1] << 8))
static void rm(Int i);
static void modrm(Int i);
static void segrm(Int i);
static void data1(Int i);
static void data2(Int i);
static void regop(Int i);
static void segop(Int i);
static void strop(Int i);
static void escop(Int i);
static void axImp(Int i);
static void alImp(Int i);
static void axSrcIm(Int i);
static void memImp(Int i);
static void memReg0(Int i);
static void memOnly(Int i);
static void dispM(Int i);
static void dispS(Int i);
static void dispN(Int i);
static void dispF(Int i);
static void prefix(Int i);
static void immed(Int i);
static void shift(Int i);
static void arith(Int i);
static void trans(Int i);
static void const1(Int i);
static void const3(Int i);
static void none1(Int i);
static void none2(Int i);
static void checkInt(Int i);
/* Extracts reg bits from middle of mod-reg-rm byte */
#define REG(x) ((byte)(x & 0x38) >> 3)

View File

@ -101,12 +101,11 @@ void BB::displayDfs()
printf("----\n");
/* Recursive call on successors of current node */
std::for_each(edges.begin(), edges.end(),
[](TYPEADR_TYPE &pb)
for(TYPEADR_TYPE &pb : edges)
{
if (pb.BBptr->traversed != DFS_DISP)
pb.BBptr->displayDfs();
});
}
}
/* Recursive procedure that writes the code for the given procedure, pointed
* to by pBB.
@ -155,7 +154,7 @@ void BB::writeCode (Int indLevel, Function * pProc , Int *numLoc,Int latchNode,
{
/* Write the code for this basic block */
writeBB(&pProc->Icode.front(), indLevel, pProc, numLoc);
repCond = TRUE;
repCond = true;
}
/* Condition needs to be inverted if the loop body is along
@ -271,7 +270,7 @@ void BB::writeCode (Int indLevel, Function * pProc , Int *numLoc,Int latchNode,
l = writeJcondInv ( back().ic.hl, pProc, numLoc);
cCode.appendCode( "\n%s%s", indent(indLevel-1), l);
edges[ELSE].BBptr->writeCode (indLevel, pProc, numLoc, latchNode, follow);
emptyThen = TRUE;
emptyThen = true;
}
}
else /* already visited => emit label */

View File

@ -97,27 +97,13 @@ void ICODE::copyDU(const ICODE &duIcode, operDu _du, operDu duDu)
}
/* Creates a newExp conditional expression node of type t and returns it */
static COND_EXPR *newCondExp (condNodeType t)
{
//printf("%s:%d\n",__FUNCTION__,int(t));
COND_EXPR *newExp;
newExp = new COND_EXPR;
//memset(newExp, 0, sizeof(COND_EXPR));
newExp->type = t;
return (newExp);
}
/* Creates a conditional boolean expression and returns it */
COND_EXPR *COND_EXPR::boolOp(COND_EXPR *lhs, COND_EXPR *rhs, condOp op)
{
//printf("%s:%d\n",__FUNCTION__,int(op));
COND_EXPR *newExp;
newExp = newCondExp (BOOLEAN_OP);
newExp = new COND_EXPR(BOOLEAN_OP);
newExp->expr.boolExpr.op = op;
newExp->expr.boolExpr.lhs = lhs;
newExp->expr.boolExpr.rhs = rhs;
@ -132,7 +118,7 @@ COND_EXPR *COND_EXPR::unary(condNodeType t, COND_EXPR *sub_expr)
{
COND_EXPR *newExp;
newExp = newCondExp (t);
newExp = new COND_EXPR(t);
newExp->expr.unaryExp = sub_expr;
return (newExp);
}
@ -143,9 +129,9 @@ COND_EXPR *COND_EXPR::idGlob (int16 segValue, int16 off)
{
COND_EXPR *newExp;
dword adr;
Int i;
size_t i;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = GLOB_VAR;
adr = opAdr(segValue, off);
for (i = 0; i < symtab.size(); i++)
@ -163,7 +149,7 @@ COND_EXPR *COND_EXPR::idReg(byte regi, flags32 icodeFlg, LOCAL_ID *locsym)
{
COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = REGISTER;
if ((icodeFlg & B) || (icodeFlg & SRC_B))
{
@ -184,7 +170,7 @@ COND_EXPR *COND_EXPR::idRegIdx(Int idx, regType reg_type)
{
COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = REGISTER;
newExp->expr.ident.regiType = reg_type;
newExp->expr.ident.idNode.regiIdx = idx;
@ -197,7 +183,7 @@ COND_EXPR *COND_EXPR::idLoc(Int off, LOCAL_ID *localId)
COND_EXPR *newExp;
size_t i;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = LOCAL_VAR;
for (i = 0; i < localId->csym(); i++)
if ((localId->id_arr[i].id.bwId.off == off) &&
@ -217,7 +203,7 @@ COND_EXPR *COND_EXPR::idParam(Int off, const STKFRAME * argSymtab)
COND_EXPR *newExp;
size_t i;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = PARAM;
for (i = 0; i < argSymtab->sym.size(); i++)
if (argSymtab->sym[i].off == off)
@ -235,7 +221,7 @@ COND_EXPR *idCondExpIdxGlob (int16 segValue, int16 off, byte regi, const LOCAL_I
COND_EXPR *newExp;
size_t i;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = GLOB_VAR_IDX;
for (i = 0; i < locSym->csym(); i++)
if ((locSym->id_arr[i].id.bwGlb.seg == segValue) &&
@ -252,9 +238,7 @@ COND_EXPR *idCondExpIdxGlob (int16 segValue, int16 off, byte regi, const LOCAL_I
/* Returns an identifier conditional expression node of type CONSTANT */
COND_EXPR *COND_EXPR::idKte(dword kte, byte size)
{
COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER);
COND_EXPR *newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = CONSTANT;
newExp->expr.ident.idNode.kte.kte = kte;
newExp->expr.ident.idNode.kte.size = size;
@ -266,9 +250,7 @@ COND_EXPR *COND_EXPR::idKte(dword kte, byte size)
* that points to the given index idx. */
COND_EXPR *COND_EXPR::idLongIdx (Int idx)
{
COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER);
COND_EXPR *newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = LONG_VAR;
newExp->expr.ident.idNode.longIdx = idx;
return (newExp);
@ -278,10 +260,8 @@ COND_EXPR *COND_EXPR::idLongIdx (Int idx)
/* Returns an identifier conditional expression node of type LONG_VAR */
COND_EXPR *COND_EXPR::idLong(LOCAL_ID *localId, opLoc sd, iICODE pIcode, hlFirst f, Int ix, operDu du, Int off)
{
COND_EXPR *newExp;
Int idx;
newExp = newCondExp (IDENTIFIER);
COND_EXPR *newExp = new COND_EXPR(IDENTIFIER);
/* Check for long constant and save it as a constant expression */
if ((sd == SRC) && ((pIcode->ic.ll.flg & I) == I)) /* constant */
@ -311,7 +291,7 @@ COND_EXPR *COND_EXPR::idFunc(Function * pproc, STKFRAME * args)
{
COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = FUNCTION;
newExp->expr.ident.idNode.call.proc = pproc;
newExp->expr.ident.idNode.call.args = args;
@ -326,7 +306,7 @@ COND_EXPR *COND_EXPR::idOther(byte seg, byte regi, int16 off)
{
COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = OTHER;
newExp->expr.ident.idNode.other.seg = seg;
newExp->expr.ident.idNode.other.regi = regi;
@ -342,7 +322,7 @@ COND_EXPR *COND_EXPR::idID (const ID *retVal, LOCAL_ID *locsym, Int ix)
COND_EXPR *newExp;
Int idx;
newExp = newCondExp (IDENTIFIER);
newExp = new COND_EXPR(IDENTIFIER);
if (retVal->type == TYPE_LONG_SIGN)
{
idx = locsym->newLongReg (TYPE_LONG_SIGN, retVal->id.longId.h,retVal->id.longId.l, ix);
@ -563,7 +543,8 @@ hlType expType (const COND_EXPR *expr, Function * pproc)
case POST_INC: case POST_DEC:
case PRE_INC: case PRE_DEC:
case NEGATION: return (expType (expr->expr.unaryExp, pproc));
case NEGATION:
return (expType (expr->expr.unaryExp, pproc));
case ADDRESSOF: return (TYPE_PTR); /***????****/
case DEREFERENCE: return (TYPE_PTR);
@ -653,8 +634,8 @@ string walkCondExpr (const COND_EXPR* expr, Function * pProc, Int* numLoc)
{
int16 off; /* temporal - for OTHER */
ID* id; /* Pointer to local identifier table */
char* o; /* Operand string pointer */
boolT needBracket; /* Determine whether parenthesis is needed */
//char* o; /* Operand string pointer */
bool needBracket; /* Determine whether parenthesis is needed */
BWGLB_TYPE* bwGlb; /* Ptr to BWGLB_TYPE (global indexed var) */
STKSYM * psym; /* Pointer to argument in the stack */
std::ostringstream outStr;
@ -662,7 +643,7 @@ string walkCondExpr (const COND_EXPR* expr, Function * pProc, Int* numLoc)
if (expr == NULL)
return "";
needBracket = TRUE;
needBracket = true;
switch (expr->type)
{
case BOOLEAN_OP:
@ -841,7 +822,7 @@ COND_EXPR *COND_EXPR::clone()
break;
case IDENTIFIER:
newExp = new COND_EXPR(*this);
return new COND_EXPR(*this);
}
return (newExp);
}
@ -856,7 +837,7 @@ void COND_EXPR::changeBoolOp (condOp newOp)
/* Inserts the expression exp into the tree at the location specified by the
* register regi */
boolT insertSubTreeReg (COND_EXPR *expr, COND_EXPR **tree, byte regi,LOCAL_ID *locsym)
bool insertSubTreeReg (COND_EXPR *expr, COND_EXPR **tree, byte regi,LOCAL_ID *locsym)
{
byte treeReg;
@ -904,29 +885,33 @@ boolT insertSubTreeReg (COND_EXPR *expr, COND_EXPR **tree, byte regi,LOCAL_ID *l
/* Inserts the expression exp into the tree at the location specified by the
* long register index longIdx*/
boolT insertSubTreeLongReg (COND_EXPR *exp, COND_EXPR **tree, Int longIdx)
bool insertSubTreeLongReg(COND_EXPR *exp, COND_EXPR **tree, Int longIdx)
{
switch ((*tree)->type) {
case IDENTIFIER: if ((*tree)->expr.ident.idNode.longIdx == longIdx)
switch ((*tree)->type)
{
case IDENTIFIER:
if ((*tree)->expr.ident.idNode.longIdx == longIdx)
{
*tree = exp;
return TRUE;
return true;
}
return FALSE;
return false;
case BOOLEAN_OP: if (insertSubTreeLongReg (exp, &(*tree)->expr.boolExpr.lhs, longIdx))
return TRUE;
case BOOLEAN_OP:
if (insertSubTreeLongReg (exp, &(*tree)->expr.boolExpr.lhs, longIdx))
return true;
if (insertSubTreeLongReg (exp, &(*tree)->expr.boolExpr.rhs, longIdx))
return TRUE;
return FALSE;
return true;
return false;
case NEGATION:
case ADDRESSOF:
case DEREFERENCE: if (insertSubTreeLongReg (exp, &(*tree)->expr.unaryExp, longIdx))
return TRUE;
return FALSE;
case DEREFERENCE:
if (insertSubTreeLongReg (exp, &(*tree)->expr.unaryExp, longIdx))
return true;
return false;
}
return FALSE;
return false;
}

View File

@ -127,12 +127,14 @@ static void printGlobVar (SYM * psym)
prog.Image[relocOp+1], prog.Image[relocOp+2],
prog.Image[relocOp+3]);
break;
default:strContents = (char *)allocMem((psym->size*2+1) *sizeof(char));
default:
strContents = (char *)malloc((psym->size*2+1) *sizeof(char));
strContents[0] = '\0';
for (j=0; j < psym->size; j++)
strcat (strContents, cChar(prog.Image[relocOp + j]));
cCode.appendDecl( "char\t*%s = \"%s\";\n",
psym->name, strContents);
free(strContents);
}
}
@ -362,20 +364,17 @@ static void backBackEnd (char *filename, CALL_GRAPH * pcallGraph, std::ostream &
/* Invokes the necessary routines to produce code one procedure at a time. */
void BackEnd (char *fileName, CALL_GRAPH * pcallGraph)
{
char* outName, *ext;
std::ofstream fs; /* Output C file */
/* Get output file name */
outName = strcpy ((char*)allocMem(strlen(fileName)+1), fileName);
if ((ext = strrchr (outName, '.')) != NULL)
*ext = '\0';
strcat (outName, ".b"); /* b for beta */
std::string outNam(fileName);
outNam = outNam.substr(0,outNam.rfind("."))+".b"; /* b for beta */
/* Open output file */
fs.open(outName);
fs.open(outNam);
if(!fs.is_open())
fatalError (CANNOT_OPEN, outName);
printf ("dcc: Writing C beta file %s\n", outName);
fatalError (CANNOT_OPEN, outNam.c_str());
printf ("dcc: Writing C beta file %s\n", outNam.c_str());
/* Header information */
writeHeader (fs, fileName);

View File

@ -55,7 +55,7 @@ static word *T1base, *T2base; /* Pointers to start of T1, T2 */
static word *g; /* g[] */
static HT *ht; /* The hash table */
static PH_FUNC_STRUCT *pFunc; /* Points to the array of func names */
static hlType *pArg; /* Points to the array of param types */
static hlType *pArg=0; /* Points to the array of param types */
static int numFunc; /* Number of func names actually stored */
static int numArg; /* Number of param names actually stored */
#define DCCLIBS "dcclibs.dat" /* Name of the prototypes data file */
@ -390,7 +390,8 @@ void SetupLibCheck(void)
/* This is now the hash table */
/* First allocate space for the table */
if ((ht = (HT *)allocMem(numKeys * sizeof(HT))) == 0)
ht = new HT[numKeys];
if ( 0 == ht)
{
printf("Could not allocate hash table\n");
exit(1);
@ -422,19 +423,18 @@ void SetupLibCheck(void)
}
void
CleanupLibCheck(void)
void CleanupLibCheck(void)
{
/* Deallocate all the stuff allocated in SetupLibCheck() */
if (ht) free(ht);
if (pFunc)free(pFunc);
delete [] ht;
delete [] pFunc;
}
/* Check this function to see if it is a library function. Return TRUE if
it is, and copy its name to pProc->name
*/
boolT LibCheck(Function & pProc)
bool LibCheck(Function & pProc)
{
long fileOffset;
int h, i, j, arg;
@ -904,7 +904,7 @@ readProtoFile(void)
numFunc = readFileShort(fProto); /* Num of entries to allocate */
/* Allocate exactly correct # entries */
pFunc = (PH_FUNC_STRUCT*) allocMem(numFunc * sizeof(PH_FUNC_STRUCT));
pFunc = new PH_FUNC_STRUCT[numFunc];
for (i=0; i < numFunc; i++)
{
@ -925,7 +925,8 @@ readProtoFile(void)
numArg = readFileShort(fProto); /* Num of entries to allocate */
/* Allocate exactly correct # entries */
pArg = (hlType*) allocMem(numArg * sizeof(hlType));
delete [] pArg;
pArg = new hlType[numArg];
for (i=0; i < numArg; i++)
{

View File

@ -76,10 +76,8 @@ void Function::findImmedDom ()
currNode = dfsLast[currIdx];
if (currNode->flg & INVALID_BB) /* Do not process invalid BBs */
continue;
for (j = 0; j < currNode->inEdges.size(); j++)
for (BB * inedge : currNode->inEdges)
{
BB* inedge=currNode->inEdges[j];
predIdx = inedge->dfsLastNum;
if (predIdx < currIdx)
currNode->immedDom = commonDom (currNode->immedDom, predIdx, this);
@ -257,14 +255,12 @@ static void findNodesInInt (queue &intNodes, Int level, interval *Ii)
{
if (level == 1)
{
std::for_each(Ii->nodes.begin(),Ii->nodes.end(),[&intNodes](BB *en)->void {
for(BB *en : Ii->nodes)
appendQueue(intNodes,en);
});
}
else
std::for_each(Ii->nodes.begin(),Ii->nodes.end(),[&intNodes,level](BB *en)->void {
for(BB *en : Ii->nodes)
findNodesInInt(intNodes,level-1,en->correspInt);
});
}
@ -339,10 +335,11 @@ void Function::structLoops(derSeq *derivedG)
}
static boolT successor (Int s, Int h, Function * pProc)
/* Returns whether the BB indexed by s is a successor of the BB indexed by
* h. Note that h is a case node. */
{ Int i;
static boolT successor (Int s, Int h, Function * pProc)
{
Int i;
BB * header;
header = pProc->dfsLast[h];
@ -406,9 +403,10 @@ void Function::structCases()
* header field with caseHeader. */
insertList (caseNodes, i);
dfsLast[i]->caseHead = i;
std::for_each(caseHeader->edges.begin(),caseHeader->edges.end(),
[&caseNodes, i, exitNode](TYPEADR_TYPE &pb)
{tagNodesInCase(pb.BBptr, caseNodes, i, exitNode);});
for(TYPEADR_TYPE &pb : caseHeader->edges)
{
tagNodesInCase(pb.BBptr, caseNodes, i, exitNode);
}
//for (j = 0; j < caseHeader->edges[j]; j++)
// tagNodesInCase (caseHeader->edges[j].BBptr, caseNodes, i, exitNode);
if (exitNode != NO_NODE)

View File

@ -70,7 +70,8 @@ ExpStack g_exp_stk;
/* Returns the index of the local variable or parameter at offset off, if it
* is in the stack frame provided. */
Int STKFRAME::getLocVar(Int off)
{ Int i;
{
Int i;
for (i = 0; i < sym.size(); i++)
if (sym[i].off == off)

View File

@ -129,13 +129,13 @@ NextArg:;
{
if (! asm1_name)
{
asm1_name = strcpy((char*)allocMem(strlen(*argv)+4), *argv);
asm1_name = strcpy((char*)malloc(strlen(*argv)+4), *argv);
pc = strrchr(asm1_name, '.');
if (pc > strrchr(asm1_name, '/'))
{
*pc = '\0';
}
asm2_name = (char*)allocMem(strlen(asm1_name)+4) ;
asm2_name = (char*)malloc(strlen(asm1_name)+4) ;
strcat(strcpy(asm2_name, asm1_name), ".a2");
unlink(asm2_name);
strcat(asm1_name, ".a1");

View File

@ -215,7 +215,7 @@ void disassem(Int pass, Function * ppProc)
JmpInst(pc[i].ic.ll.opcode))
{
/* Replace the immediate operand with an icode index */
if (labelSrch(pc,numIcode, pc[i].ic.ll.immed.op,(Int *)&pc[i].ic.ll.immed.op))
if (pc.labelSrch(pc[i].ic.ll.immed.op,pc[i].ic.ll.immed.op))
{
/* This icode is the target of a jump */
pc[pc[i].ic.ll.immed.op].ic.ll.flg |= TARGET;

View File

@ -40,7 +40,7 @@ static const char *errorMessage[] = {
/****************************************************************************
fatalError: displays error message and exits the program.
****************************************************************************/
void fatalError(Int errId, ...)
void fatalError(eErrorId errId, ...)
{ va_list args;
//#ifdef __UNIX__ /* ultrix */
#if 0
@ -66,7 +66,7 @@ void fatalError(Int errId, ...)
/****************************************************************************
reportError: reports the warning/error and continues with the program.
****************************************************************************/
void reportError(Int errId, ...)
void reportError(eErrorId errId, ...)
{ va_list args;
//#ifdef __UNIX__ /* ultrix */
#if 0

View File

@ -79,19 +79,20 @@ void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
}
/* Search through code looking for impure references and flag them */
std::for_each(pProcList.begin(),pProcList.end(),
[](Function &f)->void {
for(Function &f : pProcList)
{
f.markImpure();
if (option.asm1)
disassem(1, &f); });
disassem(1, &f);
}
if (option.Interact)
{
interactDis(&pProcList.front(), 0); /* Interactive disassembler */
}
/* Converts jump target addresses to icode offsets */
std::for_each(pProcList.begin(),pProcList.end(),
[](Function &f)->void { f.bindIcodeOff(); });
for(Function &f : pProcList)
f.bindIcodeOff();
/* Print memory bitmap */
if (option.Map)
@ -249,7 +250,7 @@ static void LoadImage(char *filename)
/* Allocate the relocation table */
if (prog.cReloc)
{
prog.relocTable = (dword*)allocMem(prog.cReloc * sizeof(Int));
prog.relocTable = new dword [prog.cReloc];
fseek(fp, LH(&header.relocTabOffset), SEEK_SET);
/* Read in seg:offset pairs and convert to Image ptrs */
@ -285,7 +286,7 @@ static void LoadImage(char *filename)
/* Allocate a block of memory for the program. */
prog.cbImage = cb + sizeof(PSP);
prog.Image = (byte*)allocMem(prog.cbImage);
prog.Image = new byte [prog.cbImage];
prog.Image[0] = 0xCD; /* Fill in PSP Int 20h location */
prog.Image[1] = 0x20; /* for termination checking */
@ -304,7 +305,8 @@ static void LoadImage(char *filename)
/* Set up memory map */
cb = (prog.cbImage + 3) / 4;
prog.map = (byte *)memset(allocMem(cb), BM_UNKNOWN, (size_t)cb);
prog.map = (byte *)malloc(cb);
memset(prog.map, BM_UNKNOWN, (size_t)cb);
/* Relocate segment constants */
if (prog.cReloc)
@ -336,37 +338,6 @@ void *allocMem(Int cb)
{
fatalError(MALLOC_FAILED, cb);
}
/*printf("allocMem: %p\n", p);/**/
// printf("allocMem: %p\n", p);
return p;
}
/*****************************************************************************
* reallocVar - reallocs extra variable space
****************************************************************************/
void *reallocVar(void *p, Int newsize)
{
/*printf("Attempt to reallocVar %5d bytes\n", newsize);/**/
if (! (p = realloc((byte *)p, (size_t)newsize)))
{
fatalError(MALLOC_FAILED, newsize);
}
/*printf("reallocVar: %p\n", p);/**/
return p;
}
#if 0
void free(void *p)
{
_ffree(p);
switch (_heapset('Z'))
{
case _HEAPBADBEGIN: printf("f: Bad heap begin\n"); getchar(); break;
case _HEAPBADNODE: printf("f: Bad heap node\n"); getchar(); break;
case _HEAPEMPTY: printf("f: Heap empty\n"); getchar(); break;
case _HEAPOK:putchar('!');break;
}/**/
}
#endif

View File

@ -189,7 +189,8 @@ void Function::markImpure()
****************************************************************************/
void Function::freeCFG()
{
std::for_each(heldBBs.begin(),heldBBs.end(),[](BB *p)->void {delete p;});
for(BB *p : heldBBs)
delete p;
}
@ -369,15 +370,14 @@ void BB::mergeFallThrough( CIcodeRec &Icode)
void BB::dfsNumbering(std::vector<BB *> &dfsLast, Int *first, Int *last)
{
BB * pChild;
byte i;
traversed = DFS_NUM;
dfsFirstNum = (*first)++;
/* index is being used as an index to inEdges[]. */
for (i = 0; i < edges.size(); i++)
// for (i = 0; i < edges.size(); i++)
for (auto edge : edges)
{
pChild = edges[i].BBptr;
pChild = edge.BBptr;
pChild->inEdges[pChild->index++] = this;
/* Is this the last visit? */

View File

@ -157,7 +157,8 @@ void Function::highLevelGen()
lhs = COND_EXPR::id (*pIcode, DST, this, i, *pIcode, NONE);
}
switch (pIcode->ic.ll.opcode) {
switch (pIcode->ic.ll.opcode)
{
case iADD:
rhs = COND_EXPR::boolOp (lhs, rhs, ADD);
pIcode->setAsgn(lhs, rhs);
@ -196,12 +197,14 @@ void Function::highLevelGen()
pIcode->setAsgn(lhs, rhs);
break;
case iIMUL: rhs = COND_EXPR::boolOp (lhs, rhs, MUL);
case iIMUL:
rhs = COND_EXPR::boolOp (lhs, rhs, MUL);
lhs = COND_EXPR::id (*pIcode, LHS_OP, this, i, *pIcode, NONE);
pIcode->setAsgn(lhs, rhs);
break;
case iINC: rhs = COND_EXPR::idKte (1, 2);
case iINC:
rhs = COND_EXPR::idKte (1, 2);
rhs = COND_EXPR::boolOp (lhs, rhs, ADD);
pIcode->setAsgn(lhs, rhs);
break;
@ -227,7 +230,8 @@ void Function::highLevelGen()
case iMOV: pIcode->setAsgn(lhs, rhs);
break;
case iMUL: rhs = COND_EXPR::boolOp (lhs, rhs, MUL);
case iMUL:
rhs = COND_EXPR::boolOp (lhs, rhs, MUL);
lhs = COND_EXPR::id (*pIcode, LHS_OP, this, i, *pIcode, NONE);
pIcode->setAsgn(lhs, rhs);
break;
@ -236,11 +240,13 @@ void Function::highLevelGen()
pIcode->setAsgn(lhs, rhs);
break;
case iNOT: rhs = COND_EXPR::boolOp (NULL, rhs, NOT);
case iNOT:
rhs = COND_EXPR::boolOp (NULL, rhs, NOT);
pIcode->setAsgn(lhs, rhs);
break;
case iOR: rhs = COND_EXPR::boolOp (lhs, rhs, OR);
case iOR:
rhs = COND_EXPR::boolOp (lhs, rhs, OR);
pIcode->setAsgn(lhs, rhs);
break;
@ -259,7 +265,8 @@ void Function::highLevelGen()
break;
case iSAR: /* signed */
case iSHR: rhs = COND_EXPR::boolOp (lhs, rhs, SHR); /* unsigned*/
case iSHR:
rhs = COND_EXPR::boolOp (lhs, rhs, SHR); /* unsigned*/
pIcode->setAsgn(lhs, rhs);
break;

View File

@ -15,6 +15,7 @@
CIcodeRec::CIcodeRec()
{
//reserve(512);
}
CIcodeRec::~CIcodeRec()
@ -100,7 +101,7 @@ llIcode CIcodeRec::GetLlOpcode(int ip)
/* labelSrchRepl - Searches the icodes for instruction with label = target, and
replaces *pIndex with an icode index */
boolT CIcodeRec::labelSrch(dword target, Int *pIndex)
bool CIcodeRec::labelSrch(dword target, dword &pIndex)
{
Int i;
@ -108,7 +109,7 @@ boolT CIcodeRec::labelSrch(dword target, Int *pIndex)
{
if (at(i).ic.ll.label == target)
{
*pIndex = i;
pIndex = i;
return TRUE;
}
}

View File

@ -13,7 +13,7 @@
/*****************************************************************************
* JmpInst - Returns TRUE if opcode is a conditional or unconditional jump
****************************************************************************/
boolT JmpInst(llIcode opcode)
bool JmpInst(llIcode opcode)
{
switch (opcode) {
case iJMP: case iJMPF: case iJCXZ:
@ -22,9 +22,9 @@ boolT JmpInst(llIcode opcode)
case iJL: case iJLE: case iJGE: case iJG:
case iJE: case iJNE: case iJS: case iJNS:
case iJO: case iJNO: case iJP: case iJNP:
return TRUE;
return true;
}
return FALSE;
return false;
}
@ -1418,9 +1418,9 @@ void Function::findIdioms()
* binds jump target addresses to icode offsets. */
void Function::bindIcodeOff()
{
Int i, j; /* idx into icode array */
Int i; /* idx into icode array */
iICODE pIcode; /* ptr icode array */
dword *p; /* for case table */
dword *p,j; /* for case table */
if (! Icode.GetNumIcodes()) /* No Icode */
return;
@ -1430,7 +1430,7 @@ void Function::bindIcodeOff()
for (i = 0; i < Icode.GetNumIcodes(); i++)
if ((pIcode[i].ic.ll.flg & I) && JmpInst(pIcode[i].ic.ll.opcode))
{
if (Icode.labelSrch(pIcode[i].ic.ll.immed.op, &j))
if (Icode.labelSrch(pIcode[i].ic.ll.immed.op, j))
{
pIcode[j].ic.ll.flg |= TARGET;
}
@ -1445,14 +1445,14 @@ void Function::bindIcodeOff()
{
if (pIcode->ic.ll.flg & I)
{
if (! Icode.labelSrch(pIcode->ic.ll.immed.op, (Int *)&pIcode->ic.ll.immed.op))
if (! Icode.labelSrch(pIcode->ic.ll.immed.op, pIcode->ic.ll.immed.op))
pIcode->ic.ll.flg |= NO_LABEL;
}
else if (pIcode->ic.ll.flg & SWITCH)
{
p = pIcode->ic.ll.caseTbl.entries;
for (j = 0; j < pIcode->ic.ll.caseTbl.numEntries; j++, p++)
Icode.labelSrch(*p, (Int *)p);
Icode.labelSrch(*p, *p);
}
}
}

View File

@ -121,9 +121,9 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
ICODE eIcode; /* extra icodes for iDIV, iIDIV, iXCHG */
SYM * psym;
dword offset;
Int err;
eErrorId err;
boolT done = FALSE;
Int lab;
dword lab;
if (strstr(name, "chkstk") != NULL)
{
@ -151,7 +151,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
flg |= (_Icode.ic.ll.flg & (NOT_HLL | FLOAT_OP));
/* Check if this instruction has already been parsed */
if (Icode.labelSrch(_Icode.ic.ll.label, &lab))
if (Icode.labelSrch(_Icode.ic.ll.label, lab))
{ /* Synthetic jump */
_Icode.type = LOW_LEVEL;
_Icode.ic.ll.opcode = iJMP;
@ -397,7 +397,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr
ICODE _Icode;
dword cs, offTable, endTable;
dword i, k, seg, target;
Int tmp;
dword tmp;
if (pIcode->ic.ll.flg & I)
{
@ -410,7 +410,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr
}
/* Return TRUE if jump target is already parsed */
return Icode.labelSrch(i, &tmp);
return Icode.labelSrch(i, tmp);
}
/* We've got an indirect JMP - look for switch() stmt. idiom of the form
@ -854,7 +854,7 @@ void STATE::setState(word reg, int16 value)
/* labelSrchRepl - Searches Icode for instruction with label = target, and
replaces *pIndex with an icode index */
boolT labelSrch(CIcodeRec &pIcode, Int numIp, dword target, Int *pIndex)
bool labelSrch(CIcodeRec &pIcode, Int numIp, dword target, Int *pIndex)
{
Int i;
@ -863,10 +863,10 @@ boolT labelSrch(CIcodeRec &pIcode, Int numIp, dword target, Int *pIndex)
if (pIcode[i].ic.ll.label == target)
{
*pIndex = i;
return TRUE;
return true;
}
}
return FALSE;
return false;
}

View File

@ -30,10 +30,9 @@ void CALL_GRAPH::insertArc (ilFunction newProc)
Int i;
/* Check if procedure already exists */
for (i = 0; i < outEdges.size(); i++)
if (outEdges[i]->proc == newProc)
auto res=std::find_if(outEdges.begin(),outEdges.end(),[newProc](CALL_GRAPH *e) {return e->proc==newProc;});
if(res!=outEdges.end())
return;
/* Include new arc */
pcg = new CALL_GRAPH;
pcg->proc = newProc;
@ -275,16 +274,18 @@ void placeStkArg (ICODE *picode, COND_EXPR *exp, Int pos)
* same type as the given type (from the procedure's formal list). If not,
* the actual argument gets modified */
void adjustActArgType (COND_EXPR *exp, hlType forType, Function * pproc)
{ hlType actType;
{
hlType actType;
Int offset, offL;
if (exp == NULL)
return;
actType = expType (exp, pproc);
if ((actType != forType) && (exp->type == IDENTIFIER))
if (((actType == forType) || (exp->type != IDENTIFIER)))
return;
switch (forType)
{
switch (forType) {
case TYPE_UNKNOWN: case TYPE_BYTE_SIGN:
case TYPE_BYTE_UNSIGN: case TYPE_WORD_SIGN:
case TYPE_WORD_UNSIGN: case TYPE_LONG_SIGN:
@ -322,7 +323,6 @@ void adjustActArgType (COND_EXPR *exp, hlType forType, Function * pproc)
break;
}
}
}
/* Determines whether the formal argument has the same type as the given

View File

@ -237,7 +237,8 @@ void Function::propLongStk (Int i, ID *pLocId)
if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
{
switch (pIcode->ic.ll.opcode) {
switch (pIcode->ic.ll.opcode)
{
case iMOV:
if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
&rhs, &lhs, 1) == TRUE)
@ -252,7 +253,8 @@ void Function::propLongStk (Int i, ID *pLocId)
if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
&rhs, &lhs, 1) == TRUE)
{
switch (pIcode->ic.ll.opcode) {
switch (pIcode->ic.ll.opcode)
{
case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
break;
case iOR: rhs = COND_EXPR::boolOp (lhs, rhs, OR);
@ -296,32 +298,107 @@ void Function::propLongStk (Int i, ID *pLocId)
}
}
}
void checkBack();
//int Function::checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx)
//{
// int idx;
// for (idx = pLocId_idx - 1; idx > 0 ; idx--)
// {
// pIcode = Icode.begin()+(idx-1);
// if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
// continue;
// if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode)
// continue;
// switch (pIcode->ic.ll.opcode)
// {
// case iMOV:
// pmH = &pIcode->ic.ll.dst;
// pmL = &(pIcode+1)->ic.ll.dst;
// if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
// {
// lhs = COND_EXPR::idLongIdx (i);
// this->localId.id_arr[i].idx.push_back(idx-1);
// pIcode->setRegDU( pmL->regi, eDEF);
// rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
// pIcode->setAsgn(lhs, rhs);
// (pIcode+1)->invalidate();
// idx = 0; /* to exit the loop */
// }
// break;
// case iPOP:
// pmH = &(pIcode+1)->ic.ll.dst;
// pmL = &pIcode->ic.ll.dst;
// if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
// {
// lhs = COND_EXPR::idLongIdx (i);
// pIcode->setRegDU( pmH->regi, eDEF);
// pIcode->setUnary(HLI_POP, lhs);
// (pIcode+1)->invalidate();
// idx = 0; /* to exit the loop */
// }
// break;
// /**** others missing ***/
// case iAND: case iOR: case iXOR:
// pmL = &pIcode->ic.ll.dst;
// pmH = &(pIcode+1)->ic.ll.dst;
// if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
// {
// lhs = COND_EXPR::idLongIdx (i);
// pIcode->setRegDU( pmH->regi, USE_DEF);
// rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
// switch (pIcode->ic.ll.opcode) {
// case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
// break;
// case iOR:
// rhs = COND_EXPR::boolOp (lhs, rhs, OR);
// break;
// case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
// break;
// } /* eos */
// pIcode->setAsgn(lhs, rhs);
// (pIcode+1)->invalidate();
// idx = 0;
// }
// break;
// } /* eos */
// }
//}
/* Finds the definition of the long register pointed to by pLocId, and
* transforms that instruction into a HIGH_LEVEL icode instruction.
* Arguments: i : index into the local identifier table
* pLocId: ptr to the long local identifier
* pProc : ptr to current procedure's record. */
void Function::propLongReg (Int i, ID *pLocId)
void Function::propLongReg (Int loc_ident_idx, ID *pLocId)
{
COND_EXPR *lhs, *rhs;
Int idx, j, off, arc;
iICODE pIcode, pEnd;
ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
Int idx;
iICODE pEnd;
/* Process all definitions/uses of long registers at an icode position */
pEnd = this->Icode.end();
for (j = 0; j < pLocId->idx.size(); j++)
// for (int pLocId_idx : pLocId->idx)
// WARNING: this loop modifies the iterated-over container.
for (int j = 0; j < pLocId->idx.size(); j++)
{
int pLocId_idx=pLocId->idx[j];
/* Check backwards for a definition of this long register */
for (idx = pLocId->idx[j] - 1; idx > 0 ; idx--)
COND_EXPR *lhs, *rhs;
for (idx = pLocId_idx - 1; idx > 0 ; idx--)
{
iICODE pIcode;
ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
pIcode = Icode.begin()+(idx-1);
if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
continue;
if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode)
continue;
switch (pIcode->ic.ll.opcode)
{
case iMOV:
@ -329,8 +406,8 @@ void Function::propLongReg (Int i, ID *pLocId)
pmL = &(pIcode+1)->ic.ll.dst;
if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
{
lhs = COND_EXPR::idLongIdx (i);
this->localId.id_arr[i].idx.push_back(idx-1);
lhs = COND_EXPR::idLongIdx (loc_ident_idx);
this->localId.id_arr[loc_ident_idx].idx.push_back(idx-1);
pIcode->setRegDU( pmL->regi, eDEF);
rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
pIcode->setAsgn(lhs, rhs);
@ -344,7 +421,7 @@ void Function::propLongReg (Int i, ID *pLocId)
pmL = &pIcode->ic.ll.dst;
if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
{
lhs = COND_EXPR::idLongIdx (i);
lhs = COND_EXPR::idLongIdx (loc_ident_idx);
pIcode->setRegDU( pmH->regi, eDEF);
pIcode->setUnary(HLI_POP, lhs);
(pIcode+1)->invalidate();
@ -359,7 +436,7 @@ void Function::propLongReg (Int i, ID *pLocId)
pmH = &(pIcode+1)->ic.ll.dst;
if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
{
lhs = COND_EXPR::idLongIdx (i);
lhs = COND_EXPR::idLongIdx (loc_ident_idx);
pIcode->setRegDU( pmH->regi, USE_DEF);
rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
switch (pIcode->ic.ll.opcode) {
@ -368,7 +445,8 @@ void Function::propLongReg (Int i, ID *pLocId)
case iOR:
rhs = COND_EXPR::boolOp (lhs, rhs, OR);
break;
case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
case iXOR:
rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
break;
} /* eos */
pIcode->setAsgn(lhs, rhs);
@ -378,12 +456,14 @@ void Function::propLongReg (Int i, ID *pLocId)
break;
} /* eos */
}
/* If no definition backwards, check forward for a use of this long reg */
if (idx > 0)
continue;
for (idx = pLocId->idx[j] + 1; idx < Icode.size() - 1; idx++)
for (idx = pLocId_idx + 1; idx < Icode.size() - 1; idx++)
{
iICODE pIcode;
ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
int off,arc;
pIcode = Icode.begin()+(idx);
if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
continue;
@ -394,7 +474,7 @@ void Function::propLongReg (Int i, ID *pLocId)
if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
(pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
{
rhs = COND_EXPR::idLongIdx (i);
rhs = COND_EXPR::idLongIdx (loc_ident_idx);
pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
lhs = COND_EXPR::idLong (&this->localId, DST, pIcode,
HIGH_FIRST, idx, eDEF, 1);
@ -408,7 +488,7 @@ void Function::propLongReg (Int i, ID *pLocId)
if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
(pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
{
rhs = COND_EXPR::idLongIdx (i);
rhs = COND_EXPR::idLongIdx (loc_ident_idx);
pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
pIcode->setUnary(HLI_PUSH, lhs);
(pIcode+1)->invalidate();
@ -424,7 +504,7 @@ void Function::propLongReg (Int i, ID *pLocId)
if ((pLocId->id.longId.h == pmH->regi) &&
(pLocId->id.longId.l == pmL->regi))
{
lhs = COND_EXPR::idLongIdx (i);
lhs = COND_EXPR::idLongIdx (loc_ident_idx);
pIcode->setRegDU( pmH->regi, USE_DEF);
rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode,
LOW_FIRST, idx, eUSE, 1);
@ -447,7 +527,7 @@ void Function::propLongReg (Int i, ID *pLocId)
else if ((pIcode->ic.ll.opcode == iCMP) &&
(isLong23 (idx, pIcode->inBB, &off, &arc)))
{
if (checkLongRegEq (pLocId->id.longId, pIcode, i, idx, this,
if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this,
&rhs, &lhs, off) == TRUE)
longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off);
}
@ -457,7 +537,7 @@ void Function::propLongReg (Int i, ID *pLocId)
else if ((pIcode->ic.ll.opcode == iCMP) &&
(isLong22 (pIcode, pEnd, &off)))
{
if (checkLongRegEq (pLocId->id.longId, pIcode, i, idx, this,
if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this,
&rhs, &lhs, off) == TRUE)
longJCond22 (rhs, lhs, pIcode, &idx);
}
@ -472,7 +552,7 @@ void Function::propLongReg (Int i, ID *pLocId)
if ((pIcode->ic.ll.dst.regi == pLocId->id.longId.h) &&
(pIcode->ic.ll.src.regi == pLocId->id.longId.l))
{
lhs = COND_EXPR::idLongIdx (i);
lhs = COND_EXPR::idLongIdx (loc_ident_idx);
rhs = COND_EXPR::idKte (0, 4); /* long 0 */
lhs = COND_EXPR::boolOp (lhs, rhs,

View File

@ -42,12 +42,11 @@ static BB *firstOfQueue (queue &Q)
queue::iterator appendQueue (queue &Q, BB *node)
{
auto iter=std::find(Q.begin(),Q.end(),node);
if(iter==Q.end())
{
if(iter!=Q.end())
return iter;
Q.push_back(node);
iter=Q.end();
--iter;
}
return iter;
}
@ -248,7 +247,7 @@ bool Function::nextOrderGraph (derSeq *derivedGi)
*curr, /* BB being checked for out edges */
*succ /* Successor node */
;
queue *listIi; /* List of intervals */
//queue *listIi; /* List of intervals */
Int i, /* Index to outEdges array */
j; /* Index to successors */
boolT sameGraph; /* Boolean, isomorphic graphs */
@ -277,9 +276,8 @@ bool Function::nextOrderGraph (derSeq *derivedGi)
if (BBnode->edges.size() > 0)
{
for(auto iter=listIi.begin();iter!=listIi.end(); ++iter)
for(BB *curr : listIi)
{
curr = *iter;
for (j = 0; j < curr->edges.size(); j++)
{
succ = curr->edges[j].BBptr;
@ -297,12 +295,11 @@ bool Function::nextOrderGraph (derSeq *derivedGi)
* Determines the number of in edges to each new BB, and places it
* in numInEdges and inEdgeCount for later interval processing. */
curr = new_entry.Gi = bbs.front();
for(auto curr=bbs.begin(); curr!=bbs.end(); ++curr)
for(BB *curr : bbs)
{
for (i = 0; i < (*curr)->edges.size(); i++)
for(TYPEADR_TYPE &edge : curr->edges)
{
BBnode = new_entry.Gi; /* BB of an interval */
TYPEADR_TYPE &edge=(*curr)->edges[i];
auto iter= std::find_if(bbs.begin(),bbs.end(),
[&edge](BB *node)->bool { return edge.intPtr==node->correspInt;});
if(iter==bbs.end())

View File

@ -5,9 +5,40 @@
* (C) Cristina Cifuentes, Jeff Ledermann
****************************************************************************/
#include <cstring>
#include "dcc.h"
#include "scanner.h"
#include <string.h>
static void rm(Int i);
static void modrm(Int i);
static void segrm(Int i);
static void data1(Int i);
static void data2(Int i);
static void regop(Int i);
static void segop(Int i);
static void strop(Int i);
static void escop(Int i);
static void axImp(Int i);
static void alImp(Int i);
static void axSrcIm(Int i);
static void memImp(Int i);
static void memReg0(Int i);
static void memOnly(Int i);
static void dispM(Int i);
static void dispS(Int i);
static void dispN(Int i);
static void dispF(Int i);
static void prefix(Int i);
static void immed(Int i);
static void shift(Int i);
static void arith(Int i);
static void trans(Int i);
static void const1(Int i);
static void const3(Int i);
static void none1(Int i);
static void none2(Int i);
static void checkInt(Int i);
#define iZERO (llIcode)0 // For neatness
#define IC llIcode
@ -20,120 +51,120 @@ static struct {
byte df;
byte uf;
} stateTable[] = {
{ modrm, none2, B , iADD , Sf | Zf | Cf, }, /* 00 */
{ modrm, none2, 0 , iADD , Sf | Zf | Cf, }, /* 01 */
{ modrm, none2, TO_REG | B , iADD , Sf | Zf | Cf, }, /* 02 */
{ modrm, none2, TO_REG , iADD , Sf | Zf | Cf, }, /* 03 */
{ data1, axImp, B , iADD , Sf | Zf | Cf, }, /* 04 */
{ data2, axImp, 0 , iADD , Sf | Zf | Cf, }, /* 05 */
{ segop, none2, NO_SRC , iPUSH , 0 , }, /* 06 */
{ segop, none2, NO_SRC , iPOP , 0 , }, /* 07 */
{ modrm, none2, B , iOR , Sf | Zf | Cf, }, /* 08 */
{ modrm, none2, NSP , iOR , Sf | Zf | Cf, }, /* 09 */
{ modrm, none2, TO_REG | B , iOR , Sf | Zf | Cf, }, /* 0A */
{ modrm, none2, TO_REG | NSP , iOR , Sf | Zf | Cf, }, /* 0B */
{ data1, axImp, B , iOR , Sf | Zf | Cf, }, /* 0C */
{ data2, axImp, 0 , iOR , Sf | Zf | Cf, }, /* 0D */
{ segop, none2, NO_SRC , iPUSH , 0 , }, /* 0E */
{ none1, none2, OP386 , iZERO , 0 , }, /* 0F */
{ modrm, none2, B , iADD , Sf | Zf | Cf , 0 }, /* 00 */
{ modrm, none2, 0 , iADD , Sf | Zf | Cf , 0 }, /* 01 */
{ modrm, none2, TO_REG | B , iADD , Sf | Zf | Cf , 0 }, /* 02 */
{ modrm, none2, TO_REG , iADD , Sf | Zf | Cf , 0 }, /* 03 */
{ data1, axImp, B , iADD , Sf | Zf | Cf , 0 }, /* 04 */
{ data2, axImp, 0 , iADD , Sf | Zf | Cf , 0 }, /* 05 */
{ segop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 06 */
{ segop, none2, NO_SRC , iPOP , 0 , 0 }, /* 07 */
{ modrm, none2, B , iOR , Sf | Zf | Cf , 0 }, /* 08 */
{ modrm, none2, NSP , iOR , Sf | Zf | Cf , 0 }, /* 09 */
{ modrm, none2, TO_REG | B , iOR , Sf | Zf | Cf , 0 }, /* 0A */
{ modrm, none2, TO_REG | NSP , iOR , Sf | Zf | Cf , 0 }, /* 0B */
{ data1, axImp, B , iOR , Sf | Zf | Cf , 0 }, /* 0C */
{ data2, axImp, 0 , iOR , Sf | Zf | Cf , 0 }, /* 0D */
{ segop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 0E */
{ none1, none2, OP386 , iZERO , 0 , 0 }, /* 0F */
{ modrm, none2, B , iADC , Sf | Zf | Cf , Cf }, /* 10 */
{ modrm, none2, NSP , iADC , Sf | Zf | Cf , Cf }, /* 11 */
{ modrm, none2, TO_REG | B , iADC , Sf | Zf | Cf , Cf }, /* 12 */
{ modrm, none2, TO_REG | NSP , iADC , Sf | Zf | Cf , Cf }, /* 13 */
{ data1, axImp, B , iADC , Sf | Zf | Cf , Cf }, /* 14 */
{ data2, axImp, 0 , iADC , Sf | Zf | Cf , Cf }, /* 15 */
{ segop, none2, NOT_HLL | NO_SRC , iPUSH , 0 , }, /* 16 */
{ segop, none2, NOT_HLL | NO_SRC , iPOP , 0 , }, /* 17 */
{ segop, none2, NOT_HLL | NO_SRC , iPUSH , 0 , 0 }, /* 16 */
{ segop, none2, NOT_HLL | NO_SRC , iPOP , 0 , 0 }, /* 17 */
{ modrm, none2, B , iSBB , Sf | Zf | Cf , Cf }, /* 18 */
{ modrm, none2, NSP , iSBB , Sf | Zf | Cf , Cf }, /* 19 */
{ modrm, none2, TO_REG | B , iSBB , Sf | Zf | Cf , Cf }, /* 1A */
{ modrm, none2, TO_REG | NSP , iSBB , Sf | Zf | Cf , Cf }, /* 1B */
{ data1, axImp, B , iSBB , Sf | Zf | Cf , Cf }, /* 1C */
{ data2, axImp, 0 , iSBB , Sf | Zf | Cf , Cf }, /* 1D */
{ segop, none2, NO_SRC , iPUSH , 0 , }, /* 1E */
{ segop, none2, NO_SRC , iPOP , 0 , }, /* 1F */
{ modrm, none2, B , iAND , Sf | Zf | Cf, }, /* 20 */
{ modrm, none2, NSP , iAND , Sf | Zf | Cf, }, /* 21 */
{ modrm, none2, TO_REG | B , iAND , Sf | Zf | Cf, }, /* 22 */
{ modrm, none2, TO_REG | NSP , iAND , Sf | Zf | Cf, }, /* 23 */
{ data1, axImp, B , iAND , Sf | Zf | Cf, }, /* 24 */
{ data2, axImp, 0 , iAND , Sf | Zf | Cf, }, /* 25 */
{ prefix, none2, 0 , (IC)rES,0 , }, /* 26 */
{ none1, axImp, NOT_HLL | B|NO_SRC , iDAA , Sf | Zf | Cf, }, /* 27 */
{ modrm, none2, B , iSUB , Sf | Zf | Cf, }, /* 28 */
{ modrm, none2, 0 , iSUB , Sf | Zf | Cf, }, /* 29 */
{ modrm, none2, TO_REG | B , iSUB , Sf | Zf | Cf, }, /* 2A */
{ modrm, none2, TO_REG , iSUB , Sf | Zf | Cf, }, /* 2B */
{ data1, axImp, B , iSUB , Sf | Zf | Cf, }, /* 2C */
{ data2, axImp, 0 , iSUB , Sf | Zf | Cf, }, /* 2D */
{ prefix, none2, 0 , (IC)rCS,0 , }, /* 2E */
{ none1, axImp, NOT_HLL | B|NO_SRC , iDAS , Sf | Zf | Cf, }, /* 2F */
{ modrm, none2, B , iXOR , Sf | Zf | Cf, }, /* 30 */
{ modrm, none2, NSP , iXOR , Sf | Zf | Cf, }, /* 31 */
{ modrm, none2, TO_REG | B , iXOR , Sf | Zf | Cf, }, /* 32 */
{ modrm, none2, TO_REG | NSP , iXOR , Sf | Zf | Cf, }, /* 33 */
{ data1, axImp, B , iXOR , Sf | Zf | Cf, }, /* 34 */
{ data2, axImp, 0 , iXOR , Sf | Zf | Cf, }, /* 35 */
{ prefix, none2, 0 , (IC)rSS,0 , }, /* 36 */
{ none1, axImp, NOT_HLL | NO_SRC , iAAA , Sf | Zf | Cf, }, /* 37 */
{ modrm, none2, B , iCMP , Sf | Zf | Cf, }, /* 38 */
{ modrm, none2, NSP , iCMP , Sf | Zf | Cf, }, /* 39 */
{ modrm, none2, TO_REG | B , iCMP , Sf | Zf | Cf, }, /* 3A */
{ modrm, none2, TO_REG | NSP , iCMP , Sf | Zf | Cf, }, /* 3B */
{ data1, axImp, B , iCMP , Sf | Zf | Cf, }, /* 3C */
{ data2, axImp, 0 , iCMP , Sf | Zf | Cf, }, /* 3D */
{ prefix, none2, 0 , (IC)rDS,0 , }, /* 3E */
{ none1, axImp, NOT_HLL | NO_SRC , iAAS , Sf | Zf | Cf, }, /* 3F */
{ regop, none2, 0 , iINC , Sf | Zf, }, /* 40 */
{ regop, none2, 0 , iINC , Sf | Zf, }, /* 41 */
{ regop, none2, 0 , iINC , Sf | Zf, }, /* 42 */
{ regop, none2, 0 , iINC , Sf | Zf, }, /* 43 */
{ regop, none2, NOT_HLL , iINC , Sf | Zf, }, /* 44 */
{ regop, none2, 0 , iINC , Sf | Zf, }, /* 45 */
{ regop, none2, 0 , iINC , Sf | Zf, }, /* 46 */
{ regop, none2, 0 , iINC , Sf | Zf, }, /* 47 */
{ regop, none2, 0 , iDEC , Sf | Zf, }, /* 48 */
{ regop, none2, 0 , iDEC , Sf | Zf, }, /* 49 */
{ regop, none2, 0 , iDEC , Sf | Zf, }, /* 4A */
{ regop, none2, 0 , iDEC , Sf | Zf, }, /* 4B */
{ regop, none2, NOT_HLL , iDEC , Sf | Zf, }, /* 4C */
{ regop, none2, 0 , iDEC , Sf | Zf, }, /* 4D */
{ regop, none2, 0 , iDEC , Sf | Zf, }, /* 4E */
{ regop, none2, 0 , iDEC , Sf | Zf, }, /* 4F */
{ regop, none2, NO_SRC , iPUSH , 0 , }, /* 50 */
{ regop, none2, NO_SRC , iPUSH , 0 , }, /* 51 */
{ regop, none2, NO_SRC , iPUSH , 0 , }, /* 52 */
{ regop, none2, NO_SRC , iPUSH , 0 , }, /* 53 */
{ regop, none2, NOT_HLL | NO_SRC , iPUSH , 0 , }, /* 54 */
{ regop, none2, NO_SRC , iPUSH , 0 , }, /* 55 */
{ regop, none2, NO_SRC , iPUSH , 0 , }, /* 56 */
{ regop, none2, NO_SRC , iPUSH , 0 , }, /* 57 */
{ regop, none2, NO_SRC , iPOP , 0 , }, /* 58 */
{ regop, none2, NO_SRC , iPOP , 0 , }, /* 59 */
{ regop, none2, NO_SRC , iPOP , 0 , }, /* 5A */
{ regop, none2, NO_SRC , iPOP , 0 , }, /* 5B */
{ regop, none2, NOT_HLL | NO_SRC , iPOP , 0 , }, /* 5C */
{ regop, none2, NO_SRC , iPOP , 0 , }, /* 5D */
{ regop, none2, NO_SRC , iPOP , 0 , }, /* 5E */
{ regop, none2, NO_SRC , iPOP , 0 , }, /* 5F */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHA, 0 , }, /* 60 */
{ none1, none2, NOT_HLL | NO_OPS , iPOPA , 0 , }, /* 61 */
{ memOnly, modrm, TO_REG | NSP , iBOUND, 0 , }, /* 62 */
{ none1, none2, OP386 , iZERO , 0 , }, /* 63 */
{ none1, none2, OP386 , iZERO , 0 , }, /* 64 */
{ none1, none2, OP386 , iZERO , 0 , }, /* 65 */
{ none1, none2, OP386 , iZERO , 0 , }, /* 66 */
{ none1, none2, OP386 , iZERO , 0 , }, /* 67 */
{ data2, none2, NO_SRC , iPUSH , 0 , }, /* 68 */
{ modrm, data2, TO_REG | NSP , iIMUL , Sf | Zf | Cf, }, /* 69 */
{ data1, none2, S_EXT | NO_SRC , iPUSH , 0 , }, /* 6A */
{ modrm, data1, TO_REG | NSP | S_EXT , iIMUL , Sf | Zf | Cf, }, /* 6B */
{ segop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 1E */
{ segop, none2, NO_SRC , iPOP , 0 , 0 }, /* 1F */
{ modrm, none2, B , iAND , Sf | Zf | Cf , 0 }, /* 20 */
{ modrm, none2, NSP , iAND , Sf | Zf | Cf , 0 }, /* 21 */
{ modrm, none2, TO_REG | B , iAND , Sf | Zf | Cf , 0 }, /* 22 */
{ modrm, none2, TO_REG | NSP , iAND , Sf | Zf | Cf , 0 }, /* 23 */
{ data1, axImp, B , iAND , Sf | Zf | Cf , 0 }, /* 24 */
{ data2, axImp, 0 , iAND , Sf | Zf | Cf , 0 }, /* 25 */
{ prefix, none2, 0 , (IC)rES,0 , 0 }, /* 26 */
{ none1, axImp, NOT_HLL | B|NO_SRC , iDAA , Sf | Zf | Cf , 0 }, /* 27 */
{ modrm, none2, B , iSUB , Sf | Zf | Cf , 0 }, /* 28 */
{ modrm, none2, 0 , iSUB , Sf | Zf | Cf , 0 }, /* 29 */
{ modrm, none2, TO_REG | B , iSUB , Sf | Zf | Cf , 0 }, /* 2A */
{ modrm, none2, TO_REG , iSUB , Sf | Zf | Cf , 0 }, /* 2B */
{ data1, axImp, B , iSUB , Sf | Zf | Cf , 0 }, /* 2C */
{ data2, axImp, 0 , iSUB , Sf | Zf | Cf , 0 }, /* 2D */
{ prefix, none2, 0 , (IC)rCS,0 , 0 }, /* 2E */
{ none1, axImp, NOT_HLL | B|NO_SRC , iDAS , Sf | Zf | Cf , 0 }, /* 2F */
{ modrm, none2, B , iXOR , Sf | Zf | Cf , 0 }, /* 30 */
{ modrm, none2, NSP , iXOR , Sf | Zf | Cf , 0 }, /* 31 */
{ modrm, none2, TO_REG | B , iXOR , Sf | Zf | Cf , 0 }, /* 32 */
{ modrm, none2, TO_REG | NSP , iXOR , Sf | Zf | Cf , 0 }, /* 33 */
{ data1, axImp, B , iXOR , Sf | Zf | Cf , 0 }, /* 34 */
{ data2, axImp, 0 , iXOR , Sf | Zf | Cf , 0 }, /* 35 */
{ prefix, none2, 0 , (IC)rSS,0 , 0 }, /* 36 */
{ none1, axImp, NOT_HLL | NO_SRC , iAAA , Sf | Zf | Cf , 0 }, /* 37 */
{ modrm, none2, B , iCMP , Sf | Zf | Cf , 0 }, /* 38 */
{ modrm, none2, NSP , iCMP , Sf | Zf | Cf , 0 }, /* 39 */
{ modrm, none2, TO_REG | B , iCMP , Sf | Zf | Cf , 0 }, /* 3A */
{ modrm, none2, TO_REG | NSP , iCMP , Sf | Zf | Cf , 0 }, /* 3B */
{ data1, axImp, B , iCMP , Sf | Zf | Cf , 0 }, /* 3C */
{ data2, axImp, 0 , iCMP , Sf | Zf | Cf , 0 }, /* 3D */
{ prefix, none2, 0 , (IC)rDS,0 , 0 }, /* 3E */
{ none1, axImp, NOT_HLL | NO_SRC , iAAS , Sf | Zf | Cf , 0 }, /* 3F */
{ regop, none2, 0 , iINC , Sf | Zf, 0 }, /* 40 */
{ regop, none2, 0 , iINC , Sf | Zf, 0 }, /* 41 */
{ regop, none2, 0 , iINC , Sf | Zf, 0 }, /* 42 */
{ regop, none2, 0 , iINC , Sf | Zf, 0 }, /* 43 */
{ regop, none2, NOT_HLL , iINC , Sf | Zf, 0 }, /* 44 */
{ regop, none2, 0 , iINC , Sf | Zf, 0 }, /* 45 */
{ regop, none2, 0 , iINC , Sf | Zf, 0 }, /* 46 */
{ regop, none2, 0 , iINC , Sf | Zf, 0 }, /* 47 */
{ regop, none2, 0 , iDEC , Sf | Zf, 0 }, /* 48 */
{ regop, none2, 0 , iDEC , Sf | Zf, 0 }, /* 49 */
{ regop, none2, 0 , iDEC , Sf | Zf, 0 }, /* 4A */
{ regop, none2, 0 , iDEC , Sf | Zf, 0 }, /* 4B */
{ regop, none2, NOT_HLL , iDEC , Sf | Zf, 0 }, /* 4C */
{ regop, none2, 0 , iDEC , Sf | Zf, 0 }, /* 4D */
{ regop, none2, 0 , iDEC , Sf | Zf, 0 }, /* 4E */
{ regop, none2, 0 , iDEC , Sf | Zf, 0 }, /* 4F */
{ regop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 50 */
{ regop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 51 */
{ regop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 52 */
{ regop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 53 */
{ regop, none2, NOT_HLL | NO_SRC , iPUSH , 0 , 0 }, /* 54 */
{ regop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 55 */
{ regop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 56 */
{ regop, none2, NO_SRC , iPUSH , 0 , 0 }, /* 57 */
{ regop, none2, NO_SRC , iPOP , 0 , 0 }, /* 58 */
{ regop, none2, NO_SRC , iPOP , 0 , 0 }, /* 59 */
{ regop, none2, NO_SRC , iPOP , 0 , 0 }, /* 5A */
{ regop, none2, NO_SRC , iPOP , 0 , 0 }, /* 5B */
{ regop, none2, NOT_HLL | NO_SRC , iPOP , 0 , 0 }, /* 5C */
{ regop, none2, NO_SRC , iPOP , 0 , 0 }, /* 5D */
{ regop, none2, NO_SRC , iPOP , 0 , 0 }, /* 5E */
{ regop, none2, NO_SRC , iPOP , 0 , 0 }, /* 5F */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHA, 0 , 0 }, /* 60 */
{ none1, none2, NOT_HLL | NO_OPS , iPOPA , 0 , 0 }, /* 61 */
{ memOnly, modrm, TO_REG | NSP , iBOUND, 0 , 0 }, /* 62 */
{ none1, none2, OP386 , iZERO , 0 , 0 }, /* 63 */
{ none1, none2, OP386 , iZERO , 0 , 0 }, /* 64 */
{ none1, none2, OP386 , iZERO , 0 , 0 }, /* 65 */
{ none1, none2, OP386 , iZERO , 0 , 0 }, /* 66 */
{ none1, none2, OP386 , iZERO , 0 , 0 }, /* 67 */
{ data2, none2, NO_SRC , iPUSH , 0 , 0 }, /* 68 */
{ modrm, data2, TO_REG | NSP , iIMUL , Sf | Zf | Cf, 0 }, /* 69 */
{ data1, none2, S_EXT | NO_SRC , iPUSH , 0 , 0 }, /* 6A */
{ modrm, data1, TO_REG | NSP | S_EXT , iIMUL , Sf | Zf | Cf, 0 }, /* 6B */
{ strop, memImp, NOT_HLL | B|IM_OPS , iINS , 0 , Df }, /* 6C */
{ strop, memImp, NOT_HLL | IM_OPS , iINS , 0 , Df }, /* 6D */
{ strop, memImp, NOT_HLL | B|IM_OPS , iOUTS , 0 , Df }, /* 6E */
{ strop, memImp, NOT_HLL | IM_OPS , iOUTS , 0 , Df }, /* 6F */
{ dispS, none2, NOT_HLL , iJO , 0 , }, /* 70 */
{ dispS, none2, NOT_HLL , iJNO , 0 , }, /* 71 */
{ dispS, none2, NOT_HLL , iJO , 0 , 0 }, /* 70 */
{ dispS, none2, NOT_HLL , iJNO , 0 , 0 }, /* 71 */
{ dispS, none2, 0 , iJB , 0 , Cf }, /* 72 */
{ dispS, none2, 0 , iJAE , 0 , Cf }, /* 73 */
{ dispS, none2, 0 , iJE , 0 , Zf }, /* 74 */
@ -142,140 +173,140 @@ static struct {
{ dispS, none2, 0 , iJA , 0 , Zf | Cf }, /* 77 */
{ dispS, none2, 0 , iJS , 0 , Sf }, /* 78 */
{ dispS, none2, 0 , iJNS , 0 , Sf }, /* 79 */
{ dispS, none2, NOT_HLL , iJP , 0 , }, /* 7A */
{ dispS, none2, NOT_HLL , iJNP , 0 , }, /* 7B */
{ dispS, none2, NOT_HLL , iJP , 0 , 0 }, /* 7A */
{ dispS, none2, NOT_HLL , iJNP , 0 , 0 }, /* 7B */
{ dispS, none2, 0 , iJL , 0 , Sf }, /* 7C */
{ dispS, none2, 0 , iJGE , 0 , Sf }, /* 7D */
{ dispS, none2, 0 , iJLE , 0 , Sf | Zf }, /* 7E */
{ dispS, none2, 0 , iJG , 0 , Sf | Zf }, /* 7F */
{ immed, data1, B , iZERO , 0 , }, /* 80 */
{ immed, data2, NSP , iZERO , 0 , }, /* 81 */
{ immed, data1, B , iZERO , 0 , }, /* 82 */ /* ?? */
{ immed, data1, NSP | S_EXT , iZERO , 0 , }, /* 83 */
{ modrm, none2, TO_REG | B , iTEST , Sf | Zf | Cf, }, /* 84 */
{ modrm, none2, TO_REG | NSP , iTEST , Sf | Zf | Cf, }, /* 85 */
{ modrm, none2, TO_REG | B , iXCHG , 0 , }, /* 86 */
{ modrm, none2, TO_REG | NSP , iXCHG , 0 , }, /* 87 */
{ modrm, none2, B , iMOV , 0 , }, /* 88 */
{ modrm, none2, 0 , iMOV , 0 , }, /* 89 */
{ modrm, none2, TO_REG | B , iMOV , 0 , }, /* 8A */
{ modrm, none2, TO_REG , iMOV , 0 , }, /* 8B */
{ segrm, none2, NSP , iMOV , 0 , }, /* 8C */
{ memOnly, modrm, TO_REG | NSP , iLEA , 0 , }, /* 8D */
{ segrm, none2, TO_REG | NSP , iMOV , 0 , }, /* 8E */
{ memReg0, none2, NO_SRC , iPOP , 0 , }, /* 8F */
{ none1, none2, NO_OPS , iNOP , 0 , }, /* 90 */
{ regop, axImp, 0 , iXCHG , 0 , }, /* 91 */
{ regop, axImp, 0 , iXCHG , 0 , }, /* 92 */
{ regop, axImp, 0 , iXCHG , 0 , }, /* 93 */
{ regop, axImp, NOT_HLL , iXCHG , 0 , }, /* 94 */
{ regop, axImp, 0 , iXCHG , 0 , }, /* 95 */
{ regop, axImp, 0 , iXCHG , 0 , }, /* 96 */
{ regop, axImp, 0 , iXCHG , 0 , }, /* 97 */
{ alImp, axImp, SRC_B | S_EXT , iSIGNEX,0 , }, /* 98 */
{axSrcIm, axImp, IM_DST | S_EXT , iSIGNEX,0 , }, /* 99 */
{ dispF, none2, 0 , iCALLF ,0 , }, /* 9A */
{ none1, none2, FLOAT_OP| NO_OPS , iWAIT , 0 , }, /* 9B */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHF, 0 , }, /* 9C */
{ immed, data1, B , iZERO , 0 , 0 }, /* 80 */
{ immed, data2, NSP , iZERO , 0 , 0 }, /* 81 */
{ immed, data1, B , iZERO , 0 , 0 }, /* 82 */ /* ?? */
{ immed, data1, NSP | S_EXT , iZERO , 0 , 0 }, /* 83 */
{ modrm, none2, TO_REG | B , iTEST , Sf | Zf | Cf, 0 }, /* 84 */
{ modrm, none2, TO_REG | NSP , iTEST , Sf | Zf | Cf, 0 }, /* 85 */
{ modrm, none2, TO_REG | B , iXCHG , 0 , 0 }, /* 86 */
{ modrm, none2, TO_REG | NSP , iXCHG , 0 , 0 }, /* 87 */
{ modrm, none2, B , iMOV , 0 , 0 }, /* 88 */
{ modrm, none2, 0 , iMOV , 0 , 0 }, /* 89 */
{ modrm, none2, TO_REG | B , iMOV , 0 , 0 }, /* 8A */
{ modrm, none2, TO_REG , iMOV , 0 , 0 }, /* 8B */
{ segrm, none2, NSP , iMOV , 0 , 0 }, /* 8C */
{ memOnly, modrm, TO_REG | NSP , iLEA , 0 , 0 }, /* 8D */
{ segrm, none2, TO_REG | NSP , iMOV , 0 , 0 }, /* 8E */
{ memReg0, none2, NO_SRC , iPOP , 0 , 0 }, /* 8F */
{ none1, none2, NO_OPS , iNOP , 0 , 0 }, /* 90 */
{ regop, axImp, 0 , iXCHG , 0 , 0 }, /* 91 */
{ regop, axImp, 0 , iXCHG , 0 , 0 }, /* 92 */
{ regop, axImp, 0 , iXCHG , 0 , 0 }, /* 93 */
{ regop, axImp, NOT_HLL , iXCHG , 0 , 0 }, /* 94 */
{ regop, axImp, 0 , iXCHG , 0 , 0 }, /* 95 */
{ regop, axImp, 0 , iXCHG , 0 , 0 }, /* 96 */
{ regop, axImp, 0 , iXCHG , 0 , 0 }, /* 97 */
{ alImp, axImp, SRC_B | S_EXT , iSIGNEX,0 , 0 }, /* 98 */
{axSrcIm, axImp, IM_DST | S_EXT , iSIGNEX,0 , 0 }, /* 99 */
{ dispF, none2, 0 , iCALLF ,0 , 0 }, /* 9A */
{ none1, none2, FLOAT_OP| NO_OPS , iWAIT , 0 , 0 }, /* 9B */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHF, 0 , 0 }, /* 9C */
{ none1, none2, NOT_HLL | NO_OPS , iPOPF , Sf | Zf | Cf | Df,}, /* 9D */
{ none1, none2, NOT_HLL | NO_OPS , iSAHF , Sf | Zf | Cf, }, /* 9E */
{ none1, none2, NOT_HLL | NO_OPS , iSAHF , Sf | Zf | Cf, 0 }, /* 9E */
{ none1, none2, NOT_HLL | NO_OPS , iLAHF , 0 , Sf | Zf | Cf }, /* 9F */
{ dispM, axImp, B , iMOV , 0 , }, /* A0 */
{ dispM, axImp, 0 , iMOV , 0 , }, /* A1 */
{ dispM, axImp, TO_REG | B , iMOV , 0 , }, /* A2 */
{ dispM, axImp, TO_REG , iMOV , 0 , }, /* A3 */
{ dispM, axImp, B , iMOV , 0 , 0 }, /* A0 */
{ dispM, axImp, 0 , iMOV , 0 , 0 }, /* A1 */
{ dispM, axImp, TO_REG | B , iMOV , 0 , 0 }, /* A2 */
{ dispM, axImp, TO_REG , iMOV , 0 , 0 }, /* A3 */
{ strop, memImp, B | IM_OPS , iMOVS , 0 , Df }, /* A4 */
{ strop, memImp, IM_OPS , iMOVS , 0 , Df }, /* A5 */
{ strop, memImp, B | IM_OPS , iCMPS , Sf | Zf | Cf, Df }, /* A6 */
{ strop, memImp, IM_OPS , iCMPS , Sf | Zf | Cf, Df }, /* A7 */
{ data1, axImp, B , iTEST , Sf | Zf | Cf, }, /* A8 */
{ data2, axImp, 0 , iTEST , Sf | Zf | Cf, }, /* A9 */
{ data1, axImp, B , iTEST , Sf | Zf | Cf, 0 }, /* A8 */
{ data2, axImp, 0 , iTEST , Sf | Zf | Cf, 0 }, /* A9 */
{ strop, memImp, B | IM_OPS , iSTOS , 0 , Df }, /* AA */
{ strop, memImp, IM_OPS , iSTOS , 0 , Df }, /* AB */
{ strop, memImp, B | IM_OPS , iLODS , 0 , Df }, /* AC */
{ strop, memImp, IM_OPS , iLODS , 0 , Df }, /* AD */
{ strop, memImp, B | IM_OPS , iSCAS , Sf | Zf | Cf, Df }, /* AE */
{ strop, memImp, IM_OPS , iSCAS , Sf | Zf | Cf, Df }, /* AF */
{ regop, data1, B , iMOV , 0 , }, /* B0 */
{ regop, data1, B , iMOV , 0 , }, /* B1 */
{ regop, data1, B , iMOV , 0 , }, /* B2 */
{ regop, data1, B , iMOV , 0 , }, /* B3 */
{ regop, data1, B , iMOV , 0 , }, /* B4 */
{ regop, data1, B , iMOV , 0 , }, /* B5 */
{ regop, data1, B , iMOV , 0 , }, /* B6 */
{ regop, data1, B , iMOV , 0 , }, /* B7 */
{ regop, data2, 0 , iMOV , 0 , }, /* B8 */
{ regop, data2, 0 , iMOV , 0 , }, /* B9 */
{ regop, data2, 0 , iMOV , 0 , }, /* BA */
{ regop, data2, 0 , iMOV , 0 , }, /* BB */
{ regop, data2, NOT_HLL , iMOV , 0 , }, /* BC */
{ regop, data2, 0 , iMOV , 0 , }, /* BD */
{ regop, data2, 0 , iMOV , 0 , }, /* BE */
{ regop, data2, 0 , iMOV , 0 , }, /* BF */
{ shift, data1, B , iZERO , 0 , }, /* C0 */
{ shift, data1, NSP | SRC_B , iZERO , 0 , }, /* C1 */
{ data2, none2, 0 , iRET , 0 , }, /* C2 */
{ none1, none2, NO_OPS , iRET , 0 , }, /* C3 */
{ memOnly, modrm, TO_REG | NSP , iLES , 0 , }, /* C4 */
{ memOnly, modrm, TO_REG | NSP , iLDS , 0 , }, /* C5 */
{ memReg0, data1, B , iMOV , 0 , }, /* C6 */
{ memReg0, data2, 0 , iMOV , 0 , }, /* C7 */
{ data2, data1, 0 , iENTER, 0 , }, /* C8 */
{ none1, none2, NO_OPS , iLEAVE, 0 , }, /* C9 */
{ data2, none2, 0 , iRETF , 0 , }, /* CA */
{ none1, none2, NO_OPS , iRETF , 0 , }, /* CB */
{ const3, none2, NOT_HLL , iINT , 0 , }, /* CC */
{ data1,checkInt, NOT_HLL , iINT , 0 , }, /* CD */
{ none1, none2, NOT_HLL | NO_OPS , iINTO , 0 , }, /* CE */
{ none1, none2, NOT_HLL | NO_OPS , iIRET , 0 , }, /* Cf */
{ shift, const1, B , iZERO , 0 , }, /* D0 */
{ shift, const1, SRC_B , iZERO , 0 , }, /* D1 */
{ shift, none1, B , iZERO , 0 , }, /* D2 */
{ shift, none1, SRC_B , iZERO , 0 , }, /* D3 */
{ data1, axImp, NOT_HLL , iAAM , Sf | Zf | Cf, }, /* D4 */
{ data1, axImp, NOT_HLL , iAAD , Sf | Zf | Cf, }, /* D5 */
{ none1, none2, 0 , iZERO , 0 , }, /* D6 */
{ memImp, axImp, NOT_HLL | B| IM_OPS, iXLAT , 0 , }, /* D7 */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* D8 */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* D9 */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* DA */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* DB */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* DC */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* DD */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* DE */
{ escop, none2, FLOAT_OP , iESC , 0 , }, /* Df */
{ regop, data1, B , iMOV , 0 , 0 }, /* B0 */
{ regop, data1, B , iMOV , 0 , 0 }, /* B1 */
{ regop, data1, B , iMOV , 0 , 0 }, /* B2 */
{ regop, data1, B , iMOV , 0 , 0 }, /* B3 */
{ regop, data1, B , iMOV , 0 , 0 }, /* B4 */
{ regop, data1, B , iMOV , 0 , 0 }, /* B5 */
{ regop, data1, B , iMOV , 0 , 0 }, /* B6 */
{ regop, data1, B , iMOV , 0 , 0 }, /* B7 */
{ regop, data2, 0 , iMOV , 0 , 0 }, /* B8 */
{ regop, data2, 0 , iMOV , 0 , 0 }, /* B9 */
{ regop, data2, 0 , iMOV , 0 , 0 }, /* BA */
{ regop, data2, 0 , iMOV , 0 , 0 }, /* BB */
{ regop, data2, NOT_HLL , iMOV , 0 , 0 }, /* BC */
{ regop, data2, 0 , iMOV , 0 , 0 }, /* BD */
{ regop, data2, 0 , iMOV , 0 , 0 }, /* BE */
{ regop, data2, 0 , iMOV , 0 , 0 }, /* BF */
{ shift, data1, B , iZERO , 0 , 0 }, /* C0 */
{ shift, data1, NSP | SRC_B , iZERO , 0 , 0 }, /* C1 */
{ data2, none2, 0 , iRET , 0 , 0 }, /* C2 */
{ none1, none2, NO_OPS , iRET , 0 , 0 }, /* C3 */
{ memOnly, modrm, TO_REG | NSP , iLES , 0 , 0 }, /* C4 */
{ memOnly, modrm, TO_REG | NSP , iLDS , 0 , 0 }, /* C5 */
{ memReg0, data1, B , iMOV , 0 , 0 }, /* C6 */
{ memReg0, data2, 0 , iMOV , 0 , 0 }, /* C7 */
{ data2, data1, 0 , iENTER, 0 , 0 }, /* C8 */
{ none1, none2, NO_OPS , iLEAVE, 0 , 0 }, /* C9 */
{ data2, none2, 0 , iRETF , 0 , 0 }, /* CA */
{ none1, none2, NO_OPS , iRETF , 0 , 0 }, /* CB */
{ const3, none2, NOT_HLL , iINT , 0 , 0 }, /* CC */
{ data1,checkInt, NOT_HLL , iINT , 0 , 0 }, /* CD */
{ none1, none2, NOT_HLL | NO_OPS , iINTO , 0 , 0 }, /* CE */
{ none1, none2, NOT_HLL | NO_OPS , iIRET , 0 , 0 }, /* Cf */
{ shift, const1, B , iZERO , 0 , 0 }, /* D0 */
{ shift, const1, SRC_B , iZERO , 0 , 0 }, /* D1 */
{ shift, none1, B , iZERO , 0 , 0 }, /* D2 */
{ shift, none1, SRC_B , iZERO , 0 , 0 }, /* D3 */
{ data1, axImp, NOT_HLL , iAAM , Sf | Zf | Cf, 0 }, /* D4 */
{ data1, axImp, NOT_HLL , iAAD , Sf | Zf | Cf, 0 }, /* D5 */
{ none1, none2, 0 , iZERO , 0 , 0 }, /* D6 */
{ memImp, axImp, NOT_HLL | B| IM_OPS, iXLAT , 0 , 0 }, /* D7 */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* D8 */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* D9 */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* DA */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* DB */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* DC */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* DD */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* DE */
{ escop, none2, FLOAT_OP , iESC , 0 , 0 }, /* Df */
{ dispS, none2, 0 , iLOOPNE,0 , Zf }, /* E0 */
{ dispS, none2, 0 , iLOOPE, 0 , Zf }, /* E1 */
{ dispS, none2, 0 , iLOOP , 0 , }, /* E2 */
{ dispS, none2, 0 , iJCXZ , 0 , }, /* E3 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iIN , 0 , }, /* E4 */
{ data1, axImp, NOT_HLL | NO_SRC , iIN , 0 , }, /* E5 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iOUT , 0 , }, /* E6 */
{ data1, axImp, NOT_HLL | NO_SRC , iOUT , 0 , }, /* E7 */
{ dispN, none2, 0 , iCALL , 0 , }, /* E8 */
{ dispN, none2, 0 , iJMP , 0 , }, /* E9 */
{ dispF, none2, 0 , iJMPF , 0 , }, /* EA */
{ dispS, none2, 0 , iJMP , 0 , }, /* EB */
{ none1, axImp, NOT_HLL | B|NO_SRC , iIN , 0 , }, /* EC */
{ none1, axImp, NOT_HLL | NO_SRC , iIN , 0 , }, /* ED */
{ none1, axImp, NOT_HLL | B|NO_SRC , iOUT , 0 , }, /* EE */
{ none1, axImp, NOT_HLL | NO_SRC , iOUT , 0 , }, /* EF */
{ none1, none2, NOT_HLL | NO_OPS , iLOCK , 0 , }, /* F0 */
{ none1, none2, 0 , iZERO , 0 , }, /* F1 */
{ prefix, none2, 0 , iREPNE, 0 , }, /* F2 */
{ prefix, none2, 0 , iREPE , 0 , }, /* F3 */
{ none1, none2, NOT_HLL | NO_OPS , iHLT , 0 , }, /* F4 */
{ dispS, none2, 0 , iLOOP , 0 , 0 }, /* E2 */
{ dispS, none2, 0 , iJCXZ , 0 , 0 }, /* E3 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iIN , 0 , 0 }, /* E4 */
{ data1, axImp, NOT_HLL | NO_SRC , iIN , 0 , 0 }, /* E5 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iOUT , 0 , 0 }, /* E6 */
{ data1, axImp, NOT_HLL | NO_SRC , iOUT , 0 , 0 }, /* E7 */
{ dispN, none2, 0 , iCALL , 0 , 0 }, /* E8 */
{ dispN, none2, 0 , iJMP , 0 , 0 }, /* E9 */
{ dispF, none2, 0 , iJMPF , 0 , 0 }, /* EA */
{ dispS, none2, 0 , iJMP , 0 , 0 }, /* EB */
{ none1, axImp, NOT_HLL | B|NO_SRC , iIN , 0 , 0 }, /* EC */
{ none1, axImp, NOT_HLL | NO_SRC , iIN , 0 , 0 }, /* ED */
{ none1, axImp, NOT_HLL | B|NO_SRC , iOUT , 0 , 0 }, /* EE */
{ none1, axImp, NOT_HLL | NO_SRC , iOUT , 0 , 0 }, /* EF */
{ none1, none2, NOT_HLL | NO_OPS , iLOCK , 0 , 0 }, /* F0 */
{ none1, none2, 0 , iZERO , 0 , 0 }, /* F1 */
{ prefix, none2, 0 , iREPNE, 0 , 0 }, /* F2 */
{ prefix, none2, 0 , iREPE , 0 , 0 }, /* F3 */
{ none1, none2, NOT_HLL | NO_OPS , iHLT , 0 , 0 }, /* F4 */
{ none1, none2, NO_OPS , iCMC , Cf, Cf }, /* F5 */
{ arith, none1, B , iZERO , 0 , }, /* F6 */
{ arith, none1, NSP , iZERO , 0 , }, /* F7 */
{ none1, none2, NO_OPS , iCLC , Cf, }, /* F8 */
{ none1, none2, NO_OPS , iSTC , Cf, }, /* F9 */
{ none1, none2, NOT_HLL | NO_OPS , iCLI , 0 , }, /* FA */
{ none1, none2, NOT_HLL | NO_OPS , iSTI , 0 , }, /* FB */
{ none1, none2, NO_OPS , iCLD , Df, }, /* FC */
{ none1, none2, NO_OPS , iSTD , Df, }, /* FD */
{ trans, none1, B , iZERO , 0 , }, /* FE */
{ trans, none1, NSP , iZERO , 0 , } /* FF */
{ arith, none1, B , iZERO , 0 , 0 }, /* F6 */
{ arith, none1, NSP , iZERO , 0 , 0 }, /* F7 */
{ none1, none2, NO_OPS , iCLC , Cf, 0 }, /* F8 */
{ none1, none2, NO_OPS , iSTC , Cf, 0 }, /* F9 */
{ none1, none2, NOT_HLL | NO_OPS , iCLI , 0 , 0 }, /* FA */
{ none1, none2, NOT_HLL | NO_OPS , iSTI , 0 , 0 }, /* FB */
{ none1, none2, NO_OPS , iCLD , Df, 0 }, /* FC */
{ none1, none2, NO_OPS , iSTD , Df, 0 }, /* FD */
{ trans, none1, B , iZERO , 0 , 0 }, /* FE */
{ trans, none1, NSP , iZERO , 0 , 0 } /* FF */
} ;
static word SegPrefix, RepPrefix;
@ -287,7 +318,7 @@ static ICODE * pIcode; /* Ptr to Icode record filled in by scan() */
Scans one machine instruction at offset ip in prog.Image and returns error.
At the same time, fill in low-level icode details for the scanned inst.
****************************************************************************/
Int scan(dword ip, ICODE *p)
eErrorId scan(dword ip, ICODE *p)
{
Int op;
@ -321,7 +352,7 @@ Int scan(dword ip, ICODE *p)
/* Save bytes of image used */
p->ic.ll.numBytes = (byte)((pInst - prog.Image) - ip);
return ((SegPrefix)? FUNNY_SEGOVR: /* Seg. Override invalid */
(RepPrefix ? FUNNY_REP: 0));/* REP prefix invalid */
(RepPrefix ? FUNNY_REP: NO_ERR));/* REP prefix invalid */
}
/* Else opcode error */
return ((stateTable[op].flg & OP386)? INVALID_386OP: INVALID_OPCODE);
@ -501,16 +532,14 @@ static void axImp(Int i)
setAddress(i, TRUE, 0, rAX, 0);
}
static void axSrcIm (Int i)
/* Implied AX source */
static void axSrcIm (Int )
{
pIcode->ic.ll.src.regi = rAX;
}
static void alImp (Int i)
/* Implied AL source */
static void alImp (Int )
{
pIcode->ic.ll.src.regi = rAL;
}
@ -528,7 +557,7 @@ static void memImp(Int i)
/****************************************************************************
memOnly - Instruction is not valid if modrm refers to register (i.e. mod == 3)
***************************************************************************/
static void memOnly(Int i)
static void memOnly(Int )
{
if ((*pInst & 0xC0) == 0xC0)
pIcode->ic.ll.opcode = (llIcode)0;
@ -665,7 +694,7 @@ static void data1(Int i)
/*****************************************************************************
data2 - Sets up immed from 2 byte data
****************************************************************************/
static void data2(Int i)
static void data2(Int )
{
if (relocItem(pInst))
pIcode->ic.ll.flg |= SEG_IMMED;
@ -699,7 +728,7 @@ static void dispM(Int i)
/****************************************************************************
dispN - 2 byte disp as immed relative to ip
****************************************************************************/
static void dispN(Int i)
static void dispN(Int )
{
long off = (short)getWord(); /* Signed displacement */
@ -714,7 +743,7 @@ static void dispN(Int i)
/***************************************************************************
dispS - 1 byte disp as immed relative to ip
***************************************************************************/
static void dispS(Int i)
static void dispS(Int )
{
long off = signex(*pInst++); /* Signed displacement */
@ -726,7 +755,7 @@ static void dispS(Int i)
/****************************************************************************
dispF - 4 byte disp as immed 20-bit target address
***************************************************************************/
static void dispF(Int i)
static void dispF(Int )
{
dword off = (unsigned)getWord();
dword seg = (unsigned)getWord();
@ -740,7 +769,7 @@ static void dispF(Int i)
prefix - picks up prefix byte for following instruction (LOCK is ignored
on purpose)
****************************************************************************/
static void prefix(Int i)
static void prefix(Int )
{
if (pIcode->ic.ll.opcode == iREPE || pIcode->ic.ll.opcode == iREPNE)
RepPrefix = pIcode->ic.ll.opcode;
@ -756,7 +785,7 @@ inline void BumpOpcode(llIcode& ic)
/*****************************************************************************
strop - checks RepPrefix and converts string instructions accordingly
*****************************************************************************/
static void strop(Int i)
static void strop(Int )
{
if (RepPrefix)
{
@ -788,7 +817,7 @@ static void escop(Int i)
/****************************************************************************
const1
****************************************************************************/
static void const1(Int i)
static void const1(Int )
{
pIcode->ic.ll.immed.op = 1;
pIcode->ic.ll.flg |= I;
@ -798,7 +827,7 @@ static void const1(Int i)
/*****************************************************************************
const3
****************************************************************************/
static void const3(Int i)
static void const3(Int )
{
pIcode->ic.ll.immed.op = 3;
pIcode->ic.ll.flg |= I;
@ -808,7 +837,7 @@ static void const3(Int i)
/****************************************************************************
none1
****************************************************************************/
static void none1(Int i)
static void none1(Int )
{
}
@ -816,7 +845,7 @@ static void none1(Int i)
/****************************************************************************
none2 - Sets the NO_OPS flag if the operand is immediate
****************************************************************************/
static void none2(Int i)
static void none2(Int )
{
if (pIcode->ic.ll.flg & I)
pIcode->ic.ll.flg |= NO_OPS;
@ -825,7 +854,7 @@ static void none2(Int i)
/****************************************************************************
Checks for int 34 to int 3B - if so, converts to ESC nn instruction
****************************************************************************/
static void checkInt(Int i)
static void checkInt(Int )
{
word wOp = (word) pIcode->ic.ll.immed.op;
if ((wOp >= 0x34) && (wOp <= 0x3B))

View File

@ -90,15 +90,10 @@ void udm(void)
***************************************************************************/
void Function::displayCFG()
{
Int i;
BB * pBB;
printf("\nBasic Block List - Proc %s", name);
for (auto iter = cfg.begin(); iter!=cfg.end(); ++iter)
for (BB *pBB : cfg)
{
pBB = *iter;
(*iter)->display();
pBB->display();
}
}