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

View File

@ -25,7 +25,7 @@ struct BB : public llvm::ilist_node<BB>
{ {
private: private:
BB(const BB&); 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), numHlIcodes(0),flg(0),
inEdges(0), inEdges(0),
edges(0),beenOnH(0),inEdgeCount(0),reachingInt(0), edges(0),beenOnH(0),inEdgeCount(0),reachingInt(0),
@ -97,8 +97,8 @@ public:
Int caseTail; /* tail node for the case */ Int caseTail; /* tail node for the case */
Int index; /* Index, used in several ways */ Int index; /* Index, used in several ways */
static BB *Create(void *ctx=0,const std::string &s="",Function *parent=0,BB *insertBefore=0); static BB *Create(void *ctx=0,const std::string &s="",Function *parent=0,BB *insertBefore=0);
static BB *Create(Int start, Int ip, byte nodeType, Int numOutEdges, Function * parent); static BB *Create(Int start, Int ip, byte nodeType, Int numOutEdges, Function * parent);
void writeCode(Int indLevel, Function *pProc, Int *numLoc, Int latchNode, Int ifFollow); void writeCode(Int indLevel, Function *pProc, Int *numLoc, Int latchNode, Int ifFollow);
void mergeFallThrough(CIcodeRec &Icode); void mergeFallThrough(CIcodeRec &Icode);
void dfsNumbering(std::vector<BB *> &dfsLast, Int *first, Int *last); void dfsNumbering(std::vector<BB *> &dfsLast, Int *first, Int *last);

View File

@ -113,12 +113,13 @@ public:
void buildCFG(); void buildCFG();
void controlFlowAnalysis(); void controlFlowAnalysis();
void newRegArg(ICODE *picode, ICODE *ticode); void newRegArg(ICODE *picode, ICODE *ticode);
protected: protected:
// TODO: replace those with friend visitor ? // 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 propLongStk(Int i, ID *pLocId);
void propLongGlb(Int i, ID *pLocId); void propLongGlb(Int i, ID *pLocId);
int checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx);
void structCases(); void structCases();
void findExps(); void findExps();
void genDU1(); void genDU1();

View File

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

View File

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

View File

@ -23,7 +23,6 @@ public:
#define lineSize 360 /* 3 lines in the mean time */ #define lineSize 360 /* 3 lines in the mean time */
void newBundle (bundle *procCode); void newBundle (bundle *procCode);
//void appendStrTab (strTable *strTab, const char *format, ...);
Int nextBundleIdx (strTable *strTab); Int nextBundleIdx (strTable *strTab);
void addLabelBundle (strTable &strTab, Int idx, Int label); void addLabelBundle (strTable &strTab, Int idx, Int label);
void writeBundle (std::ostream &ios, bundle procCode); 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 */ /* Procedure FLAGS */
enum PROC_FLAGS enum PROC_FLAGS
{ {
PROC_BADINST=0x000100,/* Proc contains invalid or 386 instruction */ PROC_BADINST=0x00000100,/* Proc contains invalid or 386 instruction */
PROC_IJMP =0x000200,/* Proc incomplete due to indirect jmp */ PROC_IJMP =0x00000200,/* Proc incomplete due to indirect jmp */
PROC_ICALL =0x000400, /* Proc incomplete due to indirect call */ PROC_ICALL =0x00000400, /* Proc incomplete due to indirect call */
PROC_HLL=0x001000, /* Proc is likely to be from a HLL */ PROC_HLL =0x00001000, /* Proc is likely to be from a HLL */
CALL_PASCAL=0x002000, /* Proc uses Pascal calling convention */ CALL_PASCAL =0x00002000, /* Proc uses Pascal calling convention */
CALL_C=0x004000, /* Proc uses C calling convention */ CALL_C =0x00004000, /* Proc uses C calling convention */
CALL_UNKNOWN=0x008000, /* Proc uses unknown calling convention */ CALL_UNKNOWN=0x00008000, /* Proc uses unknown calling convention */
PROC_NEAR=0x010000, /* Proc exits with near return */ PROC_NEAR =0x00010000, /* Proc exits with near return */
PROC_FAR=0x020000, /* Proc exits with far return */ PROC_FAR =0x00020000, /* Proc exits with far return */
GRAPH_IRRED=0x100000, /* Proc generates an irreducible graph */ GRAPH_IRRED =0x00100000, /* Proc generates an irreducible graph */
SI_REGVAR=0x200000, /* SI is used as a stack variable */ SI_REGVAR =0x00200000, /* SI is used as a stack variable */
DI_REGVAR=0x400000, /* DI is used as a stack variable */ DI_REGVAR =0x00400000, /* DI is used as a stack variable */
PROC_IS_FUNC=0x800000, /* Proc is a function */ PROC_IS_FUNC=0x00800000, /* Proc is a function */
REG_ARGS=0x1000000, /* Proc has registers as arguments */ REG_ARGS =0x01000000, /* Proc has registers as arguments */
PROC_VARARG=0x2000000, /* Proc has variable arguments */ PROC_VARARG =0x02000000, /* Proc has variable arguments */
PROC_OUTPUT=0x4000000, /* C for this proc has been output */ PROC_OUTPUT =0x04000000, /* C for this proc has been output */
PROC_RUNTIME=0x8000000, /* Proc is part of the runtime support */ PROC_RUNTIME=0x08000000, /* Proc is part of the runtime support */
PROC_ISLIB=0x10000000, /* Proc is a library function */ PROC_ISLIB =0x10000000, /* Proc is a library function */
PROC_ASM=0x20000000, /* Proc is an intrinsic assembler routine */ PROC_ASM =0x20000000, /* Proc is an intrinsic assembler routine */
PROC_IS_HLL=0x40000000 /* Proc has HLL prolog code */ PROC_IS_HLL =0x40000000 /* Proc has HLL prolog code */
}; };
#define CALL_MASK 0xFFFF9FFF /* Masks off CALL_C and CALL_PASCAL */ #define CALL_MASK 0xFFFF9FFF /* Masks off CALL_C and CALL_PASCAL */
/**** Global variables ****/ /**** Global variables ****/
extern char *asm1_name, *asm2_name; /* Assembler output filenames */ 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 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 duReg[30]; /* def/use bits for registers */
extern dword maskDuReg[30]; /* masks off du bits for regs */ extern dword maskDuReg[30]; /* masks off du bits for regs */
/* Registers used by icode instructions */ /* 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", "si", "di", "es", "cs", "ss", "ds",
"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh", "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh",
"tmp"}; "tmp"};
@ -161,24 +156,24 @@ extern STATS stats; /* Icode statistics */
void FrontEnd(char *filename, CALL_GRAPH * *); /* frontend.c */ void FrontEnd(char *filename, CALL_GRAPH * *); /* frontend.c */
void *allocMem(Int cb); /* frontend.c */ void *allocMem(Int cb); /* frontend.c */
void *reallocVar(void *p, Int newsize); /* frontend.c */
void udm(void); /* udm.c */ void udm(void); /* udm.c */
void freeCFG(BB * cfg); /* graph.c */ void freeCFG(BB * cfg); /* graph.c */
BB * newBB(BB *, Int, Int, byte, Int, Function *); /* graph.c */ BB * newBB(BB *, Int, Int, byte, Int, Function *); /* graph.c */
void BackEnd(char *filename, CALL_GRAPH *); /* backend.c */ void BackEnd(char *filename, CALL_GRAPH *); /* backend.c */
char *cChar(byte c); /* 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 */ void parse (CALL_GRAPH * *); /* parser.c */
boolT labelSrch(CIcodeRec &pIc, Int n, dword tg, Int *pIdx); /* parser.c */
Int strSize (byte *, char); /* parser.c */ Int strSize (byte *, char); /* parser.c */
void disassem(Int pass, Function * pProc); /* disassem.c */ void disassem(Int pass, Function * pProc); /* disassem.c */
void interactDis(Function * initProc, Int initIC); /* 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 */ queue::iterator appendQueue(queue &Q, BB *node); /* reducible.c */
void SetupLibCheck(void); /* chklib.c */ void SetupLibCheck(void); /* chklib.c */
void CleanupLibCheck(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 */ /* Exported functions from procs.c */
boolT insertCallGraph (CALL_GRAPH *, ilFunction, ilFunction); 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 *); std::string walkCondExpr (const COND_EXPR *exp, Function * pProc, Int *);
Int hlTypeSize (const COND_EXPR *, Function *); Int hlTypeSize (const COND_EXPR *, Function *);
hlType expType (const COND_EXPR *, Function *); hlType expType (const COND_EXPR *, Function *);
boolT insertSubTreeReg (COND_EXPR *, COND_EXPR **, byte, LOCAL_ID *); bool insertSubTreeReg(COND_EXPR *, COND_EXPR **, byte, LOCAL_ID *);
boolT insertSubTreeLongReg (COND_EXPR *, COND_EXPR **, Int); bool insertSubTreeLongReg (COND_EXPR *, COND_EXPR **, Int);
/* Exported functions from hlicode.c */ /* Exported functions from hlicode.c */

View File

@ -5,29 +5,32 @@
#pragma once #pragma once
/* These definitions refer to errorMessage in error.c */ /* 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 NO_BB,
#define INVALID_ARG 1 INVALID_SYNTHETIC_BB,
#define INVALID_OPCODE 2 INVALID_INT_BB,
#define INVALID_386OP 3 IP_OUT_OF_RANGE,
#define FUNNY_SEGOVR 4 DEF_NOT_FOUND,
#define FUNNY_REP 5 JX_NOT_DEF,
#define CANNOT_OPEN 6 NOT_DEF_USE,
#define CANNOT_READ 7 REPEAT_FAIL,
#define MALLOC_FAILED 8 WHILE_FAIL
#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
void fatalError(Int errId, ...); void fatalError(eErrorId errId, ...);
void reportError(Int errId, ...); void reportError(eErrorId errId, ...);

View File

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

View File

@ -34,7 +34,7 @@ typedef enum {
TYPE_DOUBLE /* double precision float */ TYPE_DOUBLE /* double precision float */
} hlType; } 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 *", "long", "unsigned long", "record", "int *", "char *",
"", "float", "double"}; "", "float", "double"};
@ -69,12 +69,12 @@ typedef struct
struct ID struct ID
{ {
hlType type; /* Probable type */ hlType type; /* Probable type */
boolT illegal;/* Boolean: not a valid field any more */ boolT illegal; /* Boolean: not a valid field any more */
IDX_ARRAY idx; /* Index into icode array (REG_FRAME only) */ IDX_ARRAY idx; /* Index into icode array (REG_FRAME only) */
frameType loc; /* Frame location */ frameType loc; /* Frame location */
boolT hasMacro;/* Identifier requires a macro */ boolT hasMacro; /* Identifier requires a macro */
char macro[10];/* Macro for this identifier */ char macro[10]; /* Macro for this identifier */
char name[20];/* Identifier's name */ char name[20]; /* Identifier's name */
union { /* Different types of identifiers */ union { /* Different types of identifiers */
byte regi; /* For TYPE_BYTE(WORD)_(UN)SIGN registers */ byte regi; /* For TYPE_BYTE(WORD)_(UN)SIGN registers */
struct { /* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */ struct { /* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */
@ -83,7 +83,7 @@ struct ID
} bwId; } bwId;
BWGLB_TYPE bwGlb; /* For TYPE_BYTE(WORD)_(UN)SIGN globals */ BWGLB_TYPE bwGlb; /* For TYPE_BYTE(WORD)_(UN)SIGN globals */
LONGID_TYPE longId; /* For TYPE_LONG_(UN)SIGN registers */ LONGID_TYPE longId; /* For TYPE_LONG_(UN)SIGN registers */
LONG_STKID_TYPE longStkId;/* For TYPE_LONG_(UN)SIGN on the stack */ LONG_STKID_TYPE longStkId; /* For TYPE_LONG_(UN)SIGN on the stack */
struct { /* For TYPE_LONG_(UN)SIGN globals */ struct { /* For TYPE_LONG_(UN)SIGN globals */
int16 seg; /* segment value */ int16 seg; /* segment value */
int16 offH; /* offset high */ int16 offH; /* offset high */

View File

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

View File

@ -3,36 +3,5 @@
*/ */
#define LH(p) ((int)((byte *)(p))[0] + ((int)((byte *)(p))[1] << 8)) #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 */ /* Extracts reg bits from middle of mod-reg-rm byte */
#define REG(x) ((byte)(x & 0x38) >> 3) #define REG(x) ((byte)(x & 0x38) >> 3)

View File

@ -101,12 +101,11 @@ void BB::displayDfs()
printf("----\n"); printf("----\n");
/* Recursive call on successors of current node */ /* Recursive call on successors of current node */
std::for_each(edges.begin(), edges.end(), for(TYPEADR_TYPE &pb : edges)
[](TYPEADR_TYPE &pb)
{ {
if (pb.BBptr->traversed != DFS_DISP) if (pb.BBptr->traversed != DFS_DISP)
pb.BBptr->displayDfs(); pb.BBptr->displayDfs();
}); }
} }
/* Recursive procedure that writes the code for the given procedure, pointed /* Recursive procedure that writes the code for the given procedure, pointed
* to by pBB. * 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 */ /* Write the code for this basic block */
writeBB(&pProc->Icode.front(), indLevel, pProc, numLoc); writeBB(&pProc->Icode.front(), indLevel, pProc, numLoc);
repCond = TRUE; repCond = true;
} }
/* Condition needs to be inverted if the loop body is along /* 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); l = writeJcondInv ( back().ic.hl, pProc, numLoc);
cCode.appendCode( "\n%s%s", indent(indLevel-1), l); cCode.appendCode( "\n%s%s", indent(indLevel-1), l);
edges[ELSE].BBptr->writeCode (indLevel, pProc, numLoc, latchNode, follow); edges[ELSE].BBptr->writeCode (indLevel, pProc, numLoc, latchNode, follow);
emptyThen = TRUE; emptyThen = true;
} }
} }
else /* already visited => emit label */ 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 */ /* Creates a conditional boolean expression and returns it */
COND_EXPR *COND_EXPR::boolOp(COND_EXPR *lhs, COND_EXPR *rhs, condOp op) COND_EXPR *COND_EXPR::boolOp(COND_EXPR *lhs, COND_EXPR *rhs, condOp op)
{ {
//printf("%s:%d\n",__FUNCTION__,int(op)); //printf("%s:%d\n",__FUNCTION__,int(op));
COND_EXPR *newExp; COND_EXPR *newExp;
newExp = newCondExp (BOOLEAN_OP); newExp = new COND_EXPR(BOOLEAN_OP);
newExp->expr.boolExpr.op = op; newExp->expr.boolExpr.op = op;
newExp->expr.boolExpr.lhs = lhs; newExp->expr.boolExpr.lhs = lhs;
newExp->expr.boolExpr.rhs = rhs; newExp->expr.boolExpr.rhs = rhs;
@ -132,7 +118,7 @@ COND_EXPR *COND_EXPR::unary(condNodeType t, COND_EXPR *sub_expr)
{ {
COND_EXPR *newExp; COND_EXPR *newExp;
newExp = newCondExp (t); newExp = new COND_EXPR(t);
newExp->expr.unaryExp = sub_expr; newExp->expr.unaryExp = sub_expr;
return (newExp); return (newExp);
} }
@ -143,9 +129,9 @@ COND_EXPR *COND_EXPR::idGlob (int16 segValue, int16 off)
{ {
COND_EXPR *newExp; COND_EXPR *newExp;
dword adr; dword adr;
Int i; size_t i;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = GLOB_VAR; newExp->expr.ident.idType = GLOB_VAR;
adr = opAdr(segValue, off); adr = opAdr(segValue, off);
for (i = 0; i < symtab.size(); i++) 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; COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = REGISTER; newExp->expr.ident.idType = REGISTER;
if ((icodeFlg & B) || (icodeFlg & SRC_B)) if ((icodeFlg & B) || (icodeFlg & SRC_B))
{ {
@ -184,7 +170,7 @@ COND_EXPR *COND_EXPR::idRegIdx(Int idx, regType reg_type)
{ {
COND_EXPR *newExp; COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = REGISTER; newExp->expr.ident.idType = REGISTER;
newExp->expr.ident.regiType = reg_type; newExp->expr.ident.regiType = reg_type;
newExp->expr.ident.idNode.regiIdx = idx; newExp->expr.ident.idNode.regiIdx = idx;
@ -197,7 +183,7 @@ COND_EXPR *COND_EXPR::idLoc(Int off, LOCAL_ID *localId)
COND_EXPR *newExp; COND_EXPR *newExp;
size_t i; size_t i;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = LOCAL_VAR; newExp->expr.ident.idType = LOCAL_VAR;
for (i = 0; i < localId->csym(); i++) for (i = 0; i < localId->csym(); i++)
if ((localId->id_arr[i].id.bwId.off == off) && 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; COND_EXPR *newExp;
size_t i; size_t i;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = PARAM; newExp->expr.ident.idType = PARAM;
for (i = 0; i < argSymtab->sym.size(); i++) for (i = 0; i < argSymtab->sym.size(); i++)
if (argSymtab->sym[i].off == off) 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; COND_EXPR *newExp;
size_t i; size_t i;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = GLOB_VAR_IDX; newExp->expr.ident.idType = GLOB_VAR_IDX;
for (i = 0; i < locSym->csym(); i++) for (i = 0; i < locSym->csym(); i++)
if ((locSym->id_arr[i].id.bwGlb.seg == segValue) && 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 */ /* Returns an identifier conditional expression node of type CONSTANT */
COND_EXPR *COND_EXPR::idKte(dword kte, byte size) COND_EXPR *COND_EXPR::idKte(dword kte, byte size)
{ {
COND_EXPR *newExp; COND_EXPR *newExp = new COND_EXPR(IDENTIFIER);
newExp = newCondExp (IDENTIFIER);
newExp->expr.ident.idType = CONSTANT; newExp->expr.ident.idType = CONSTANT;
newExp->expr.ident.idNode.kte.kte = kte; newExp->expr.ident.idNode.kte.kte = kte;
newExp->expr.ident.idNode.kte.size = size; 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. */ * that points to the given index idx. */
COND_EXPR *COND_EXPR::idLongIdx (Int idx) COND_EXPR *COND_EXPR::idLongIdx (Int idx)
{ {
COND_EXPR *newExp; COND_EXPR *newExp = new COND_EXPR(IDENTIFIER);
newExp = newCondExp (IDENTIFIER);
newExp->expr.ident.idType = LONG_VAR; newExp->expr.ident.idType = LONG_VAR;
newExp->expr.ident.idNode.longIdx = idx; newExp->expr.ident.idNode.longIdx = idx;
return (newExp); return (newExp);
@ -278,10 +260,8 @@ COND_EXPR *COND_EXPR::idLongIdx (Int idx)
/* Returns an identifier conditional expression node of type LONG_VAR */ /* 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 *COND_EXPR::idLong(LOCAL_ID *localId, opLoc sd, iICODE pIcode, hlFirst f, Int ix, operDu du, Int off)
{ {
COND_EXPR *newExp;
Int idx; Int idx;
COND_EXPR *newExp = new COND_EXPR(IDENTIFIER);
newExp = newCondExp (IDENTIFIER);
/* Check for long constant and save it as a constant expression */ /* Check for long constant and save it as a constant expression */
if ((sd == SRC) && ((pIcode->ic.ll.flg & I) == I)) /* constant */ 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; COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = FUNCTION; newExp->expr.ident.idType = FUNCTION;
newExp->expr.ident.idNode.call.proc = pproc; newExp->expr.ident.idNode.call.proc = pproc;
newExp->expr.ident.idNode.call.args = args; 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; COND_EXPR *newExp;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
newExp->expr.ident.idType = OTHER; newExp->expr.ident.idType = OTHER;
newExp->expr.ident.idNode.other.seg = seg; newExp->expr.ident.idNode.other.seg = seg;
newExp->expr.ident.idNode.other.regi = regi; 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; COND_EXPR *newExp;
Int idx; Int idx;
newExp = newCondExp (IDENTIFIER); newExp = new COND_EXPR(IDENTIFIER);
if (retVal->type == TYPE_LONG_SIGN) if (retVal->type == TYPE_LONG_SIGN)
{ {
idx = locsym->newLongReg (TYPE_LONG_SIGN, retVal->id.longId.h,retVal->id.longId.l, ix); 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 POST_INC: case POST_DEC:
case PRE_INC: case PRE_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 ADDRESSOF: return (TYPE_PTR); /***????****/
case DEREFERENCE: 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 */ int16 off; /* temporal - for OTHER */
ID* id; /* Pointer to local identifier table */ ID* id; /* Pointer to local identifier table */
char* o; /* Operand string pointer */ //char* o; /* Operand string pointer */
boolT needBracket; /* Determine whether parenthesis is needed */ bool needBracket; /* Determine whether parenthesis is needed */
BWGLB_TYPE* bwGlb; /* Ptr to BWGLB_TYPE (global indexed var) */ BWGLB_TYPE* bwGlb; /* Ptr to BWGLB_TYPE (global indexed var) */
STKSYM * psym; /* Pointer to argument in the stack */ STKSYM * psym; /* Pointer to argument in the stack */
std::ostringstream outStr; std::ostringstream outStr;
@ -662,7 +643,7 @@ string walkCondExpr (const COND_EXPR* expr, Function * pProc, Int* numLoc)
if (expr == NULL) if (expr == NULL)
return ""; return "";
needBracket = TRUE; needBracket = true;
switch (expr->type) switch (expr->type)
{ {
case BOOLEAN_OP: case BOOLEAN_OP:
@ -841,7 +822,7 @@ COND_EXPR *COND_EXPR::clone()
break; break;
case IDENTIFIER: case IDENTIFIER:
newExp = new COND_EXPR(*this); return new COND_EXPR(*this);
} }
return (newExp); 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 /* Inserts the expression exp into the tree at the location specified by the
* register regi */ * 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; 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 /* Inserts the expression exp into the tree at the location specified by the
* long register index longIdx*/ * 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) { switch ((*tree)->type)
case IDENTIFIER: if ((*tree)->expr.ident.idNode.longIdx == longIdx) {
case IDENTIFIER:
if ((*tree)->expr.ident.idNode.longIdx == longIdx)
{ {
*tree = exp; *tree = exp;
return TRUE; return true;
} }
return FALSE; return false;
case BOOLEAN_OP: if (insertSubTreeLongReg (exp, &(*tree)->expr.boolExpr.lhs, longIdx)) case BOOLEAN_OP:
return TRUE; if (insertSubTreeLongReg (exp, &(*tree)->expr.boolExpr.lhs, longIdx))
return true;
if (insertSubTreeLongReg (exp, &(*tree)->expr.boolExpr.rhs, longIdx)) if (insertSubTreeLongReg (exp, &(*tree)->expr.boolExpr.rhs, longIdx))
return TRUE; return true;
return FALSE; return false;
case NEGATION: case NEGATION:
case ADDRESSOF: case ADDRESSOF:
case DEREFERENCE: if (insertSubTreeLongReg (exp, &(*tree)->expr.unaryExp, longIdx)) case DEREFERENCE:
return TRUE; if (insertSubTreeLongReg (exp, &(*tree)->expr.unaryExp, longIdx))
return FALSE; 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+1], prog.Image[relocOp+2],
prog.Image[relocOp+3]); prog.Image[relocOp+3]);
break; break;
default:strContents = (char *)allocMem((psym->size*2+1) *sizeof(char)); default:
strContents = (char *)malloc((psym->size*2+1) *sizeof(char));
strContents[0] = '\0'; strContents[0] = '\0';
for (j=0; j < psym->size; j++) for (j=0; j < psym->size; j++)
strcat (strContents, cChar(prog.Image[relocOp + j])); strcat (strContents, cChar(prog.Image[relocOp + j]));
cCode.appendDecl( "char\t*%s = \"%s\";\n", cCode.appendDecl( "char\t*%s = \"%s\";\n",
psym->name, strContents); 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. */ /* Invokes the necessary routines to produce code one procedure at a time. */
void BackEnd (char *fileName, CALL_GRAPH * pcallGraph) void BackEnd (char *fileName, CALL_GRAPH * pcallGraph)
{ {
char* outName, *ext;
std::ofstream fs; /* Output C file */ std::ofstream fs; /* Output C file */
/* Get output file name */ /* Get output file name */
outName = strcpy ((char*)allocMem(strlen(fileName)+1), fileName); std::string outNam(fileName);
if ((ext = strrchr (outName, '.')) != NULL) outNam = outNam.substr(0,outNam.rfind("."))+".b"; /* b for beta */
*ext = '\0';
strcat (outName, ".b"); /* b for beta */
/* Open output file */ /* Open output file */
fs.open(outName); fs.open(outNam);
if(!fs.is_open()) if(!fs.is_open())
fatalError (CANNOT_OPEN, outName); fatalError (CANNOT_OPEN, outNam.c_str());
printf ("dcc: Writing C beta file %s\n", outName); printf ("dcc: Writing C beta file %s\n", outNam.c_str());
/* Header information */ /* Header information */
writeHeader (fs, fileName); writeHeader (fs, fileName);

View File

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

View File

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

View File

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

View File

@ -129,13 +129,13 @@ NextArg:;
{ {
if (! asm1_name) 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, '.'); pc = strrchr(asm1_name, '.');
if (pc > strrchr(asm1_name, '/')) if (pc > strrchr(asm1_name, '/'))
{ {
*pc = '\0'; *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"); strcat(strcpy(asm2_name, asm1_name), ".a2");
unlink(asm2_name); unlink(asm2_name);
strcat(asm1_name, ".a1"); strcat(asm1_name, ".a1");

View File

@ -215,7 +215,7 @@ void disassem(Int pass, Function * ppProc)
JmpInst(pc[i].ic.ll.opcode)) JmpInst(pc[i].ic.ll.opcode))
{ {
/* Replace the immediate operand with an icode index */ /* 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 */ /* This icode is the target of a jump */
pc[pc[i].ic.ll.immed.op].ic.ll.flg |= TARGET; 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. fatalError: displays error message and exits the program.
****************************************************************************/ ****************************************************************************/
void fatalError(Int errId, ...) void fatalError(eErrorId errId, ...)
{ va_list args; { va_list args;
//#ifdef __UNIX__ /* ultrix */ //#ifdef __UNIX__ /* ultrix */
#if 0 #if 0
@ -66,7 +66,7 @@ void fatalError(Int errId, ...)
/**************************************************************************** /****************************************************************************
reportError: reports the warning/error and continues with the program. reportError: reports the warning/error and continues with the program.
****************************************************************************/ ****************************************************************************/
void reportError(Int errId, ...) void reportError(eErrorId errId, ...)
{ va_list args; { va_list args;
//#ifdef __UNIX__ /* ultrix */ //#ifdef __UNIX__ /* ultrix */
#if 0 #if 0

View File

@ -1,8 +1,8 @@
/***************************************************************************** /*****************************************************************************
* dcc project Front End module * dcc project Front End module
* Loads a program into simulated main memory and builds the procedure list. * Loads a program into simulated main memory and builds the procedure list.
* (C) Cristina Cifuentes * (C) Cristina Cifuentes
****************************************************************************/ ****************************************************************************/
#include "dcc.h" #include "dcc.h"
#include <stdio.h> #include <stdio.h>
@ -58,9 +58,9 @@ static void displayLoadInfo(void);
static void displayMemMap(void); static void displayMemMap(void);
/***************************************************************************** /*****************************************************************************
* FrontEnd - invokes the loader, parser, disassembler (if asm1), icode * FrontEnd - invokes the loader, parser, disassembler (if asm1), icode
* rewritter, and displays any useful information. * rewritter, and displays any useful information.
****************************************************************************/ ****************************************************************************/
void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph) void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
{ {
/* Load program into memory */ /* Load program into memory */
@ -70,7 +70,7 @@ void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
displayLoadInfo(); displayLoadInfo();
/* Do depth first flow analysis building call graph and procedure list, /* Do depth first flow analysis building call graph and procedure list,
* and attaching the I-code to each procedure */ * and attaching the I-code to each procedure */
parse (pcallGraph); parse (pcallGraph);
if (option.asm1) if (option.asm1)
@ -79,29 +79,30 @@ void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
} }
/* Search through code looking for impure references and flag them */ /* Search through code looking for impure references and flag them */
std::for_each(pProcList.begin(),pProcList.end(), for(Function &f : pProcList)
[](Function &f)->void { {
f.markImpure(); f.markImpure();
if (option.asm1) if (option.asm1)
disassem(1, &f); }); disassem(1, &f);
if (option.Interact) }
{ if (option.Interact)
{
interactDis(&pProcList.front(), 0); /* Interactive disassembler */ interactDis(&pProcList.front(), 0); /* Interactive disassembler */
} }
/* Converts jump target addresses to icode offsets */ /* Converts jump target addresses to icode offsets */
std::for_each(pProcList.begin(),pProcList.end(), for(Function &f : pProcList)
[](Function &f)->void { f.bindIcodeOff(); }); f.bindIcodeOff();
/* Print memory bitmap */ /* Print memory bitmap */
if (option.Map) if (option.Map)
displayMemMap(); displayMemMap();
} }
/**************************************************************************** /****************************************************************************
* displayLoadInfo - Displays low level loader type info. * displayLoadInfo - Displays low level loader type info.
***************************************************************************/ ***************************************************************************/
static void displayLoadInfo(void) static void displayLoadInfo(void)
{ {
Int i; Int i;
@ -133,8 +134,8 @@ static void displayLoadInfo(void)
/***************************************************************************** /*****************************************************************************
* fill - Fills line for displayMemMap() * fill - Fills line for displayMemMap()
****************************************************************************/ ****************************************************************************/
static void fill(Int ip, char *bf) static void fill(Int ip, char *bf)
{ {
static byte type[4] = {'.', 'd', 'c', 'x'}; static byte type[4] = {'.', 'd', 'c', 'x'};
@ -151,8 +152,8 @@ static void fill(Int ip, char *bf)
/***************************************************************************** /*****************************************************************************
* displayMemMap - Displays the memory bitmap * displayMemMap - Displays the memory bitmap
****************************************************************************/ ****************************************************************************/
static void displayMemMap(void) static void displayMemMap(void)
{ {
char c, b1[33], b2[33], b3[33]; char c, b1[33], b2[33], b3[33];
@ -187,8 +188,8 @@ static void displayMemMap(void)
/***************************************************************************** /*****************************************************************************
* LoadImage * LoadImage
****************************************************************************/ ****************************************************************************/
static void LoadImage(char *filename) static void LoadImage(char *filename)
{ {
FILE *fp; FILE *fp;
@ -222,10 +223,10 @@ static void LoadImage(char *filename)
} }
/* Calculate the load module size. /* Calculate the load module size.
* This is the number of pages in the file * This is the number of pages in the file
* less the length of the header and reloc table * less the length of the header and reloc table
* less the number of bytes unused on last page * less the number of bytes unused on last page
*/ */
cb = (dword)LH(&header.numPages) * 512 - (dword)LH(&header.numParaHeader) * 16; cb = (dword)LH(&header.numPages) * 512 - (dword)LH(&header.numParaHeader) * 16;
if (header.lastPageSize) if (header.lastPageSize)
{ {
@ -233,13 +234,13 @@ static void LoadImage(char *filename)
} }
/* We quietly ignore minAlloc and maxAlloc since for our /* We quietly ignore minAlloc and maxAlloc since for our
* purposes it doesn't really matter where in real memory * purposes it doesn't really matter where in real memory
* the program would end up. EXE programs can't really rely on * the program would end up. EXE programs can't really rely on
* their load location so setting the PSP segment to 0 is fine. * their load location so setting the PSP segment to 0 is fine.
* Certainly programs that prod around in DOS or BIOS are going * Certainly programs that prod around in DOS or BIOS are going
* to have to load DS from a constant so it'll be pretty * to have to load DS from a constant so it'll be pretty
* obvious. * obvious.
*/ */
prog.initCS = (int16)LH(&header.initCS) + EXE_RELOCATION; prog.initCS = (int16)LH(&header.initCS) + EXE_RELOCATION;
prog.initIP = (int16)LH(&header.initIP); prog.initIP = (int16)LH(&header.initIP);
prog.initSS = (int16)LH(&header.initSS) + EXE_RELOCATION; prog.initSS = (int16)LH(&header.initSS) + EXE_RELOCATION;
@ -249,7 +250,7 @@ static void LoadImage(char *filename)
/* Allocate the relocation table */ /* Allocate the relocation table */
if (prog.cReloc) if (prog.cReloc)
{ {
prog.relocTable = (dword*)allocMem(prog.cReloc * sizeof(Int)); prog.relocTable = new dword [prog.cReloc];
fseek(fp, LH(&header.relocTabOffset), SEEK_SET); fseek(fp, LH(&header.relocTabOffset), SEEK_SET);
/* Read in seg:offset pairs and convert to Image ptrs */ /* 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. */ /* Allocate a block of memory for the program. */
prog.cbImage = cb + sizeof(PSP); 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[0] = 0xCD; /* Fill in PSP Int 20h location */
prog.Image[1] = 0x20; /* for termination checking */ prog.Image[1] = 0x20; /* for termination checking */
@ -304,7 +305,8 @@ static void LoadImage(char *filename)
/* Set up memory map */ /* Set up memory map */
cb = (prog.cbImage + 3) / 4; 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 */ /* Relocate segment constants */
if (prog.cReloc) if (prog.cReloc)
@ -323,8 +325,8 @@ static void LoadImage(char *filename)
/***************************************************************************** /*****************************************************************************
* allocMem - malloc with failure test * allocMem - malloc with failure test
****************************************************************************/ ****************************************************************************/
void *allocMem(Int cb) void *allocMem(Int cb)
{ {
byte *p; byte *p;
@ -336,37 +338,6 @@ void *allocMem(Int cb)
{ {
fatalError(MALLOC_FAILED, cb); fatalError(MALLOC_FAILED, cb);
} }
/*printf("allocMem: %p\n", p);/**/ // printf("allocMem: %p\n", p);
return 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() 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) void BB::dfsNumbering(std::vector<BB *> &dfsLast, Int *first, Int *last)
{ {
BB * pChild; BB * pChild;
byte i;
traversed = DFS_NUM; traversed = DFS_NUM;
dfsFirstNum = (*first)++; dfsFirstNum = (*first)++;
/* index is being used as an index to inEdges[]. */ /* 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; pChild->inEdges[pChild->index++] = this;
/* Is this the last visit? */ /* Is this the last visit? */

View File

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

View File

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

View File

@ -13,7 +13,7 @@
/***************************************************************************** /*****************************************************************************
* JmpInst - Returns TRUE if opcode is a conditional or unconditional jump * JmpInst - Returns TRUE if opcode is a conditional or unconditional jump
****************************************************************************/ ****************************************************************************/
boolT JmpInst(llIcode opcode) bool JmpInst(llIcode opcode)
{ {
switch (opcode) { switch (opcode) {
case iJMP: case iJMPF: case iJCXZ: case iJMP: case iJMPF: case iJCXZ:
@ -22,9 +22,9 @@ boolT JmpInst(llIcode opcode)
case iJL: case iJLE: case iJGE: case iJG: case iJL: case iJLE: case iJGE: case iJG:
case iJE: case iJNE: case iJS: case iJNS: case iJE: case iJNE: case iJS: case iJNS:
case iJO: case iJNO: case iJP: case iJNP: 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. */ * binds jump target addresses to icode offsets. */
void Function::bindIcodeOff() void Function::bindIcodeOff()
{ {
Int i, j; /* idx into icode array */ Int i; /* idx into icode array */
iICODE pIcode; /* ptr icode array */ iICODE pIcode; /* ptr icode array */
dword *p; /* for case table */ dword *p,j; /* for case table */
if (! Icode.GetNumIcodes()) /* No Icode */ if (! Icode.GetNumIcodes()) /* No Icode */
return; return;
@ -1430,7 +1430,7 @@ void Function::bindIcodeOff()
for (i = 0; i < Icode.GetNumIcodes(); i++) for (i = 0; i < Icode.GetNumIcodes(); i++)
if ((pIcode[i].ic.ll.flg & I) && JmpInst(pIcode[i].ic.ll.opcode)) 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; pIcode[j].ic.ll.flg |= TARGET;
} }
@ -1445,14 +1445,14 @@ void Function::bindIcodeOff()
{ {
if (pIcode->ic.ll.flg & I) 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; pIcode->ic.ll.flg |= NO_LABEL;
} }
else if (pIcode->ic.ll.flg & SWITCH) else if (pIcode->ic.ll.flg & SWITCH)
{ {
p = pIcode->ic.ll.caseTbl.entries; p = pIcode->ic.ll.caseTbl.entries;
for (j = 0; j < pIcode->ic.ll.caseTbl.numEntries; j++, p++) 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 */ ICODE eIcode; /* extra icodes for iDIV, iIDIV, iXCHG */
SYM * psym; SYM * psym;
dword offset; dword offset;
Int err; eErrorId err;
boolT done = FALSE; boolT done = FALSE;
Int lab; dword lab;
if (strstr(name, "chkstk") != NULL) 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)); flg |= (_Icode.ic.ll.flg & (NOT_HLL | FLOAT_OP));
/* Check if this instruction has already been parsed */ /* 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 */ { /* Synthetic jump */
_Icode.type = LOW_LEVEL; _Icode.type = LOW_LEVEL;
_Icode.ic.ll.opcode = iJMP; _Icode.ic.ll.opcode = iJMP;
@ -397,7 +397,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr
ICODE _Icode; ICODE _Icode;
dword cs, offTable, endTable; dword cs, offTable, endTable;
dword i, k, seg, target; dword i, k, seg, target;
Int tmp; dword tmp;
if (pIcode->ic.ll.flg & I) 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 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 /* 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 /* labelSrchRepl - Searches Icode for instruction with label = target, and
replaces *pIndex with an icode index */ 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; Int i;
@ -863,10 +863,10 @@ boolT labelSrch(CIcodeRec &pIcode, Int numIp, dword target, Int *pIndex)
if (pIcode[i].ic.ll.label == target) if (pIcode[i].ic.ll.label == target)
{ {
*pIndex = i; *pIndex = i;
return TRUE; return true;
} }
} }
return FALSE; return false;
} }

View File

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

View File

@ -108,54 +108,54 @@ static void longJCond23 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode,
tbb->inEdges.erase(iter); /* looses 1 arc */ tbb->inEdges.erase(iter); /* looses 1 arc */
/* Update icode index */ /* Update icode index */
(*idx) += 5; (*idx) += 5;
} }
else /* ELSE arc */ else /* ELSE arc */
{ {
/* Find intermediate basic blocks and target block */ /* Find intermediate basic blocks and target block */
pbb = pIcode->inBB; pbb = pIcode->inBB;
obb1 = pbb->edges[ELSE].BBptr; obb1 = pbb->edges[ELSE].BBptr;
obb2 = obb1->edges[THEN].BBptr; obb2 = obb1->edges[THEN].BBptr;
tbb = obb2->edges[THEN].BBptr; tbb = obb2->edges[THEN].BBptr;
/* Modify in edges of target basic block */ /* Modify in edges of target basic block */
auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2); auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
assert(iter!=tbb->inEdges.end()); assert(iter!=tbb->inEdges.end());
tbb->inEdges.erase(iter); /* looses 1 arc */ tbb->inEdges.erase(iter); /* looses 1 arc */
/* Modify in edges of the ELSE basic block */ /* Modify in edges of the ELSE basic block */
tbb = obb2->edges[ELSE].BBptr; tbb = obb2->edges[ELSE].BBptr;
auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(), auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
[obb1,obb2](BB *b) -> bool [obb1,obb2](BB *b) -> bool
{ {
return (b==obb1) || (b==obb2); return (b==obb1) || (b==obb2);
} }
); );
tbb->inEdges.erase(newlast,tbb->inEdges.end()); tbb->inEdges.erase(newlast,tbb->inEdges.end());
tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */ tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
/* Modify out edge of header basic block */ /* Modify out edge of header basic block */
pbb->edges[ELSE].BBptr = tbb; pbb->edges[ELSE].BBptr = tbb;
/* Update icode index */ /* Update icode index */
(*idx) += 2; (*idx) += 2;
} }
/* Create new HLI_JCOND and condition */ /* Create new HLI_JCOND and condition */
lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[(pIcode+off+1)->ic.ll.opcode-iJB]); lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[(pIcode+off+1)->ic.ll.opcode-iJB]);
(pIcode+1)->setJCond(lhs); (pIcode+1)->setJCond(lhs);
(pIcode+1)->copyDU(*pIcode, eUSE, eUSE); (pIcode+1)->copyDU(*pIcode, eUSE, eUSE);
(pIcode+1)->du.use |= (pIcode+off)->du.use; (pIcode+1)->du.use |= (pIcode+off)->du.use;
/* Update statistics */ /* Update statistics */
obb1->flg |= INVALID_BB; obb1->flg |= INVALID_BB;
obb2->flg |= INVALID_BB; obb2->flg |= INVALID_BB;
stats.numBBaft -= 2; stats.numBBaft -= 2;
pIcode->invalidate(); pIcode->invalidate();
obb1->front().invalidate(); obb1->front().invalidate();
obb2->front().invalidate(); obb2->front().invalidate();
(obb2->begin2()+1)->invalidate(); (obb2->begin2()+1)->invalidate();
} }
@ -201,8 +201,8 @@ static void longJCond22 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode, Int *idx
tbb->inEdges.erase(iter); tbb->inEdges.erase(iter);
if ((pIcode+3)->ic.ll.opcode == iJE) /* replace */ if ((pIcode+3)->ic.ll.opcode == iJE) /* replace */
tbb->inEdges.push_back(pbb); tbb->inEdges.push_back(pbb);
// else // else
// tbb->numInEdges--; /* iJNE => looses 1 arc */ // tbb->numInEdges--; /* iJNE => looses 1 arc */
/* Update statistics */ /* Update statistics */
@ -237,7 +237,8 @@ void Function::propLongStk (Int i, ID *pLocId)
if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode) if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
{ {
switch (pIcode->ic.ll.opcode) { switch (pIcode->ic.ll.opcode)
{
case iMOV: case iMOV:
if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this, if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
&rhs, &lhs, 1) == TRUE) &rhs, &lhs, 1) == TRUE)
@ -252,7 +253,8 @@ void Function::propLongStk (Int i, ID *pLocId)
if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this, if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
&rhs, &lhs, 1) == TRUE) &rhs, &lhs, 1) == TRUE)
{ {
switch (pIcode->ic.ll.opcode) { switch (pIcode->ic.ll.opcode)
{
case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND); case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
break; break;
case iOR: rhs = COND_EXPR::boolOp (lhs, rhs, OR); 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 /* Finds the definition of the long register pointed to by pLocId, and
* transforms that instruction into a HIGH_LEVEL icode instruction. * transforms that instruction into a HIGH_LEVEL icode instruction.
* Arguments: i : index into the local identifier table * Arguments: i : index into the local identifier table
* pLocId: ptr to the long local identifier * pLocId: ptr to the long local identifier
* pProc : ptr to current procedure's record. */ * 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;
Int idx, j, off, arc; iICODE pEnd;
iICODE pIcode, pEnd;
ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
/* Process all definitions/uses of long registers at an icode position */ /* Process all definitions/uses of long registers at an icode position */
pEnd = this->Icode.end(); 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 */ /* 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); pIcode = Icode.begin()+(idx-1);
if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE)) if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
continue; 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) switch (pIcode->ic.ll.opcode)
{ {
case iMOV: case iMOV:
@ -329,8 +406,8 @@ void Function::propLongReg (Int i, ID *pLocId)
pmL = &(pIcode+1)->ic.ll.dst; pmL = &(pIcode+1)->ic.ll.dst;
if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) 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);
this->localId.id_arr[i].idx.push_back(idx-1); this->localId.id_arr[loc_ident_idx].idx.push_back(idx-1);
pIcode->setRegDU( pmL->regi, eDEF); pIcode->setRegDU( pmL->regi, eDEF);
rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1); rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
pIcode->setAsgn(lhs, rhs); pIcode->setAsgn(lhs, rhs);
@ -344,7 +421,7 @@ void Function::propLongReg (Int i, ID *pLocId)
pmL = &pIcode->ic.ll.dst; pmL = &pIcode->ic.ll.dst;
if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) 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->setRegDU( pmH->regi, eDEF);
pIcode->setUnary(HLI_POP, lhs); pIcode->setUnary(HLI_POP, lhs);
(pIcode+1)->invalidate(); (pIcode+1)->invalidate();
@ -359,7 +436,7 @@ void Function::propLongReg (Int i, ID *pLocId)
pmH = &(pIcode+1)->ic.ll.dst; pmH = &(pIcode+1)->ic.ll.dst;
if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi)) 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); pIcode->setRegDU( pmH->regi, USE_DEF);
rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1); rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
switch (pIcode->ic.ll.opcode) { switch (pIcode->ic.ll.opcode) {
@ -368,7 +445,8 @@ void Function::propLongReg (Int i, ID *pLocId)
case iOR: case iOR:
rhs = COND_EXPR::boolOp (lhs, rhs, OR); rhs = COND_EXPR::boolOp (lhs, rhs, OR);
break; break;
case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR); case iXOR:
rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
break; break;
} /* eos */ } /* eos */
pIcode->setAsgn(lhs, rhs); pIcode->setAsgn(lhs, rhs);
@ -378,12 +456,14 @@ void Function::propLongReg (Int i, ID *pLocId)
break; break;
} /* eos */ } /* eos */
} }
/* If no definition backwards, check forward for a use of this long reg */ /* If no definition backwards, check forward for a use of this long reg */
if (idx > 0) if (idx > 0)
continue; 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); pIcode = Icode.begin()+(idx);
if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE)) if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
continue; continue;
@ -394,7 +474,7 @@ void Function::propLongReg (Int i, ID *pLocId)
if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) && if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
(pLocId->id.longId.l == (pIcode+1)->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->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
lhs = COND_EXPR::idLong (&this->localId, DST, pIcode, lhs = COND_EXPR::idLong (&this->localId, DST, pIcode,
HIGH_FIRST, idx, eDEF, 1); 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) && if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
(pLocId->id.longId.l == (pIcode+1)->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->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
pIcode->setUnary(HLI_PUSH, lhs); pIcode->setUnary(HLI_PUSH, lhs);
(pIcode+1)->invalidate(); (pIcode+1)->invalidate();
@ -424,7 +504,7 @@ void Function::propLongReg (Int i, ID *pLocId)
if ((pLocId->id.longId.h == pmH->regi) && if ((pLocId->id.longId.h == pmH->regi) &&
(pLocId->id.longId.l == pmL->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); pIcode->setRegDU( pmH->regi, USE_DEF);
rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode,
LOW_FIRST, idx, eUSE, 1); LOW_FIRST, idx, eUSE, 1);
@ -447,7 +527,7 @@ void Function::propLongReg (Int i, ID *pLocId)
else if ((pIcode->ic.ll.opcode == iCMP) && else if ((pIcode->ic.ll.opcode == iCMP) &&
(isLong23 (idx, pIcode->inBB, &off, &arc))) (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) &rhs, &lhs, off) == TRUE)
longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off); 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) && else if ((pIcode->ic.ll.opcode == iCMP) &&
(isLong22 (pIcode, pEnd, &off))) (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) &rhs, &lhs, off) == TRUE)
longJCond22 (rhs, lhs, pIcode, &idx); 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) && if ((pIcode->ic.ll.dst.regi == pLocId->id.longId.h) &&
(pIcode->ic.ll.src.regi == pLocId->id.longId.l)) (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 */ rhs = COND_EXPR::idKte (0, 4); /* long 0 */
lhs = COND_EXPR::boolOp (lhs, rhs, lhs = COND_EXPR::boolOp (lhs, rhs,

View File

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

View File

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

View File

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