More tabs replaced with spaces

This commit is contained in:
nemerle 2016-05-06 15:57:15 +02:00
parent 59c199837c
commit 888de8d35e
34 changed files with 671 additions and 678 deletions

View File

@ -52,23 +52,23 @@ private:
/* Procedure FLAGS */
enum PROC_FLAGS
{
PROC_BADINST=0x00000100,/* Proc contains invalid or 386 instruction */
PROC_IJMP =0x00000200,/* Proc incomplete due to indirect jmp */
PROC_ICALL =0x00000400, /* Proc incomplete due to indirect call */
PROC_HLL =0x00001000, /* Proc is likely to be from a HLL */
PROC_NEAR =0x00010000, /* Proc exits with near return */
PROC_FAR =0x00020000, /* Proc exits with far return */
GRAPH_IRRED =0x00100000, /* Proc generates an irreducible graph */
SI_REGVAR =0x00200000, /* SI is used as a stack variable */
DI_REGVAR =0x00400000, /* DI is used as a stack variable */
REG_ARGS =0x01000000, /* Proc has registers as arguments */
// PROC_VARARG =0x02000000, /* Proc has variable arguments */
PROC_OUTPUT =0x04000000, /* C for this proc has been output */
PROC_RUNTIME=0x08000000, /* Proc is part of the runtime support */
PROC_ISLIB =0x10000000, /* Proc is a library function */
PROC_ASM =0x20000000, /* Proc is an intrinsic assembler routine */
PROC_IS_HLL =0x40000000 /* Proc has HLL prolog code */
//#define CALL_MASK 0xFFFF9FFF /* Masks off CALL_C and CALL_PASCAL */
PROC_BADINST=0x00000100, /* Proc contains invalid or 386 instruction */
PROC_IJMP =0x00000200, /* Proc incomplete due to indirect jmp */
PROC_ICALL =0x00000400, /* Proc incomplete due to indirect call */
PROC_HLL =0x00001000, /* Proc is likely to be from a HLL */
PROC_NEAR =0x00010000, /* Proc exits with near return */
PROC_FAR =0x00020000, /* Proc exits with far return */
GRAPH_IRRED =0x00100000, /* Proc generates an irreducible graph */
SI_REGVAR =0x00200000, /* SI is used as a stack variable */
DI_REGVAR =0x00400000, /* DI is used as a stack variable */
REG_ARGS =0x01000000, /* Proc has registers as arguments */
// PROC_VARARG =0x02000000, /* Proc has variable arguments */
PROC_OUTPUT =0x04000000, /* C for this proc has been output */
PROC_RUNTIME=0x08000000, /* Proc is part of the runtime support */
PROC_ISLIB =0x10000000, /* Proc is a library function */
PROC_ASM =0x20000000, /* Proc is an intrinsic assembler routine */
PROC_IS_HLL =0x40000000 /* Proc has HLL prolog code */
//#define CALL_MASK 0xFFFF9FFF /* Masks off CALL_C and CALL_PASCAL */
};
struct Type {
@ -78,7 +78,7 @@ struct FunctionType : public Type
{
CConv * m_call_conv;
std::vector<Type> ContainedTys;
ID retVal; /* Return value - identifier */
ID retVal; /* Return value - identifier */
bool m_vararg=false;
unsigned getNumParams() const { return ContainedTys.size(); }
bool isVarArg() const {return m_vararg;}
@ -192,7 +192,7 @@ public:
/* For interprocedural live analysis */
LivenessSet liveIn; /* Registers used before defined */
LivenessSet liveOut; /* Registers that may be used in successors */
bool liveAnal; /* Procedure has been analysed already */
bool liveAnal; /* Procedure has been analysed already */
virtual ~Function() {
delete type;

View File

@ -77,18 +77,17 @@ extern STATS stats; /* Icode statistics */
void udm(void); /* udm.c */
void freeCFG(BB * cfg); /* graph.c */
BB * newBB(BB *, int, int, uint8_t, int, Function *); /* graph.c */
void BackEnd(CALL_GRAPH *); /* backend.c */
void BackEnd(CALL_GRAPH *); /* backend.c */
extern char *cChar(uint8_t c); /* backend.c */
eErrorId scan(uint32_t ip, ICODE &p); /* scanner.c */
void parse (CALL_GRAPH * *); /* parser.c */
extern int strSize (const uint8_t *, char); /* parser.c */
//void disassem(int pass, Function * pProc); /* disassem.c */
void interactDis(const PtrFunction &, int initIC); /* disassem.c */
bool JmpInst(llIcode opcode); /* idioms.c */
queue::iterator appendQueue(queue &Q, BB *node); /* reducible.c */
bool SetupLibCheck(QString pattern_file_id); /* chklib.c */
bool SetupLibCheck(QString pattern_file_id); /* chklib.c */
void CleanupLibCheck(void); /* chklib.c */
bool LibCheck(Function &p); /* chklib.c */

View File

@ -9,9 +9,7 @@ class IStructuredTextTarget;
struct IDcc {
static IDcc *get();
virtual void BaseInit()=0;
virtual bool load(QString name)=0; // load and preprocess -> find entry point
virtual const lFunction &validFunctions() const =0;
virtual QDir installDir()=0;
virtual QDir dataDir(QString kind)=0;
};

View File

@ -38,21 +38,21 @@ public:
};
/* Definitions for extended keys (first key is zero) */
#define EXT 0x100 /* "Extended" flag */
#define EXT 0x100 /* "Extended" flag */
#ifdef __UNIX__
#define KEY_DOWN EXT+'B'
#define KEY_LEFT EXT+'D'
#define KEY_UP EXT+'A'
#define KEY_RIGHT EXT+'C'
#define KEY_NPAGE EXT+'J' /* Enter correct value! */
#define KEY_PPAGE EXT+'K' /* Another guess! */
#define KEY_DOWN EXT+'B'
#define KEY_LEFT EXT+'D'
#define KEY_UP EXT+'A'
#define KEY_RIGHT EXT+'C'
#define KEY_NPAGE EXT+'J' /* Enter correct value! */
#define KEY_PPAGE EXT+'K' /* Another guess! */
#endif
/* "Attributes" */
#define A_NORMAL 'N' /* For Dos/Unix */
#define A_REVERSE 'I'
#define A_BOLD 'B'
#define A_NORMAL 'N' /* For Dos/Unix */
#define A_REVERSE 'I'
#define A_BOLD 'B'
#define LINES 24
#define COLS 80

View File

@ -51,16 +51,16 @@ enum eNodeHeaderType
/* Uninitialized values for certain fields */
#define NO_NODE MAX /* node has no associated node */
#define NO_DOM MAX /* node has no dominator */
#define UN_INIT MAX /* uninitialized variable */
#define NO_DOM MAX /* node has no dominator */
#define UN_INIT MAX /* uninitialized variable */
#define THEN 0 /* then edge */
#define ELSE 1 /* else edge */
/* Basic Block (BB) flags */
#define INVALID_BB 0x0001 /* BB is not valid any more */
#define IS_LATCH_NODE 0x0002 /* BB is the latching node of a loop */
#define INVALID_BB 0x0001 /* BB is not valid any more */
#define IS_LATCH_NODE 0x0002 /* BB is the latching node of a loop */
struct BB;
/* Interval structure */

View File

@ -7,7 +7,7 @@
#include "BinaryImage.h"
#include "libdis.h"
#include "Enums.h"
#include "state.h" // State depends on INDEXBASE, but later need STATE
#include "state.h" // State depends on INDEXBASE, but later need STATE
#include "CallConvention.h"
#include <llvm/ADT/ilist.h>
@ -137,7 +137,7 @@ struct DU
};
/* Definition-use chain for level 1 (within a basic block) */
#define MAX_REGS_DEF 4 /* 2 regs def'd for long-reg vars */
#define MAX_REGS_DEF 4 /* 2 regs def'd for long-reg vars */
struct Expr;
@ -263,9 +263,9 @@ struct LLOperand
bool is_compound;
size_t width;
/* Source operand if (flg & I) */
struct { /* Call & # actual arg bytes */
struct { /* Call & # actual arg bytes */
Function *proc; /* pointer to target proc (for CALL(F))*/
int cb; /* # actual arg bytes */
int cb; /* # actual arg bytes */
} proc;
LLOperand() : seg(rUNDEF),segOver(rUNDEF),segValue(0),regi(rUNDEF),off(0),
opz(0),immed(0),is_offset(false),is_compound(0),width(0)
@ -329,7 +329,7 @@ public:
uint8_t numBytes; /* Number of bytes this instr */
uint32_t label; /* offset in image (20-bit adr) */
LLOperand m_dst; /* destination operand */
DU flagDU; /* def/use of flags */
DU flagDU; /* def/use of flags */
int caseEntry;
std::vector<uint32_t> caseTbl2;
int hllLabNum; /* label # for hll codegen */

View File

@ -36,32 +36,32 @@ struct IDX_ARRAY : public std::vector<iICODE>
enum frameType
{
STK_FRAME, /* For stack vars */
REG_FRAME, /* For register variables */
GLB_FRAME /* For globals */
STK_FRAME, /* For stack vars */
REG_FRAME, /* For register variables */
GLB_FRAME /* For globals */
};
struct BWGLB_TYPE
{
int16_t seg; /* segment value */
int16_t off; /* offset */
eReg regi; /* optional indexed register */
int16_t seg; /* segment value */
int16_t off; /* offset */
eReg regi; /* optional indexed register */
} ;
/* For TYPE_LONG_(UN)SIGN on the stack */
struct LONG_STKID_TYPE
{
int offH; /* high offset from BP */
int offL; /* low offset from BP */
int offH; /* high offset from BP */
int offL; /* low offset from BP */
LONG_STKID_TYPE(int h,int l) : offH(h),offL(l) {}
};
/* For TYPE_LONG_(UN)SIGN registers */
/* For TYPE_LONG_(UN)SIGN registers */
struct LONGID_TYPE
{
protected:
eReg m_h; /* high register */
eReg m_l; /* low register */
eReg m_h; /* high register */
eReg m_l; /* low register */
public:
void set(eReg highpart,eReg lowpart)
{
@ -75,7 +75,7 @@ public:
LONGID_TYPE(eReg h,eReg l) : m_h(h),m_l(l) {}
};
struct LONGGLB_TYPE /* For TYPE_LONG_(UN)SIGN globals */
struct LONGGLB_TYPE /* For TYPE_LONG_(UN)SIGN globals */
{
int16_t seg; /* segment value */
int16_t offH; /* offset high */
@ -93,7 +93,7 @@ struct LONGGLB_TYPE /* For TYPE_LONG_(UN)SIGN globals */
struct ID
{
protected:
LONGID_TYPE m_longId; /* For TYPE_LONG_(UN)SIGN registers */
LONGID_TYPE m_longId; /* For TYPE_LONG_(UN)SIGN registers */
public:
hlType type; /* Probable type */
bool illegal; /* Boolean: not a valid field any more */
@ -105,16 +105,16 @@ public:
QString name; /* Identifier's name */
union ID_UNION { /* Different types of identifiers */
LONG_STKID_TYPE longStkId; /* For TYPE_LONG_(UN)SIGN on the stack */
eReg regi; /* For TYPE_BYTE(WORD)_(UN)SIGN registers */
eReg regi; /* For TYPE_BYTE(WORD)_(UN)SIGN registers */
struct { /* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */
uint8_t regOff; /* register offset (if any) */
int off; /* offset from BP */
int off; /* offset from BP */
} bwId;
BWGLB_TYPE bwGlb; /* For TYPE_BYTE(uint16_t)_(UN)SIGN globals */
BWGLB_TYPE bwGlb; /* For TYPE_BYTE(uint16_t)_(UN)SIGN globals */
LONGGLB_TYPE longGlb;
struct { /* For TYPE_LONG_(UN)SIGN constants */
uint32_t h; /* high uint16_t */
uint32_t l; /* low uint16_t */
struct { /* For TYPE_LONG_(UN)SIGN constants */
uint32_t h; /* high uint16_t */
uint32_t l; /* low uint16_t */
} longKte;
ID_UNION() { /*new (&longStkId) LONG_STKID_TYPE();*/}
} id;

View File

@ -21,10 +21,10 @@ struct TypeContainer;
/* * * * * * * * * * * * * * * * * */
struct SymbolCommon
{
QString name; /* New name for this variable/symbol/argument */
int size; /* Size/maximum size */
QString name; /* New name for this variable/symbol/argument */
int size; /* Size/maximum size */
hlType type; /* probable type */
eDuVal duVal; /* DEF, USE, VAL */
eDuVal duVal; /* DEF, USE, VAL */
SymbolCommon() : size(0),type(TYPE_UNKNOWN)
{}
};
@ -42,13 +42,13 @@ struct SYM : public SymbolCommon
struct STKSYM : public SymbolCommon
{
typedef int16_t tLabel;
Expr * actual=0; /* Expression tree of actual parameter */
AstIdent * regs=0; /* For register arguments only */
Expr * actual=0; /* Expression tree of actual parameter */
AstIdent * regs=0; /* For register arguments only */
tLabel label=0; /* Immediate off from BP (+:args, -:params) */
uint8_t regOff=0; /* Offset is a register (e.g. SI, DI) */
bool hasMacro=false; /* This type needs a macro */
QString macro; /* Macro name */
bool invalid=false; /* Boolean: invalid entry in formal arg list*/
bool hasMacro=false; /* This type needs a macro */
QString macro; /* Macro name */
bool invalid=false; /* Boolean: invalid entry in formal arg list*/
int arrayMembers=1; // for local variables if >1 marks this stack symbol as an array
void setArgName(int i)
{
@ -105,9 +105,9 @@ struct SYMTABLE
enum tableType /* The table types */
{
Label=0, /* The label table */
Comment /* The comment table */
Comment, /* The comment table */
NUM_TABLE_TYPES /* Number of entries: must be last */
};
constexpr int NUM_TABLE_TYPES = int(Comment)+1; /* Number of entries: must be last */
void createSymTables(void);
void destroySymTables(void);

View File

@ -28,7 +28,7 @@ BB *BB::Create(const rCODE &r,eBBKind _nodeType, Function *parent)
{
BB* pnewBB;
pnewBB = new BB;
pnewBB->nodeType = _nodeType; /* Initialise */
pnewBB->nodeType = _nodeType; /* Initialise */
pnewBB->immedDom = NO_DOM;
pnewBB->loopHead = pnewBB->caseHead = pnewBB->caseTail =
pnewBB->latchNode= pnewBB->loopFollow = NO_NODE;
@ -46,7 +46,7 @@ BB *BB::Create(const rCODE &r,eBBKind _nodeType, Function *parent)
parent->m_actual_cfg.push_back(pnewBB);
pnewBB->Parent = parent;
if ( r.begin() != parent->Icode.end() ) /* Only for code BB's */
if ( r.begin() != parent->Icode.end() ) /* Only for code BB's */
stats.numBBbef++;
}
return pnewBB;
@ -201,12 +201,12 @@ bool BB::isEndOfPath(int latch_node_idx) const
}
void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode, int _ifFollow)
{
int follow; /* ifFollow */
BB * succ, *latch; /* Successor and latching node */
ICODE * picode; /* Pointer to HLI_JCOND instruction */
QString l; /* Pointer to HLI_JCOND expression */
bool emptyThen, /* THEN clause is empty */
repCond; /* Repeat condition for while() */
int follow; /* ifFollow */
BB * succ, *latch; /* Successor and latching node */
ICODE * picode; /* Pointer to HLI_JCOND instruction */
QString l; /* Pointer to HLI_JCOND expression */
bool emptyThen, /* THEN clause is empty */
repCond; /* Repeat condition for while() */
/* Check if this basic block should be analysed */
if ((_ifFollow != UN_INIT) and (this == pProc->m_dfsLast[_ifFollow]))
@ -236,10 +236,10 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
return;
/* Check type of loop/node and process code */
if ( loopType!=eNodeHeaderType::NO_TYPE ) /* there is a loop */
if ( loopType!=eNodeHeaderType::NO_TYPE ) /* there is a loop */
{
assert(latch);
if (this != latch) /* loop is over several bbs */
if (this != latch) /* loop is over several bbs */
{
if (loopType == eNodeHeaderType::WHILE_TYPE)
{
@ -251,7 +251,7 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
succ = edges[0].BBptr;
if (succ->traversed != DFS_ALPHA)
succ->writeCode (indLevel, pProc, numLoc, latch->dfsLastNum,_ifFollow);
else /* has been traversed so we need a goto */
else /* has been traversed so we need a goto */
succ->front().ll()->emitGotoLabel (indLevel);
}
@ -293,20 +293,20 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
succ = pProc->m_dfsLast[loopFollow];
if (succ->traversed != DFS_ALPHA)
succ->writeCode (indLevel, pProc, numLoc, _latchNode, _ifFollow);
else /* has been traversed so we need a goto */
else /* has been traversed so we need a goto */
succ->front().ll()->emitGotoLabel (indLevel);
}
}
else /* no loop, process nodeType of the graph */
else /* no loop, process nodeType of the graph */
{
if (nodeType == TWO_BRANCH) /* if-then[-else] */
if (nodeType == TWO_BRANCH) /* if-then[-else] */
{
stats.numHLIcode++;
indLevel++;
emptyThen = false;
if (ifFollow != MAX) /* there is a follow */
if (ifFollow != MAX) /* there is a follow */
{
/* process the THEN part */
follow = ifFollow;
@ -319,7 +319,7 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
cCode.appendCode( "\n%s%s", indentStr(indLevel-1), qPrintable(l));
succ->writeCode (indLevel, pProc, numLoc, _latchNode,follow);
}
else /* empty THEN part => negate ELSE part */
else /* empty THEN part => negate ELSE part */
{
l = writeJcondInv ( *back().hl(), pProc, numLoc);
cCode.appendCode( "\n%s%s", indentStr(indLevel-1), qPrintable(l));
@ -332,9 +332,9 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
/* process the ELSE part */
succ = edges[ELSE].BBptr;
if (succ->traversed != DFS_ALPHA) /* not visited */
if (succ->traversed != DFS_ALPHA) /* not visited */
{
if (succ->dfsLastNum != follow) /* ELSE part */
if (succ->dfsLastNum != follow) /* ELSE part */
{
cCode.appendCode( "%s}\n%selse {\n",
indentStr(indLevel-1), indentStr(indLevel - 1));
@ -355,7 +355,7 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
if (succ->traversed != DFS_ALPHA)
succ->writeCode (indLevel, pProc, numLoc, _latchNode,_ifFollow);
}
else /* no follow => if..then..else */
else /* no follow => if..then..else */
{
l = writeJcond ( *back().hl(), pProc, numLoc);
cCode.appendCode( "%s%s", indentStr(indLevel-1), qPrintable(l));
@ -368,7 +368,7 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
else /* fall, call, 1w */
{
succ = edges[0].BBptr; /* fall-through edge */
succ = edges[0].BBptr; /* fall-through edge */
assert(succ->size()>0);
if (succ->traversed != DFS_ALPHA)
{
@ -379,8 +379,8 @@ void BB::writeCode (int indLevel, Function * pProc , int *numLoc,int _latchNode,
}
/* Writes the code for the current basic block.
* Args: pBB: pointer to the current basic block.
* Icode: pointer to the array of icodes for current procedure.
* lev: indentation level - used for formatting. */
* Icode: pointer to the array of icodes for current procedure.
* lev: indentation level - used for formatting. */
void BB::writeBB(QTextStream &ostr,int lev, Function * pProc, int *numLoc)
{
/* Save the index into the code table in case there is a later goto

View File

@ -21,7 +21,7 @@ static void displayMemMap(void);
***************************************************************************/
void PROG::displayLoadInfo(void)
{
int i;
int i;
printf("File type is %s\n", (fCOM)?"COM":"EXE");
// if (not fCOM) {
@ -55,7 +55,7 @@ static void fill(int ip, char *bf)
{
PROG &prog(Project::get()->prog);
static uint8_t type[4] = {'.', 'd', 'c', 'x'};
uint8_t i;
uint8_t i;
for (i = 0; i < 16; i++, ip++)
{
@ -73,7 +73,7 @@ static void displayMemMap(void)
{
PROG &prog(Project::get()->prog);
char c, b1[33], b2[33], b3[33];
char c, b1[33], b2[33], b3[33];
uint8_t i;
int ip = 0;
@ -84,10 +84,10 @@ static void displayMemMap(void)
printf("%06X %s\n", ip, b1);
ip += 16;
for (i = 3, c = b1[1]; i < 32 and c == b1[i]; i += 2)
; /* Check if all same */
; /* Check if all same */
if (i > 32)
{
fill(ip, b2); /* Skip until next two are not same */
fill(ip, b2); /* Skip until next two are not same */
fill(ip+16, b3);
if (not (strcmp(b1, b2) || strcmp(b1, b3)))
{

View File

@ -4,51 +4,51 @@
#include <QtCore/QDebug>
#define EXE_RELOCATION 0x10 /* EXE images rellocated to above PSP */
#define EXE_RELOCATION 0x10 /* EXE images rellocated to above PSP */
struct PSP { /* PSP structure */
uint16_t int20h; /* interrupt 20h */
uint16_t eof; /* segment, end of allocation block */
uint8_t res1; /* reserved */
uint8_t dosDisp[5]; /* far call to DOS function dispatcher */
uint8_t int22h[4]; /* vector for terminate routine */
uint8_t int23h[4]; /* vector for ctrl+break routine */
uint8_t int24h[4]; /* vector for error routine */
uint8_t res2[22]; /* reserved */
uint16_t segEnv; /* segment address of environment block */
uint8_t res3[34]; /* reserved */
uint8_t int21h[6]; /* opcode for int21h and far return */
uint8_t res4[6]; /* reserved */
uint8_t fcb1[16]; /* default file control block 1 */
uint8_t fcb2[16]; /* default file control block 2 */
uint8_t res5[4]; /* reserved */
uint8_t cmdTail[0x80]; /* command tail and disk transfer area */
struct PSP { /* PSP structure */
uint16_t int20h; /* interrupt 20h */
uint16_t eof; /* segment, end of allocation block */
uint8_t res1; /* reserved */
uint8_t dosDisp[5]; /* far call to DOS function dispatcher */
uint8_t int22h[4]; /* vector for terminate routine */
uint8_t int23h[4]; /* vector for ctrl+break routine */
uint8_t int24h[4]; /* vector for error routine */
uint8_t res2[22]; /* reserved */
uint16_t segEnv; /* segment address of environment block */
uint8_t res3[34]; /* reserved */
uint8_t int21h[6]; /* opcode for int21h and far return */
uint8_t res4[6]; /* reserved */
uint8_t fcb1[16]; /* default file control block 1 */
uint8_t fcb2[16]; /* default file control block 2 */
uint8_t res5[4]; /* reserved */
uint8_t cmdTail[0x80]; /* command tail and disk transfer area */
};
static struct MZHeader { /* EXE file header */
uint8_t sigLo; /* .EXE signature: 0x4D 0x5A */
static struct MZHeader { /* EXE file header */
uint8_t sigLo; /* .EXE signature: 0x4D 0x5A */
uint8_t sigHi;
uint16_t lastPageSize; /* Size of the last page */
uint16_t numPages; /* Number of pages in the file */
uint16_t numReloc; /* Number of relocation items */
uint16_t numParaHeader; /* # of paragraphs in the header */
uint16_t minAlloc; /* Minimum number of paragraphs */
uint16_t maxAlloc; /* Maximum number of paragraphs */
uint16_t initSS; /* Segment displacement of stack */
uint16_t initSP; /* Contents of SP at entry */
uint16_t checkSum; /* Complemented checksum */
uint16_t initIP; /* Contents of IP at entry */
uint16_t initCS; /* Segment displacement of code */
uint16_t relocTabOffset; /* Relocation table offset */
uint16_t overlayNum; /* Overlay number */
uint16_t lastPageSize; /* Size of the last page */
uint16_t numPages; /* Number of pages in the file */
uint16_t numReloc; /* Number of relocation items */
uint16_t numParaHeader; /* # of paragraphs in the header*/
uint16_t minAlloc; /* Minimum number of paragraphs */
uint16_t maxAlloc; /* Maximum number of paragraphs */
uint16_t initSS; /* Segment displacement of stack */
uint16_t initSP; /* Contents of SP at entry */
uint16_t checkSum; /* Complemented checksum */
uint16_t initIP; /* Contents of IP at entry */
uint16_t initCS; /* Segment displacement of code */
uint16_t relocTabOffset; /* Relocation table offset */
uint16_t overlayNum; /* Overlay number */
} header;
void DosLoader::prepareImage(PROG & prog, size_t sz, QFile & fp) {
/* Allocate a block of memory for the program. */
prog.cbImage = sz + sizeof(PSP);
prog.Imagez = new uint8_t [prog.cbImage];
prog.Imagez[0] = 0xCD; /* Fill in PSP int 20h location */
prog.Imagez[1] = 0x20; /* for termination checking */
prog.Imagez[0] = 0xCD; /* Fill in PSP int 20h location */
prog.Imagez[1] = 0x20; /* for termination checking */
/* Read in the image past where a PSP would go */
if (sz != fp.read((char *)prog.Imagez + sizeof(PSP),sz))
fatalError(CANNOT_READ, fp.fileName().toLocal8Bit().data());
@ -148,7 +148,7 @@ bool ExeLoader::load(PROG & prog, QFile & fp) {
fp.seek(LH(&header.relocTabOffset));
/* Read in seg:offset pairs and convert to Image ptrs */
uint8_t buf[4];
uint8_t buf[4];
for (int i = 0; i < prog.cReloc; i++)
{
fp.read((char *)buf,4);

View File

@ -63,7 +63,7 @@ QString RegisterNode::walkCondExpr(Function *pProc, int *numLoc) const
QString o;
assert(&pProc->localId==m_syms);
ID *id = &pProc->localId.id_arr[regiIdx];
if (id->name[0] == '\0') /* no name */
if (id->name[0] == '\0') /* no name */
{
id->setLocalName(++(*numLoc));
codeOut += QString("%1 %2; ").arg(TypeContainer::typeName(id->type)).arg(id->name);

View File

@ -114,7 +114,7 @@ void ICODE::copyDU(const ICODE &duIcode, operDu _du, operDu duDu)
/* Returns a unary conditional expression node. This procedure should
* only be used with the following conditional node types: NEGATION,
* ADDRESSOF, DEREFERENCE, POST_INC, POST_DEC, PRE_INC, PRE_DEC */
* ADDRESSOF, DEREFERENCE, POST_INC, POST_DEC, PRE_INC, PRE_DEC */
/* Returns an identifier conditional expression node of type GLOB_VAR */
@ -256,7 +256,7 @@ AstIdent *AstIdent::Other(eReg seg, eReg regi, int16_t off)
/* Returns an identifier conditional expression node of type TYPE_LONG or
* TYPE_WORD_SIGN */
* TYPE_WORD_SIGN */
AstIdent *AstIdent::idID (const ID *retVal, LOCAL_ID *locsym, iICODE ix_)
{
int idx;
@ -402,9 +402,9 @@ int hlSize[] = {2, 1, 1, 2, 2, 4, 4, 4, 2, 2, 1, 4, 4};
int Expr::hlTypeSize(Function * pproc) const
{
if (this == nullptr)
return (2); /* for TYPE_UNKNOWN */
return (2); /* for TYPE_UNKNOWN */
fprintf(stderr,"hlTypeSize queried for Unkown type %d \n",m_type);
return 2; // CC: is this correct?
return 2; // CC: is this correct?
}
/* Returns the type of the expression */

View File

@ -30,12 +30,12 @@ using namespace boost;
using namespace boost::adaptors;
using namespace std;
bundle cCode; /* Procedure declaration and code */
bundle cCode; /* Procedure declaration and code */
/* Returns a unique index to the next label */
int getNextLabel()
{
static int labelIdx = 1; /* index of the next label */
static int labelIdx = 1; /* index of the next label */
return (labelIdx++);
}
@ -62,8 +62,8 @@ static void fixupLabels (PPROC pProc)
* a unique label number for it. This label is placed in the associated
* icode for the node (pProc->Icode). The procedure is done in sequential
* order of dsfLast numbering. */
{ int i; /* index into the dfsLast array */
PBB *dfsLast; /* pointer to the dfsLast array */
{ int i; /* index into the dfsLast array */
PBB *dfsLast; /* pointer to the dfsLast array */
dfsLast = pProc->dfsLast;
for (i = 0; i < pProc->numBBs; i++)
@ -82,10 +82,10 @@ char *cChar (uint8_t c)
static char res[3];
switch (c) {
case 0x8: /* backspace */
case 0x8: /* backspace */
sprintf (res, "\\b");
break;
case 0x9: /* horizontal tab */
case 0x9: /* horizontal tab */
sprintf (res, "\\t");
break;
case 0x0A: /* new line */
@ -97,7 +97,7 @@ char *cChar (uint8_t c)
case 0x0D: /* carriage return */
sprintf (res, "\\r");
break;
default: /* any other character*/
default: /* any other character*/
sprintf (res, "%c", c);
}
return (res);
@ -106,8 +106,8 @@ char *cChar (uint8_t c)
/* Prints the variable's name and initial contents on the file.
* Note: to get to the value of the variable:
* com file: prog.Image[operand]
* exe file: prog.Image[operand+0x100] */
* com file: prog.Image[operand]
* exe file: prog.Image[operand+0x100] */
static void printGlobVar (QTextStream &ostr,SYM * psym)
{
int j;
@ -124,7 +124,7 @@ static void printGlobVar (QTextStream &ostr,SYM * psym)
break;
case 4: if (psym->type == TYPE_PTR) /* pointer */
ostr << "uint16_t *\t"<<psym->name<<" = "<<LH(prog.image()+relocOp)<<";\n";
else /* char */
else /* char */
ostr << "char\t"<<psym->name<<"[4] = \""<<
prog.image()[relocOp]<<prog.image()[relocOp+1]<<
prog.image()[relocOp+2]<<prog.image()[relocOp+3]<<";\n";
@ -155,7 +155,7 @@ void Project::writeGlobSymTable()
{
if (sym.duVal.isUSE_VAL()) /* first used */
printGlobVar (ostr,&sym);
else { /* first defined */
else { /* first defined */
switch (sym.size) {
case 1: ostr<<"uint8_t\t"; break;
case 2: ostr<<"int\t"; break;
@ -198,7 +198,7 @@ static void writeHeader (QIODevice &_ios, const std::string &fileName)
* to it. If so, a goto is emitted to this label; otherwise, a new label
* is created and a goto is also emitted.
* Note: this procedure is to be used when the label is to be forward on
* the code; that is, the target code has not been traversed yet. */
* the code; that is, the target code has not been traversed yet. */
#if 0
static void emitFwdGotoLabel (ICODE * pt, int indLevel)
{
@ -279,12 +279,12 @@ void Function::codeGen (QIODevice &fs)
fs.write(ostr_contents.toLatin1());
/* Write procedure's code */
if (flg & PROC_ASM) /* generate assembler */
if (flg & PROC_ASM) /* generate assembler */
{
Disassembler ds(3);
ds.disassem(this->shared_from_this());
}
else /* generate C */
else /* generate C */
{
m_actual_cfg.front()->writeCode (1, this, &numLoc, MAX, UN_INIT);
}
@ -325,7 +325,7 @@ void Function::codeGen (QIODevice &fs)
static void backBackEnd (CALL_GRAPH * pcallGraph, QIODevice &_ios)
{
// IFace.Yield(); /* This is a good place to yield to other apps */
// IFace.Yield(); /* This is a good place to yield to other apps */
/* Check if this procedure has been processed already */
if ((pcallGraph->proc->flg & PROC_OUTPUT) or

View File

@ -48,7 +48,7 @@ struct PH_FUNC_STRUCT
#define NUM_PLIST 64 /* Number of entries to increase allocation by */
/* statics */
static char buf[100]; /* A general purpose buffer */
static char buf[100]; /* A general purpose buffer */
#define DCCLIBS "dcclibs.dat" /* Name of the prototypes data file */
@ -61,7 +61,7 @@ static void readProtoFile(void);
static int searchPList(char *name);
static void checkHeap(char *msg); /* For debugging */
void fixWildCards(uint8_t pat[]); /* In fixwild.c */
void fixWildCards(uint8_t pat[]); /* In fixwild.c */
static bool locatePattern(const uint8_t *source, int iMin, int iMax, uint8_t *pattern,
int iPatLen, int *index);
@ -140,41 +140,41 @@ static uint8_t pattBorl4on[] =
static uint8_t pattBorl4Init[] =
{
0xBA, WILD, WILD, /* Mov dx, dseg */
0xBA, WILD, WILD, /* Mov dx, dseg */
0x8E, 0xDA, /* mov ds, dx */
0x8C, 0x06, WILD, WILD, /* mov [xx], es */
0x8B, 0xC4, /* mov ax, sp */
0x05, 0x13, 0, /* add ax, 13h */
0xB1, 0x04, /* mov cl, 4 */
0xD3, 0xE8, /* shr ax, cl */
0x8C, 0xD2 /* mov dx, ss */
0x8B, 0xC4, /* mov ax, sp */
0x05, 0x13, 0, /* add ax, 13h */
0xB1, 0x04, /* mov cl, 4 */
0xD3, 0xE8, /* shr ax, cl */
0x8C, 0xD2 /* mov dx, ss */
};
static uint8_t pattBorl5Init[] =
{
0xBA, WILD, WILD, /* Mov dx, dseg */
0xBA, WILD, WILD, /* Mov dx, dseg */
0x8E, 0xDA, /* mov ds, dx */
0x8C, 0x06, 0x30, 0, /* mov [0030], es */
0x33, 0xED, /* xor bp, bp <----- */
0x8B, 0xC4, /* mov ax, sp */
0x05, 0x13, 0, /* add ax, 13h */
0xB1, 0x04, /* mov cl, 4 */
0xD3, 0xE8, /* shr ax, cl */
0x8C, 0xD2 /* mov dx, ss */
0x33, 0xED, /* xor bp, bp <----- */
0x8B, 0xC4, /* mov ax, sp */
0x05, 0x13, 0, /* add ax, 13h */
0xB1, 0x04, /* mov cl, 4 */
0xD3, 0xE8, /* shr ax, cl */
0x8C, 0xD2 /* mov dx, ss */
};
static uint8_t pattBorl7Init[] =
{
0xBA, WILD, WILD, /* Mov dx, dseg */
0xBA, WILD, WILD, /* Mov dx, dseg */
0x8E, 0xDA, /* mov ds, dx */
0x8C, 0x06, 0x30, 0, /* mov [0030], es */
0xE8, WILD, WILD, /* call xxxx */
0xE8, WILD, WILD, /* call xxxx... offset always 00A0? */
0x8B, 0xC4, /* mov ax, sp */
0x05, 0x13, 0, /* add ax, 13h */
0xB1, 0x04, /* mov cl, 4 */
0xD3, 0xE8, /* shr ax, cl */
0x8C, 0xD2 /* mov dx, ss */
0xE8, WILD, WILD, /* call xxxx */
0xE8, WILD, WILD, /* call xxxx... offset always 00A0? */
0x8B, 0xC4, /* mov ax, sp */
0x05, 0x13, 0, /* add ax, 13h */
0xB1, 0x04, /* mov cl, 4 */
0xD3, 0xE8, /* shr ax, cl */
0x8C, 0xD2 /* mov dx, ss */
};
@ -207,7 +207,7 @@ static uint8_t pattMainSmall[] =
0xFF, 0x36, WILD, WILD, /* Push environment pointer */
0xFF, 0x36, WILD, WILD, /* Push argv */
0xFF, 0x36, WILD, WILD, /* Push argc */
0xE8, WILD, WILD /* call _main */
0xE8, WILD, WILD /* call _main */
// 0x50, /* push ax... not in Borland V3 */
// 0xE8 /* call _exit */
};
@ -269,16 +269,16 @@ static uint8_t pattMainLarge[] =
/* This pattern is for the stack check code in Microsoft compilers */
static uint8_t pattMsChkstk[] =
{
0x59, /* pop cx */
0x59, /* pop cx */
0x8B, 0xDC, /* mov bx, sp */
0x2B, 0xD8, /* sub bx, ax */
0x72, 0x0A, /* jb bad */
0x2B, 0xD8, /* sub bx, ax */
0x72, 0x0A, /* jb bad */
0x3B, 0x1E, WILD, WILD, /* cmp bx, XXXX */
0x72, 0x04, /* jb bad */
0x8B, 0xE3, /* mov sp, bx */
0xFF, 0xE1, /* jmp [cx] */
0x33, 0xC0, /* xor ax, ax */
0xE9 /* jmp XXXX */
0x72, 0x04, /* jb bad */
0x8B, 0xE3, /* mov sp, bx */
0xFF, 0xE1, /* jmp [cx] */
0x33, 0xC0, /* xor ax, ax */
0xE9 /* jmp XXXX */
};
/* Check this function to see if it is a library function. Return true if
@ -318,7 +318,7 @@ bool PatternLocator::LibCheck(Function & pProc)
i = NIL;
if ((numFunc == 0) or (i=searchPList(ht[h].htSym)) != NIL)
{
pProc.flg |= PROC_ISLIB; /* It's a lib function */
pProc.flg |= PROC_ISLIB; /* It's a lib function */
pProc.callingConv(CConv::C);
if (i != NIL)
{
@ -369,7 +369,7 @@ bool PatternLocator::LibCheck(Function & pProc)
{
/* Have a symbol for it, but does not appear in a header file.
Treat it as if it is not a library function */
pProc.flg |= PROC_RUNTIME; /* => is a runtime routine */
pProc.flg |= PROC_RUNTIME; /* => is a runtime routine */
}
}
if (locatePattern(prog.image(), pProc.procEntry,
@ -378,8 +378,8 @@ bool PatternLocator::LibCheck(Function & pProc)
{
/* Found _chkstk */
pProc.name = "chkstk";
pProc.flg |= PROC_ISLIB; /* We'll say its a lib function */
pProc.args.numArgs = 0; /* With no args */
pProc.flg |= PROC_ISLIB; /* We'll say its a lib function */
pProc.args.numArgs = 0; /* With no args */
}
return (bool)((pProc.flg & PROC_ISLIB) != 0);
@ -490,7 +490,7 @@ bool checkStartup(STATE &state)
printf("Borland Turbo Pascal v4 detected\n");
proj.setLoaderMetadata({eBorland,ePascal,eUnknownMemoryModel,4});
prog.offMain = startOff; /* Code starts immediately */
prog.segMain = prog.initCS; /* At the 5 uint8_t jump */
prog.segMain = prog.initCS; /* At the 5 uint8_t jump */
return true; /* Already have vendor */
}
else if (locatePattern(prog.image(), init, init+26, pattBorl5Init, sizeof(pattBorl5Init), &i))

View File

@ -14,7 +14,7 @@
#include <sstream>
#include <QTextStream>
using namespace std;
#define intSize 40
#define intSize 40
static const char *int21h[] =
{
@ -131,21 +131,21 @@ static const char *int21h[] =
static const char *intOthers[] = {
"Exit", /* 0x20 */
"", /* other table */
"Terminate handler address", /* 0x22 */
"Ctrl-C handler address", /* 0x23 */
"Exit", /* 0x20 */
"", /* other table */
"Terminate handler address", /* 0x22 */
"Ctrl-C handler address", /* 0x23 */
"Critical-error handler address", /* 0x24 */
"Absolute disk read", /* 0x25 */
"Absolute disk write", /* 0x26 */
"Terminate and stay resident", /* 0x27 */
"Reserved", /* 0x28 */
"Reserved", /* 0x29 */
"Reserved", /* 0x2A */
"Reserved", /* 0x2B */
"Reserved", /* 0x2C */
"Reserved", /* 0x2D */
"Reserved" /* 0x2E */
"Absolute disk read", /* 0x25 */
"Absolute disk write", /* 0x26 */
"Terminate and stay resident", /* 0x27 */
"Reserved", /* 0x28 */
"Reserved", /* 0x29 */
"Reserved", /* 0x2A */
"Reserved", /* 0x2B */
"Reserved", /* 0x2C */
"Reserved", /* 0x2D */
"Reserved" /* 0x2E */
};
@ -200,8 +200,8 @@ void Function::writeProcComments()
void Function::writeProcComments(QTextStream &ostr)
{
int i;
ID *id; /* Pointer to register argument identifier */
STKSYM * psym; /* Pointer to register argument symbol */
ID *id; /* Pointer to register argument identifier */
STKSYM * psym; /* Pointer to register argument symbol */
/* About the parameters */
if (this->cbParam)
@ -218,7 +218,7 @@ void Function::writeProcComments(QTextStream &ostr)
id = &this->localId.id_arr[((RegisterNode *)psym->regs)->regiIdx];
ostr << Machine_X86::regName(id->id.regi);
}
else /* long register */
else /* long register */
{
id = &this->localId.id_arr[psym->regs->ident.idNode.longIdx];
ostr << Machine_X86::regName(id->longId().h()) << ":";

View File

@ -17,7 +17,7 @@
typedef std::list<int> nodeList; /* dfsLast index to the node */
#define ancestor(a,b) ((a->dfsLastNum < b->dfsLastNum) and (a->dfsFirstNum < b->dfsFirstNum))
#define ancestor(a,b) ((a->dfsLastNum < b->dfsLastNum) and (a->dfsFirstNum < b->dfsFirstNum))
/* there is a path on the DFST from a to b if the a was first visited in a
* dfs, and a was later visited than b when doing the last visit of each
* node. */
@ -69,7 +69,7 @@ void Function::findImmedDom ()
for (size_t currIdx = 0; currIdx < numBBs; currIdx++)
{
currNode = m_dfsLast[currIdx];
if (currNode->flg & INVALID_BB) /* Do not process invalid BBs */
if (currNode->flg & INVALID_BB) /* Do not process invalid BBs */
continue;
for (BB * inedge : currNode->inEdges)
{
@ -134,7 +134,7 @@ static void findNodesInLoop(BB * latchNode,BB * head,Function * pProc,queue &int
{
int i, headDfsNum, intNodeType;
nodeList loopNodes;
int immedDom, /* dfsLast index to immediate dominator */
int immedDom, /* dfsLast index to immediate dominator */
thenDfs, elseDfs; /* dsfLast index for THEN and ELSE nodes */
BB * pbb;
@ -144,7 +144,7 @@ static void findNodesInLoop(BB * latchNode,BB * head,Function * pProc,queue &int
insertList (loopNodes, headDfsNum);
for (i = headDfsNum + 1; i < latchNode->dfsLastNum; i++)
{
if (pProc->m_dfsLast[i]->flg & INVALID_BB) /* skip invalid BBs */
if (pProc->m_dfsLast[i]->flg & INVALID_BB) /* skip invalid BBs */
continue;
immedDom = pProc->m_dfsLast[i]->immedDom;
@ -192,7 +192,7 @@ static void findNodesInLoop(BB * latchNode,BB * head,Function * pProc,queue &int
head->loopFollow = latchNode->edges[THEN].BBptr->dfsLastNum;
latchNode->back().ll()->setFlags(JX_LOOP);
}
else /* latch = 1-way */
else /* latch = 1-way */
if (latchNode->nodeType == LOOP_NODE)
{
head->loopType = eNodeHeaderType::REPEAT_TYPE;
@ -228,7 +228,7 @@ static void findNodesInLoop(BB * latchNode,BB * head,Function * pProc,queue &int
pbb = pProc->m_dfsLast[pbb->immedDom];
}
if (pbb->dfsLastNum > head->dfsLastNum)
pProc->m_dfsLast[head->loopFollow]->loopHead = NO_NODE; /*****/
pProc->m_dfsLast[head->loopFollow]->loopHead = NO_NODE; /*****/
head->back().ll()->setFlags(JX_LOOP);
}
else
@ -266,12 +266,12 @@ static void findNodesInInt (queue &intNodes, int level, interval *Ii)
void Function::structLoops(derSeq *derivedG)
{
interval *Ii;
BB * intHead, /* interval header node */
* pred, /* predecessor node */
BB * intHead, /* interval header node */
* pred, /* predecessor node */
* latchNode;/* latching node (in case of loops) */
size_t level = 0; /* derived sequence level */
interval *initInt; /* initial interval */
queue intNodes; /* list of interval nodes */
size_t level = 0; /* derived sequence level */
interval *initInt; /* initial interval */
queue intNodes; /* list of interval nodes */
/* Structure loops */
/* for all derived sequences Gi */
@ -369,7 +369,7 @@ static void tagNodesInCase (BB * pBB, nodeList &l, int head, int tail)
* has a case node. */
void Function::structCases()
{
int exitNode = NO_NODE; /* case exit node */
int exitNode = NO_NODE; /* case exit node */
nodeList caseNodes; /* temporary: list of nodes in case */
/* Linear scan of the nodes in reverse dfsLast order, searching for
@ -428,21 +428,21 @@ static void flagNodes (nodeList &l, int f, Function * pProc)
/* Structures if statements */
void Function::structIfs ()
{
size_t followInEdges; /* Largest # in-edges so far */
int curr, /* Index for linear scan of nodes */
/*desc,*/ /* Index for descendant */
follow; /* Possible follow node */
nodeList domDesc, /* List of nodes dominated by curr */
unresolved /* List of unresolved if nodes */
size_t followInEdges; /* Largest # in-edges so far */
int curr, /* Index for linear scan of nodes */
/*desc,*/ /* Index for descendant */
follow; /* Possible follow node */
nodeList domDesc, /* List of nodes dominated by curr */
unresolved /* List of unresolved if nodes */
;
BB * currNode, /* Pointer to current node */
BB * currNode, /* Pointer to current node */
* pbb;
/* Linear scan of nodes in reverse dfsLast order */
for (curr = numBBs - 1; curr >= 0; curr--)
{
currNode = m_dfsLast[curr];
if (currNode->flg & INVALID_BB) /* Do not process invalid BBs */
if (currNode->flg & INVALID_BB) /* Do not process invalid BBs */
continue;
if ((currNode->nodeType == TWO_BRANCH) and (not currNode->back().ll()->testFlags(JX_LOOP)))

View File

@ -195,7 +195,7 @@ void Function::elimCondCodes ()
notSup = true;
std::cout << hex<<defIcode.loc_ip;
reportError (JX_NOT_DEF, defIcode.ll()->getOpcode());
flg |= PROC_ASM; /* generate asm */
flg |= PROC_ASM; /* generate asm */
}
if (not notSup)
{
@ -223,7 +223,7 @@ void Function::elimCondCodes ()
ICODE &a(*defAt);
ICODE &b(*useAt);
reportError (NOT_DEF_USE,a.ll()->label,a.ll()->getOpcode(),b.ll()->getOpcode());
flg |= PROC_ASM; /* generate asm */
flg |= PROC_ASM; /* generate asm */
}
break;
}
@ -268,7 +268,7 @@ void Function::genLiveKtes ()
def.reset();
pbb = m_dfsLast[i];
if (pbb->flg & INVALID_BB)
continue; // skip invalid BBs
continue; // skip invalid BBs
for(ICODE &insn : *pbb)
{
if ((insn.type == HIGH_LEVEL) and ( insn.valid() ))
@ -294,9 +294,9 @@ void Function::liveRegAnalysis (LivenessSet &in_liveOut)
Function * pcallee; /* invoked subroutine */
//ICODE *ticode /* icode that invokes a subroutine */
;
LivenessSet prevLiveOut, /* previous live out */
prevLiveIn; /* previous live in */
bool change; /* is there change in the live sets?*/
LivenessSet prevLiveOut, /* previous live out */
prevLiveIn; /* previous live in */
bool change; /* is there change in the live sets?*/
/* liveOut for this procedure */
liveOut = in_liveOut;
@ -447,7 +447,7 @@ bool BB::FindUseBeforeDef(eReg regi, int defRegIdx, iICODE start_at)
if (not ticode->du.def.testRegAndSubregs(regi) and liveOut.testRegAndSubregs(regi) )
start_at->du.lastDefRegi.addReg(regi);
}
else /* only 1 instruction in this basic block */
else /* only 1 instruction in this basic block */
{
/* Check if last definition of this register */
if ( liveOut.testRegAndSubregs(regi) )
@ -488,7 +488,7 @@ void BB::ProcessUseDefForFunc(eReg regi, int defRegIdx, ICODE &picode)
* thus remove it. Also check that this is not a return
* from a library function (routines such as printf
* return an integer, which is normally not taken into
* account by the programmer). */
* account by the programmer). */
void BB::RemoveUnusedDefs(eReg regi, int defRegIdx, iICODE picode)
{
if (picode->valid() and not picode->du1.used(defRegIdx) and
@ -496,7 +496,7 @@ void BB::RemoveUnusedDefs(eReg regi, int defRegIdx, iICODE picode)
(not ((picode->hl()->opcode == HLI_CALL) and
(picode->hl()->call.proc->flg & PROC_ISLIB))))
{
if (not (this->liveOut.testRegAndSubregs(regi))) /* not liveOut */
if (not (this->liveOut.testRegAndSubregs(regi))) /* not liveOut */
{
bool res = picode->removeDefRegi (regi, defRegIdx+1,&Parent->localId);
if (res == true)
@ -511,7 +511,7 @@ void BB::RemoveUnusedDefs(eReg regi, int defRegIdx, iICODE picode)
}
}
}
else /* liveOut */
else /* liveOut */
picode->du.lastDefRegi.addReg(regi);
}
}
@ -636,7 +636,7 @@ static void forwardSubsLong (int longIdx, Expr *_exp, iICODE picode, iICODE tico
}
/* Returns whether the elements of the expression rhs are all x-clear from
* instruction f up to instruction t. */
* instruction f up to instruction t. */
bool UnaryOperator::xClear(rICODE range_to_check, iICODE lastBBinst, const LOCAL_ID &locs)
{
if(nullptr==unaryExp)
@ -719,7 +719,7 @@ int C_CallingConvention::processCArg (Function * callee, Function * pProc, ICODE
}
}
}
else /* user function */
else /* user function */
{
if (callee->args.numArgs > 0)
{
@ -834,19 +834,19 @@ void Pascal_CallingConvention::processHLI(Function *func,Expr *_exp, iICODE pico
int k;
pp = picode->hl()->call.proc;
cb = pp->cbParam; /* fixed # arguments */
cb = pp->cbParam; /* fixed # arguments */
k = 0;
numArgs = 0;
while(k<cb)
{
_exp = g_exp_stk.pop();
if (pp->flg & PROC_ISLIB) /* library function */
if (pp->flg & PROC_ISLIB) /* library function */
{
if (pp->args.numArgs > 0)
_exp = func->adjustActArgType(_exp, pp->args[numArgs].type);
res = picode->newStkArg (_exp, (llIcode)picode->ll()->getOpcode(), func);
}
else /* user function */
else /* user function */
{
if (pp->args.numArgs >0)
{
@ -875,15 +875,15 @@ void BB::findBBExps(LOCAL_ID &locals,Function *fnc)
{
bool res;
ID *_retVal; // function return value
Expr *_exp; // expression pointer - for HLI_POP and HLI_CALL */
//Expr *lhs; // exp ptr for return value of a HLI_CALL */
iICODE ticode; // Target icode */
ID *_retVal; // function return value
Expr *_exp; // expression pointer - for HLI_POP and HLI_CALL
//Expr *lhs; // exp ptr for return value of a HLI_CALL
iICODE ticode; // Target icode
HLTYPE *ti_hl=nullptr;
uint8_t regi;
numHlIcodes = 0;
assert(&fnc->localId==&locals);
// register(s) to be forward substituted */
// register(s) to be forward substituted
auto valid_and_highlevel = instructions | filtered(ICODE::TypeAndValidFilter<HIGH_LEVEL>());
for (auto picode = valid_and_highlevel.begin(); picode != valid_and_highlevel.end(); picode++)
{
@ -959,7 +959,7 @@ void BB::findBBExps(LOCAL_ID &locals,Function *fnc)
newRegArg (pProc, picode, ticode);
picode->invalidate();
numHlIcodes--;
break; */
break; */
default:
fprintf(stderr,"unhandled BB::findBBExps target opcode %d\n",ticode->hl()->opcode);
@ -992,12 +992,12 @@ void BB::findBBExps(LOCAL_ID &locals,Function *fnc)
case HLI_JCOND:
_exp = _icHl.call.toAst();
res = Expr::insertSubTreeReg (ti_hl->exp.v, _exp, _retVal->id.regi, &locals);
if (res) /* was substituted */
if (res) /* was substituted */
{
picode->invalidate();
numHlIcodes--;
}
else /* cannot substitute function */
else /* cannot substitute function */
{
auto lhs = AstIdent::idID(_retVal,&locals,picode.base());
picode->setAsgn(lhs, _exp);
@ -1061,7 +1061,7 @@ void BB::findBBExps(LOCAL_ID &locals,Function *fnc)
numHlIcodes--;
}
break;
case HLI_CALL: /*** missing ***/
case HLI_CALL: /*** missing ***/
break;
default:
fprintf(stderr,"BB::findBBExps Unhandled target op %d\n",ticode->hl()->opcode);
@ -1097,12 +1097,12 @@ void BB::findBBExps(LOCAL_ID &locals,Function *fnc)
res = Expr::insertSubTreeLongReg (_exp,
ticode->hlU()->exp.v,
locals.newLongReg ( _retVal->type, _retVal->longId(), picode.base()));
if (res) /* was substituted */
if (res) /* was substituted */
{
picode->invalidate();
numHlIcodes--;
}
else /* cannot substitute function */
else /* cannot substitute function */
{
auto lhs = locals.createId(_retVal,picode.base());
picode->setAsgn(lhs, _exp);
@ -1221,7 +1221,7 @@ void Function::preprocessReturnDU(LivenessSet &_liveOut)
/*idx = */localId.newLongReg(TYPE_LONG_SIGN, LONGID_TYPE(rDX,rAX), Icode.begin());
localId.propLongId (rAX, rDX, "");
}
else if (isAx or isBx or isCx or isDx) /* uint16_t */
else if (isAx or isBx or isCx or isDx) /* uint16_t */
{
eReg selected_reg;
if (isAx)
@ -1287,10 +1287,10 @@ void Function::dataFlow(LivenessSet &_liveOut)
liveAnal = true;
elimCondCodes();
genLiveKtes();
liveRegAnalysis (_liveOut); /* calls dataFlow() recursively */
if (not (flg & PROC_ASM)) /* can generate C for pProc */
liveRegAnalysis (_liveOut); /* calls dataFlow() recursively */
if (not (flg & PROC_ASM)) /* can generate C for pProc */
{
genDU1 (); /* generate def/use level 1 chain */
findExps (); /* forward substitution algorithm */
genDU1 (); /* generate def/use level 1 chain */
findExps (); /* forward substitution algorithm */
}
}

View File

@ -20,10 +20,10 @@
#include "ui/DccMainWindow.h"
/* Global variables - extern to other modules */
extern QString asm1_name, asm2_name; /* Assembler output filenames */
extern SYMTAB symtab; /* Global symbol table */
extern STATS stats; /* cfg statistics */
extern OPTION option; /* Command line options */
extern QString asm1_name, asm2_name; /* Assembler output filenames */
extern SYMTAB symtab; /* Global symbol table */
extern STATS stats; /* cfg statistics */
extern OPTION option; /* Command line options */
static char *initargs(int argc, char *argv[]);
static void displayTotalStats(void);

View File

@ -817,7 +817,7 @@ static void strSrc(IStructuredTextTarget *out,LLInst *insn,bool skip_comma=false
out->prtt(", ");
if (insn->testFlags(I))
out->addTaggedString(XT_Number,strHex(insn->src().getImm2()));
else if (insn->testFlags(IM_SRC)) /* level 2 */
else if (insn->testFlags(IM_SRC)) /* level 2 */
out->addTaggedString(XT_Symbol,"dx:ax");
else
formatRM(out,insn->src());

View File

@ -187,7 +187,7 @@ void Function::findIdioms()
(pIcode++)->invalidate();
break;
case iENTER: /* ENTER is equivalent to init PUSH bp */
case iENTER: /* ENTER is equivalent to init PUSH bp */
if (pIcode == Icode.begin()) //ip == 0
{
flg |= (PROC_HLL | PROC_IS_HLL);

View File

@ -80,17 +80,17 @@ int Idiom6::action()
/*****************************************************************************
* idiom 18: Post-increment or post-decrement in a conditional jump
* Used
* 0 MOV reg, var (including register variables)
* 1 INC var or DEC var <------------------------- input point
* 2 CMP var, Y
* 3 JX label
* => HLI_JCOND (var++ X Y)
* Eg: MOV ax, si
* INC si
* CMP ax, 8
* JL labX
* => HLI_JCOND (si++ < 8)
* Found in Borland Turbo C. Intrinsic to C languages.
* 0 MOV reg, var (including register variables)
* 1 INC var or DEC var <------------------------- input point
* 2 CMP var, Y
* 3 JX label
* => HLI_JCOND (var++ X Y)
* Eg: MOV ax, si
* INC si
* CMP ax, 8
* JL labX
* => HLI_JCOND (si++ < 8)
* Found in Borland Turbo C. Intrinsic to C languages.
****************************************************************************/
bool Idiom18::match(iICODE picode)
{
@ -106,7 +106,7 @@ bool Idiom18::match(iICODE picode)
m_idiom_type=-1;
m_is_dec = m_icodes[1]->ll()->match(iDEC);
uint8_t regi; /* register of the MOV */
uint8_t regi; /* register of the MOV */
if(not m_icodes[0]->ll()->matchWithRegDst(iMOV) )
return false;
regi = m_icodes[0]->ll()->m_dst.regi;
@ -115,12 +115,12 @@ bool Idiom18::match(iICODE picode)
return false;
// Simple matching finished, select apropriate matcher based on dst type
/* Get variable */
if (m_icodes[1]->ll()->m_dst.regi == 0) /* global variable */
if (m_icodes[1]->ll()->m_dst.regi == 0) /* global variable */
{
/* not supported yet */
m_idiom_type = 0;
}
else if ( m_icodes[1]->ll()->m_dst.isReg() ) /* register */
else if ( m_icodes[1]->ll()->m_dst.isReg() ) /* register */
{
m_idiom_type = 1;
// if ((m_icodes[1]->ll()->dst.regi == rSI) and (m_func->flg & SI_REGVAR))
@ -128,9 +128,9 @@ bool Idiom18::match(iICODE picode)
// else if ((m_icodes[1]->ll()->dst.regi == rDI) and (m_func->flg & DI_REGVAR))
// m_idiom_type = 1;
}
else if (m_icodes[1]->ll()->m_dst.off) /* local variable */
else if (m_icodes[1]->ll()->m_dst.off) /* local variable */
m_idiom_type = 2;
else /* indexed */
else /* indexed */
{
m_idiom_type=3;
/* not supported yet */
@ -187,13 +187,13 @@ int Idiom18::action() // action length
/*****************************************************************************
* idiom 19: pre-increment or pre-decrement in conditional jump, comparing against 0.
* [INC | DEC] var (including register vars)
* JX lab JX lab
* => HLI_JCOND (++var X 0) or HLI_JCOND (--var X 0)
* Eg: INC [bp+4]
* [INC | DEC] var (including register vars)
* JX lab JX lab
* => HLI_JCOND (++var X 0) or HLI_JCOND (--var X 0)
* Eg: INC [bp+4]
* JG lab2
* => HLI_JCOND (++[bp+4] > 0)
* Found in Borland Turbo C. Intrinsic to C language.
* => HLI_JCOND (++[bp+4] > 0)
* Found in Borland Turbo C. Intrinsic to C language.
****************************************************************************/
bool Idiom19::match(iICODE picode)
{
@ -206,7 +206,7 @@ bool Idiom19::match(iICODE picode)
m_is_dec = m_icodes[0]->ll()->match(iDEC);
if ( not m_icodes[1]->ll()->conditionalJump() )
return false;
if (m_icodes[0]->ll()->m_dst.regi == 0) /* global variable */
if (m_icodes[0]->ll()->m_dst.regi == 0) /* global variable */
/* not supported yet */ ;
else if ( m_icodes[0]->ll()->m_dst.isReg() ) /* register */
{
@ -214,11 +214,11 @@ bool Idiom19::match(iICODE picode)
// ((picode->ll()->dst.regi == rDI) and (pproc->flg & DI_REGVAR)))
return true;
}
else if (m_icodes[0]->ll()->m_dst.off) /* stack variable */
else if (m_icodes[0]->ll()->m_dst.off) /* stack variable */
{
return true;
}
else /* indexed */
else /* indexed */
{
fprintf(stderr,"idiom19 : Untested type [indexed]\n");
return true;
@ -241,23 +241,23 @@ int Idiom19::action()
/*****************************************************************************
* idiom20: Pre increment/decrement in conditional expression (compares
* against a register, variable or constant different than 0).
* INC var or DEC var (including register vars)
* MOV reg, var MOV reg, var
* CMP reg, Y CMP reg, Y
* JX lab JX lab
* => HLI_JCOND (++var X Y) or HLI_JCOND (--var X Y)
* Eg: INC si (si is a register variable)
* MOV ax, si
* CMP ax, 2
* JL lab4
* => HLI_JCOND (++si < 2)
* Found in Turbo C. Intrinsic to C language.
* against a register, variable or constant different than 0).
* INC var or DEC var (including register vars)
* MOV reg, var MOV reg, var
* CMP reg, Y CMP reg, Y
* JX lab JX lab
* => HLI_JCOND (++var X Y) or HLI_JCOND (--var X Y)
* Eg: INC si (si is a register variable)
* MOV ax, si
* CMP ax, 2
* JL lab4
* => HLI_JCOND (++si < 2)
* Found in Turbo C. Intrinsic to C language.
****************************************************************************/
bool Idiom20::match(iICODE picode)
{
uint8_t type = 0; /* type of variable: 1 = reg-var, 2 = local */
uint8_t regi; /* register of the MOV */
uint8_t type = 0; /* type of variable: 1 = reg-var, 2 = local */
uint8_t regi; /* register of the MOV */
if(std::distance(picode,m_end)<4)
return false;
for(int i=0; i<4; ++i)
@ -270,11 +270,11 @@ bool Idiom20::match(iICODE picode)
const LLOperand &ll_dest(m_icodes[0]->ll()->m_dst);
/* Get variable */
if (ll_dest.regi == 0) /* global variable */
if (ll_dest.regi == 0) /* global variable */
{
/* not supported yet */ ;
}
else if ( ll_dest.isReg() ) /* register */
else if ( ll_dest.isReg() ) /* register */
{
type = 1;
// if ((ll_dest.regi == rSI) and (m_func->flg & SI_REGVAR))
@ -282,9 +282,9 @@ bool Idiom20::match(iICODE picode)
// else if ((ll_dest.regi == rDI) and (m_func->flg & DI_REGVAR))
// type = 1;
}
else if (ll_dest.off) /* local variable */
else if (ll_dest.off) /* local variable */
type = 2;
else /* indexed */
else /* indexed */
{
printf("idiom20 : Untested type [indexed]\n");
type = 3;

View File

@ -11,9 +11,9 @@ using namespace std;
* Eg: CALL proc_X
* ADD SP, 6
* => pProc->cbParam = immed
* Special case: when the call is at the end of the procedure,
* sometimes the stack gets restored by a MOV sp, bp.
* Need to flag the procedure in these cases.
* Special case: when the call is at the end of the procedure,
* sometimes the stack gets restored by a MOV sp, bp.
* Need to flag the procedure in these cases.
* Used by compilers to restore the stack when invoking a procedure using
* the C calling convention.
****************************************************************************/

View File

@ -95,15 +95,15 @@ int Idiom2::action()
* RET(F) immed
* ==> pProc->cbParam = immed
* sets CALL_PASCAL flag
* - Second version: check for optional pop of stack vars
* - Second version: check for optional pop of stack vars
* [POP DI]
* [POP SI]
* POP BP
* RET(F) [immed]
* - Third version: pop stack vars
* [POP DI]
* [POP SI]
* RET(F) [immed]
* - Third version: pop stack vars
* [POP DI]
* [POP SI]
* RET(F) [immed]
****************************************************************************/
bool Idiom4::match(iICODE pIcode)
{

View File

@ -12,14 +12,14 @@ using namespace std;
* Eg: MOV ax, di
* XOR dx, dx
* => MOV dx:ax, di
* Note: only the following combinations are allowed:
* dx:ax
* cx:bx
* this is to remove the possibility of making errors in situations
* like this:
* MOV dx, offH
* MOV ax, offL
* XOR cx, cx
* Note: only the following combinations are allowed:
* dx:ax
* cx:bx
* this is to remove the possibility of making errors in situations
* like this:
* MOV dx, offH
* MOV ax, offL
* XOR cx, cx
* Found in Borland Turbo C, used for division of unsigned integer
* operands.
****************************************************************************/

View File

@ -67,15 +67,15 @@ int Idiom11::action()
/*****************************************************************************
* idiom 16: Bitwise negation
* NEG reg
* SBB reg, reg
* INC reg
* => ASGN reg, !reg
* Eg: NEG ax
* SBB ax, ax
* INC ax
* => ax = !ax
* Found in Borland Turbo C when negating bitwise.
* NEG reg
* SBB reg, reg
* INC reg
* => ASGN reg, !reg
* Eg: NEG ax
* SBB ax, ax
* INC ax
* => ax = !ax
* Found in Borland Turbo C when negating bitwise.
****************************************************************************/
bool Idiom16::match (iICODE picode)
{

View File

@ -7,16 +7,16 @@ using namespace std;
/*****************************************************************************
* idiom21 - Assign long kte with high part zero
* XOR regH, regH
* MOV regL, kte
* => regH:regL = kte
* Eg: XOR dx, dx
* MOV ax, 3
* => dx:ax = 3
* Note: only the following valid combinations are available:
* dx:ax
* cx:bx
* Found in Borland Turbo C code.
* XOR regH, regH
* MOV regL, kte
* => regH:regL = kte
* Eg: XOR dx, dx
* MOV ax, 3
* => dx:ax = 3
* Note: only the following valid combinations are available:
* dx:ax
* cx:bx
* Found in Borland Turbo C code.
****************************************************************************/
bool Idiom21::match (iICODE picode)
{
@ -48,7 +48,7 @@ int Idiom21::action()
lhs = AstIdent::Long (&m_func->localId, DST, m_icodes[0],HIGH_FIRST, m_icodes[0], eDEF, *m_icodes[1]->ll());
rhs = new Constant(m_icodes[1]->ll()->src().getImm2(), 4);
m_icodes[0]->setAsgn(lhs, rhs);
m_icodes[0]->du.use.reset(); /* clear register used in iXOR */
m_icodes[0]->du.use.reset(); /* clear register used in iXOR */
m_icodes[1]->invalidate();
return 2;
}
@ -103,11 +103,11 @@ int Idiom7::action()
* Eg: OR ax, ax
* JNE labX
* => CMP reg 0
* JNE labX
* This instruction is NOT converted into the equivalent high-level
* instruction "HLI_JCOND (reg != 0) labX" because we do not know yet if
* it forms part of a long register conditional test. It is therefore
* modified to simplify the analysis.
* JNE labX
* This instruction is NOT converted into the equivalent high-level
* instruction "HLI_JCOND (reg != 0) labX" because we do not know yet if
* it forms part of a long register conditional test. It is therefore
* modified to simplify the analysis.
* Found in Borland Turbo C.
****************************************************************************/
bool Idiom10::match(iICODE pIcode)

View File

@ -449,14 +449,15 @@ eReg otherLongRegi (eReg regi, int idx, LOCAL_ID *locTbl)
else if (id->longId().l() == regi)
return (id->longId().h());
}
return rUNDEF; // Cristina: please check this!
return rUNDEF; // Cristina: please check this!
}
/* Checks if the registers regL and regH have been used independently in
/**
* Checks if the registers regL and regH have been used independently in
* the local identifier table. If so, macros for these registers are
* placed in the local identifier table, as these registers belong to a
* long register identifier. */
* long register identifier. */
void LOCAL_ID::propLongId (uint8_t regL, uint8_t regH, const QString &name)
{
for (ID &rid : id_arr)

View File

@ -80,13 +80,13 @@ static struct {
{ modrm, none2, NSP , iADC }, /* 11 */
{ modrm, none2, TO_REG | B , iADC }, /* 12 */
{ modrm, none2, TO_REG | NSP , iADC }, /* 13 */
{ data1, axImp, B , iADC }, /* 14 */
{ data2, axImp, 0 , iADC }, /* 15 */
{ segop, none2, NOT_HLL | NO_SRC , iPUSH }, /* 16 */
{ segop, none2, NOT_HLL | NO_SRC , iPOP }, /* 17 */
{ modrm, none2, B , iSBB }, /* 18 */
{ modrm, none2, NSP , iSBB }, /* 19 */
{ modrm, none2, TO_REG | B , iSBB }, /* 1A */
{ data1, axImp, B , iADC }, /* 14 */
{ data2, axImp, 0 , iADC }, /* 15 */
{ segop, none2, NOT_HLL | NO_SRC , iPUSH }, /* 16 */
{ segop, none2, NOT_HLL | NO_SRC , iPOP }, /* 17 */
{ modrm, none2, B , iSBB }, /* 18 */
{ modrm, none2, NSP , iSBB }, /* 19 */
{ modrm, none2, TO_REG | B , iSBB }, /* 1A */
{ modrm, none2, TO_REG | NSP , iSBB }, /* 1B */
{ data1, axImp, B , iSBB }, /* 1C */
{ data2, axImp, 0 , iSBB }, /* 1D */
@ -127,200 +127,200 @@ static struct {
{ regop, none2, 0 , iINC }, /* 40 */
{ regop, none2, 0 , iINC }, /* 41 */
{ regop, none2, 0 , iINC }, /* 42 */
{ regop, none2, 0 , iINC }, /* 43 */
{ regop, none2, NOT_HLL , iINC }, /* 44 */
{ regop, none2, 0 , iINC }, /* 45 */
{ regop, none2, 0 , iINC }, /* 46 */
{ regop, none2, 0 , iINC }, /* 47 */
{ regop, none2, 0 , iDEC }, /* 48 */
{ regop, none2, 0 , iDEC }, /* 49 */
{ regop, none2, 0 , iDEC }, /* 4A */
{ regop, none2, 0 , iDEC }, /* 4B */
{ regop, none2, NOT_HLL , iDEC }, /* 4C */
{ regop, none2, 0 , iDEC }, /* 4D */
{ regop, none2, 0 , iDEC }, /* 4E */
{ regop, none2, 0 , iDEC }, /* 4F */
{ regop, none2, NO_SRC , iPUSH }, /* 50 */
{ regop, none2, NO_SRC , iPUSH }, /* 51 */
{ regop, none2, NO_SRC , iPUSH }, /* 52 */
{ regop, none2, NO_SRC , iPUSH }, /* 53 */
{ regop, none2, NOT_HLL | NO_SRC , iPUSH }, /* 54 */
{ regop, none2, NO_SRC , iPUSH }, /* 55 */
{ regop, none2, NO_SRC , iPUSH }, /* 56 */
{ regop, none2, NO_SRC , iPUSH }, /* 57 */
{ regop, none2, NO_SRC , iPOP }, /* 58 */
{ regop, none2, NO_SRC , iPOP }, /* 59 */
{ regop, none2, NO_SRC , iPOP }, /* 5A */
{ regop, none2, NO_SRC , iPOP }, /* 5B */
{ regop, none2, NOT_HLL | NO_SRC , iPOP }, /* 5C */
{ regop, none2, NO_SRC , iPOP }, /* 5D */
{ regop, none2, NO_SRC , iPOP }, /* 5E */
{ regop, none2, NO_SRC , iPOP }, /* 5F */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHA}, /* 60 */
{ none1, none2, NOT_HLL | NO_OPS , iPOPA }, /* 61 */
{ memOnly, modrm, TO_REG | NSP , iBOUND}, /* 62 */
{ none1, none2, OP386 , iZERO }, /* 63 */
{ none1, none2, OP386 , iZERO }, /* 64 */
{ none1, none2, OP386 , iZERO }, /* 65 */
{ none1, none2, OP386 , iZERO }, /* 66 */
{ none1, none2, OP386 , iZERO }, /* 67 */
{ data2, none2, NO_SRC , iPUSH }, /* 68 */
{ modrm, data2, TO_REG | NSP , iIMUL }, /* 69 */
{ data1, none2, S_EXT | NO_SRC , iPUSH }, /* 6A */
{ modrm, data1, TO_REG | NSP | S_EXT , iIMUL }, /* 6B */
{ strop, memImp, NOT_HLL | B|IM_OPS , iINS }, /* 6C */
{ strop, memImp, NOT_HLL | IM_OPS , iINS }, /* 6D */
{ strop, memImp, NOT_HLL | B|IM_OPS , iOUTS }, /* 6E */
{ strop, memImp, NOT_HLL | IM_OPS , iOUTS }, /* 6F */
{ dispS, none2, NOT_HLL , iJO }, /* 70 */
{ dispS, none2, NOT_HLL , iJNO }, /* 71 */
{ dispS, none2, 0 , iJB }, /* 72 */
{ dispS, none2, 0 , iJAE }, /* 73 */
{ dispS, none2, 0 , iJE }, /* 74 */
{ dispS, none2, 0 , iJNE }, /* 75 */
{ dispS, none2, 0 , iJBE }, /* 76 */
{ dispS, none2, 0 , iJA }, /* 77 */
{ dispS, none2, 0 , iJS }, /* 78 */
{ dispS, none2, 0 , iJNS }, /* 79 */
{ dispS, none2, NOT_HLL , iJP }, /* 7A */
{ dispS, none2, NOT_HLL , iJNP }, /* 7B */
{ dispS, none2, 0 , iJL }, /* 7C */
{ dispS, none2, 0 , iJGE }, /* 7D */
{ dispS, none2, 0 , iJLE }, /* 7E */
{ dispS, none2, 0 , iJG }, /* 7F */
{ immed, data1, B , iZERO }, /* 80 */
{ immed, data2, NSP , iZERO }, /* 81 */
{ immed, data1, B , iZERO }, /* 82 */ /* ?? */
{ immed, data1, NSP | S_EXT , iZERO }, /* 83 */
{ modrm, none2, TO_REG | B , iTEST }, /* 84 */
{ modrm, none2, TO_REG | NSP , iTEST }, /* 85 */
{ modrm, none2, TO_REG | B , iXCHG }, /* 86 */
{ modrm, none2, TO_REG | NSP , iXCHG }, /* 87 */
{ modrm, none2, B , iMOV }, /* 88 */
{ modrm, none2, 0 , iMOV }, /* 89 */
{ modrm, none2, TO_REG | B , iMOV }, /* 8A */
{ modrm, none2, TO_REG , iMOV }, /* 8B */
{ segrm, none2, NSP , iMOV }, /* 8C */
{ memOnly, modrm, TO_REG | NSP , iLEA }, /* 8D */
{ segrm, none2, TO_REG | NSP , iMOV }, /* 8E */
{ memReg0, none2, NO_SRC , iPOP }, /* 8F */
{ none1, none2, NO_OPS , iNOP }, /* 90 */
{ regop, axImp, 0 , iXCHG }, /* 91 */
{ regop, axImp, 0 , iXCHG }, /* 92 */
{ regop, axImp, 0 , iXCHG }, /* 93 */
{ regop, axImp, NOT_HLL , iXCHG }, /* 94 */
{ regop, axImp, 0 , iXCHG }, /* 95 */
{ regop, axImp, 0 , iXCHG }, /* 96 */
{ regop, axImp, 0 , iXCHG }, /* 97 */
{ alImp, axImp, SRC_B | S_EXT , iSIGNEX}, /* 98 */
{axSrcIm, axImp, IM_DST | S_EXT , iSIGNEX}, /* 99 */
{ dispF, none2, TO_REG , iCALLF }, /* 9A */ // TO_REG set to use SRC when processing setAddress
{ none1, none2, FLOAT_OP| NO_OPS , iWAIT }, /* 9B */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHF}, /* 9C */
{ none1, none2, NOT_HLL | NO_OPS , iPOPF }, /* 9D */
{ none1, none2, NOT_HLL | NO_OPS , iSAHF }, /* 9E */
{ none1, none2, NOT_HLL | NO_OPS , iLAHF }, /* 9F */
{ dispM, axImp, B , iMOV }, /* A0 */
{ dispM, axImp, 0 , iMOV }, /* A1 */
{ dispM, axImp, TO_REG | B , iMOV }, /* A2 */
{ dispM, axImp, TO_REG , iMOV }, /* A3 */
{ strop, memImp, B | IM_OPS , iMOVS }, /* A4 */
{ strop, memImp, IM_OPS , iMOVS }, /* A5 */
{ strop, memImp, B | IM_OPS , iCMPS }, /* A6 */
{ strop, memImp, IM_OPS , iCMPS }, /* A7 */
{ data1, axImp, B , iTEST }, /* A8 */
{ data2, axImp, 0 , iTEST }, /* A9 */
{ strop, memImp, B | IM_OPS , iSTOS }, /* AA */
{ strop, memImp, IM_OPS , iSTOS }, /* AB */
{ strop, memImp, B | IM_OPS , iLODS }, /* AC */
{ strop, memImp, IM_OPS , iLODS }, /* AD */
{ strop, memImp, B | IM_OPS , iSCAS }, /* AE */
{ strop, memImp, IM_OPS , iSCAS }, /* AF */
{ regop, data1, B , iMOV }, /* B0 */
{ regop, data1, B , iMOV }, /* B1 */
{ regop, data1, B , iMOV }, /* B2 */
{ regop, data1, B , iMOV }, /* B3 */
{ regop, data1, B , iMOV }, /* B4 */
{ regop, data1, B , iMOV }, /* B5 */
{ regop, data1, B , iMOV }, /* B6 */
{ regop, data1, B , iMOV }, /* B7 */
{ regop, data2, 0 , iMOV }, /* B8 */
{ regop, data2, 0 , iMOV }, /* B9 */
{ regop, data2, 0 , iMOV }, /* BA */
{ regop, data2, 0 , iMOV }, /* BB */
{ regop, data2, NOT_HLL , iMOV }, /* BC */
{ regop, data2, 0 , iMOV }, /* BD */
{ regop, data2, 0 , iMOV }, /* BE */
{ regop, data2, 0 , iMOV }, /* BF */
{ shift, data1, B , iZERO }, /* C0 */
{ shift, data1, NSP | SRC_B , iZERO }, /* C1 */
{ data2, none2, 0 , iRET }, /* C2 */
{ none1, none2, NO_OPS , iRET }, /* C3 */
{ memOnly, modrm, TO_REG | NSP , iLES }, /* C4 */
{ memOnly, modrm, TO_REG | NSP , iLDS }, /* C5 */
{ memReg0, data1, B , iMOV }, /* C6 */
{ memReg0, data2, 0 , iMOV }, /* C7 */
{ data2, data1, 0 , iENTER}, /* C8 */
{ none1, none2, NO_OPS , iLEAVE}, /* C9 */
{ data2, none2, 0 , iRETF }, /* CA */
{ none1, none2, NO_OPS , iRETF }, /* CB */
{ const3, none2, NOT_HLL , iINT }, /* CC */
{ data1,checkInt, NOT_HLL , iINT }, /* CD */
{ none1, none2, NOT_HLL | NO_OPS , iINTO }, /* CE */
{ none1, none2, NOT_HLL | NO_OPS , iIRET }, /* Cf */
{ shift, const1, B , iZERO }, /* D0 */
{ shift, const1, SRC_B , iZERO }, /* D1 */
{ shift, none1, B , iZERO }, /* D2 */
{ shift, none1, SRC_B , iZERO }, /* D3 */
{ data1, axImp, NOT_HLL , iAAM }, /* D4 */
{ data1, axImp, NOT_HLL , iAAD }, /* D5 */
{ none1, none2, 0 , iZERO }, /* D6 */
{ memImp, axImp, NOT_HLL | B| IM_OPS , iXLAT }, /* D7 */
{ escop, none2, FLOAT_OP , iESC }, /* D8 */
{ escop, none2, FLOAT_OP , iESC }, /* D9 */
{ escop, none2, FLOAT_OP , iESC }, /* DA */
{ escop, none2, FLOAT_OP , iESC }, /* DB */
{ escop, none2, FLOAT_OP , iESC }, /* DC */
{ escop, none2, FLOAT_OP , iESC }, /* DD */
{ escop, none2, FLOAT_OP , iESC }, /* DE */
{ escop, none2, FLOAT_OP , iESC }, /* Df */
{ dispS, none2, 0 , iLOOPNE}, /* E0 */
{ dispS, none2, 0 , iLOOPE}, /* E1 */
{ dispS, none2, 0 , iLOOP }, /* E2 */
{ dispS, none2, 0 , iJCXZ }, /* E3 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iIN }, /* E4 */
{ data1, axImp, NOT_HLL | NO_SRC , iIN }, /* E5 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iOUT }, /* E6 */
{ data1, axImp, NOT_HLL | NO_SRC , iOUT }, /* E7 */
{ dispN, none2, 0 , iCALL }, /* E8 */
{ dispN, none2, 0 , iJMP }, /* E9 */
{ dispF, none2, 0 , iJMPF }, /* EA */
{ dispS, none2, 0 , iJMP }, /* EB */
{ none1, axImp, NOT_HLL | B|NO_SRC , iIN }, /* EC */
{ none1, axImp, NOT_HLL | NO_SRC , iIN }, /* ED */
{ none1, axImp, NOT_HLL | B|NO_SRC , iOUT }, /* EE */
{ none1, axImp, NOT_HLL | NO_SRC , iOUT }, /* EF */
{ none1, none2, NOT_HLL | NO_OPS , iLOCK }, /* F0 */
{ none1, none2, 0 , iZERO }, /* F1 */
{ prefix, none2, 0 , iREPNE}, /* F2 */
{ prefix, none2, 0 , iREPE }, /* F3 */
{ none1, none2, NOT_HLL | NO_OPS , iHLT }, /* F4 */
{ none1, none2, NO_OPS , iCMC }, /* F5 */
{ arith, none1, B , iZERO }, /* F6 */
{ arith, none1, NSP , iZERO }, /* F7 */
{ none1, none2, NO_OPS , iCLC }, /* F8 */
{ none1, none2, NO_OPS , iSTC }, /* F9 */
{ none1, none2, NOT_HLL | NO_OPS , iCLI }, /* FA */
{ none1, none2, NOT_HLL | NO_OPS , iSTI }, /* FB */
{ none1, none2, NO_OPS , iCLD }, /* FC */
{ none1, none2, NO_OPS , iSTD }, /* FD */
{ trans, none1, B , iZERO }, /* FE */
{ trans, none1, NSP , iZERO } /* FF */
{ regop, none2, 0 , iINC }, /* 43 */
{ regop, none2, NOT_HLL , iINC }, /* 44 */
{ regop, none2, 0 , iINC }, /* 45 */
{ regop, none2, 0 , iINC }, /* 46 */
{ regop, none2, 0 , iINC }, /* 47 */
{ regop, none2, 0 , iDEC }, /* 48 */
{ regop, none2, 0 , iDEC }, /* 49 */
{ regop, none2, 0 , iDEC }, /* 4A */
{ regop, none2, 0 , iDEC }, /* 4B */
{ regop, none2, NOT_HLL , iDEC }, /* 4C */
{ regop, none2, 0 , iDEC }, /* 4D */
{ regop, none2, 0 , iDEC }, /* 4E */
{ regop, none2, 0 , iDEC }, /* 4F */
{ regop, none2, NO_SRC , iPUSH }, /* 50 */
{ regop, none2, NO_SRC , iPUSH }, /* 51 */
{ regop, none2, NO_SRC , iPUSH }, /* 52 */
{ regop, none2, NO_SRC , iPUSH }, /* 53 */
{ regop, none2, NOT_HLL | NO_SRC , iPUSH }, /* 54 */
{ regop, none2, NO_SRC , iPUSH }, /* 55 */
{ regop, none2, NO_SRC , iPUSH }, /* 56 */
{ regop, none2, NO_SRC , iPUSH }, /* 57 */
{ regop, none2, NO_SRC , iPOP }, /* 58 */
{ regop, none2, NO_SRC , iPOP }, /* 59 */
{ regop, none2, NO_SRC , iPOP }, /* 5A */
{ regop, none2, NO_SRC , iPOP }, /* 5B */
{ regop, none2, NOT_HLL | NO_SRC , iPOP }, /* 5C */
{ regop, none2, NO_SRC , iPOP }, /* 5D */
{ regop, none2, NO_SRC , iPOP }, /* 5E */
{ regop, none2, NO_SRC , iPOP }, /* 5F */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHA}, /* 60 */
{ none1, none2, NOT_HLL | NO_OPS , iPOPA }, /* 61 */
{ memOnly, modrm, TO_REG | NSP , iBOUND}, /* 62 */
{ none1, none2, OP386 , iZERO }, /* 63 */
{ none1, none2, OP386 , iZERO }, /* 64 */
{ none1, none2, OP386 , iZERO }, /* 65 */
{ none1, none2, OP386 , iZERO }, /* 66 */
{ none1, none2, OP386 , iZERO }, /* 67 */
{ data2, none2, NO_SRC , iPUSH }, /* 68 */
{ modrm, data2, TO_REG | NSP , iIMUL }, /* 69 */
{ data1, none2, S_EXT | NO_SRC , iPUSH }, /* 6A */
{ modrm, data1, TO_REG | NSP | S_EXT , iIMUL }, /* 6B */
{ strop, memImp, NOT_HLL | B|IM_OPS , iINS }, /* 6C */
{ strop, memImp, NOT_HLL | IM_OPS , iINS }, /* 6D */
{ strop, memImp, NOT_HLL | B|IM_OPS , iOUTS }, /* 6E */
{ strop, memImp, NOT_HLL | IM_OPS , iOUTS }, /* 6F */
{ dispS, none2, NOT_HLL , iJO }, /* 70 */
{ dispS, none2, NOT_HLL , iJNO }, /* 71 */
{ dispS, none2, 0 , iJB }, /* 72 */
{ dispS, none2, 0 , iJAE }, /* 73 */
{ dispS, none2, 0 , iJE }, /* 74 */
{ dispS, none2, 0 , iJNE }, /* 75 */
{ dispS, none2, 0 , iJBE }, /* 76 */
{ dispS, none2, 0 , iJA }, /* 77 */
{ dispS, none2, 0 , iJS }, /* 78 */
{ dispS, none2, 0 , iJNS }, /* 79 */
{ dispS, none2, NOT_HLL , iJP }, /* 7A */
{ dispS, none2, NOT_HLL , iJNP }, /* 7B */
{ dispS, none2, 0 , iJL }, /* 7C */
{ dispS, none2, 0 , iJGE }, /* 7D */
{ dispS, none2, 0 , iJLE }, /* 7E */
{ dispS, none2, 0 , iJG }, /* 7F */
{ immed, data1, B , iZERO }, /* 80 */
{ immed, data2, NSP , iZERO }, /* 81 */
{ immed, data1, B , iZERO }, /* 82 */ /* ?? */
{ immed, data1, NSP | S_EXT , iZERO }, /* 83 */
{ modrm, none2, TO_REG | B , iTEST }, /* 84 */
{ modrm, none2, TO_REG | NSP , iTEST }, /* 85 */
{ modrm, none2, TO_REG | B , iXCHG }, /* 86 */
{ modrm, none2, TO_REG | NSP , iXCHG }, /* 87 */
{ modrm, none2, B , iMOV }, /* 88 */
{ modrm, none2, 0 , iMOV }, /* 89 */
{ modrm, none2, TO_REG | B , iMOV }, /* 8A */
{ modrm, none2, TO_REG , iMOV }, /* 8B */
{ segrm, none2, NSP , iMOV }, /* 8C */
{ memOnly, modrm, TO_REG | NSP , iLEA }, /* 8D */
{ segrm, none2, TO_REG | NSP , iMOV }, /* 8E */
{ memReg0, none2, NO_SRC , iPOP }, /* 8F */
{ none1, none2, NO_OPS , iNOP }, /* 90 */
{ regop, axImp, 0 , iXCHG }, /* 91 */
{ regop, axImp, 0 , iXCHG }, /* 92 */
{ regop, axImp, 0 , iXCHG }, /* 93 */
{ regop, axImp, NOT_HLL , iXCHG }, /* 94 */
{ regop, axImp, 0 , iXCHG }, /* 95 */
{ regop, axImp, 0 , iXCHG }, /* 96 */
{ regop, axImp, 0 , iXCHG }, /* 97 */
{ alImp, axImp, SRC_B | S_EXT , iSIGNEX}, /* 98 */
{axSrcIm, axImp, IM_DST | S_EXT , iSIGNEX}, /* 99 */
{ dispF, none2, TO_REG , iCALLF }, /* 9A */ // TO_REG set to use SRC when processing setAddress
{ none1, none2, FLOAT_OP| NO_OPS , iWAIT }, /* 9B */
{ none1, none2, NOT_HLL | NO_OPS , iPUSHF}, /* 9C */
{ none1, none2, NOT_HLL | NO_OPS , iPOPF }, /* 9D */
{ none1, none2, NOT_HLL | NO_OPS , iSAHF }, /* 9E */
{ none1, none2, NOT_HLL | NO_OPS , iLAHF }, /* 9F */
{ dispM, axImp, B , iMOV }, /* A0 */
{ dispM, axImp, 0 , iMOV }, /* A1 */
{ dispM, axImp, TO_REG | B , iMOV }, /* A2 */
{ dispM, axImp, TO_REG , iMOV }, /* A3 */
{ strop, memImp, B | IM_OPS , iMOVS }, /* A4 */
{ strop, memImp, IM_OPS , iMOVS }, /* A5 */
{ strop, memImp, B | IM_OPS , iCMPS }, /* A6 */
{ strop, memImp, IM_OPS , iCMPS }, /* A7 */
{ data1, axImp, B , iTEST }, /* A8 */
{ data2, axImp, 0 , iTEST }, /* A9 */
{ strop, memImp, B | IM_OPS , iSTOS }, /* AA */
{ strop, memImp, IM_OPS , iSTOS }, /* AB */
{ strop, memImp, B | IM_OPS , iLODS }, /* AC */
{ strop, memImp, IM_OPS , iLODS }, /* AD */
{ strop, memImp, B | IM_OPS , iSCAS }, /* AE */
{ strop, memImp, IM_OPS , iSCAS }, /* AF */
{ regop, data1, B , iMOV }, /* B0 */
{ regop, data1, B , iMOV }, /* B1 */
{ regop, data1, B , iMOV }, /* B2 */
{ regop, data1, B , iMOV }, /* B3 */
{ regop, data1, B , iMOV }, /* B4 */
{ regop, data1, B , iMOV }, /* B5 */
{ regop, data1, B , iMOV }, /* B6 */
{ regop, data1, B , iMOV }, /* B7 */
{ regop, data2, 0 , iMOV }, /* B8 */
{ regop, data2, 0 , iMOV }, /* B9 */
{ regop, data2, 0 , iMOV }, /* BA */
{ regop, data2, 0 , iMOV }, /* BB */
{ regop, data2, NOT_HLL , iMOV }, /* BC */
{ regop, data2, 0 , iMOV }, /* BD */
{ regop, data2, 0 , iMOV }, /* BE */
{ regop, data2, 0 , iMOV }, /* BF */
{ shift, data1, B , iZERO }, /* C0 */
{ shift, data1, NSP | SRC_B , iZERO }, /* C1 */
{ data2, none2, 0 , iRET }, /* C2 */
{ none1, none2, NO_OPS , iRET }, /* C3 */
{ memOnly, modrm, TO_REG | NSP , iLES }, /* C4 */
{ memOnly, modrm, TO_REG | NSP , iLDS }, /* C5 */
{ memReg0, data1, B , iMOV }, /* C6 */
{ memReg0, data2, 0 , iMOV }, /* C7 */
{ data2, data1, 0 , iENTER}, /* C8 */
{ none1, none2, NO_OPS , iLEAVE}, /* C9 */
{ data2, none2, 0 , iRETF }, /* CA */
{ none1, none2, NO_OPS , iRETF }, /* CB */
{ const3, none2, NOT_HLL , iINT }, /* CC */
{ data1,checkInt, NOT_HLL , iINT }, /* CD */
{ none1, none2, NOT_HLL | NO_OPS , iINTO }, /* CE */
{ none1, none2, NOT_HLL | NO_OPS , iIRET }, /* Cf */
{ shift, const1, B , iZERO }, /* D0 */
{ shift, const1, SRC_B , iZERO }, /* D1 */
{ shift, none1, B , iZERO }, /* D2 */
{ shift, none1, SRC_B , iZERO }, /* D3 */
{ data1, axImp, NOT_HLL , iAAM }, /* D4 */
{ data1, axImp, NOT_HLL , iAAD }, /* D5 */
{ none1, none2, 0 , iZERO }, /* D6 */
{ memImp, axImp, NOT_HLL | B| IM_OPS , iXLAT }, /* D7 */
{ escop, none2, FLOAT_OP , iESC }, /* D8 */
{ escop, none2, FLOAT_OP , iESC }, /* D9 */
{ escop, none2, FLOAT_OP , iESC }, /* DA */
{ escop, none2, FLOAT_OP , iESC }, /* DB */
{ escop, none2, FLOAT_OP , iESC }, /* DC */
{ escop, none2, FLOAT_OP , iESC }, /* DD */
{ escop, none2, FLOAT_OP , iESC }, /* DE */
{ escop, none2, FLOAT_OP , iESC }, /* Df */
{ dispS, none2, 0 , iLOOPNE}, /* E0 */
{ dispS, none2, 0 , iLOOPE}, /* E1 */
{ dispS, none2, 0 , iLOOP }, /* E2 */
{ dispS, none2, 0 , iJCXZ }, /* E3 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iIN }, /* E4 */
{ data1, axImp, NOT_HLL | NO_SRC , iIN }, /* E5 */
{ data1, axImp, NOT_HLL | B|NO_SRC , iOUT }, /* E6 */
{ data1, axImp, NOT_HLL | NO_SRC , iOUT }, /* E7 */
{ dispN, none2, 0 , iCALL }, /* E8 */
{ dispN, none2, 0 , iJMP }, /* E9 */
{ dispF, none2, 0 , iJMPF }, /* EA */
{ dispS, none2, 0 , iJMP }, /* EB */
{ none1, axImp, NOT_HLL | B|NO_SRC , iIN }, /* EC */
{ none1, axImp, NOT_HLL | NO_SRC , iIN }, /* ED */
{ none1, axImp, NOT_HLL | B|NO_SRC , iOUT }, /* EE */
{ none1, axImp, NOT_HLL | NO_SRC , iOUT }, /* EF */
{ none1, none2, NOT_HLL | NO_OPS , iLOCK }, /* F0 */
{ none1, none2, 0 , iZERO }, /* F1 */
{ prefix, none2, 0 , iREPNE}, /* F2 */
{ prefix, none2, 0 , iREPE }, /* F3 */
{ none1, none2, NOT_HLL | NO_OPS , iHLT }, /* F4 */
{ none1, none2, NO_OPS , iCMC }, /* F5 */
{ arith, none1, B , iZERO }, /* F6 */
{ arith, none1, NSP , iZERO }, /* F7 */
{ none1, none2, NO_OPS , iCLC }, /* F8 */
{ none1, none2, NO_OPS , iSTC }, /* F9 */
{ none1, none2, NOT_HLL | NO_OPS , iCLI }, /* FA */
{ none1, none2, NOT_HLL | NO_OPS , iSTI }, /* FB */
{ none1, none2, NO_OPS , iCLD }, /* FC */
{ none1, none2, NO_OPS , iSTD }, /* FD */
{ trans, none1, B , iZERO }, /* FE */
{ trans, none1, NSP , iZERO } /* FF */
} ;
static uint16_t SegPrefix, RepPrefix;
static const uint8_t *pInst; /* Ptr. to current uint8_t of instruction */
static ICODE * pIcode; /* Ptr to Icode record filled in by scan() */
static const uint8_t *pInst; /* Ptr. to current uint8_t of instruction */
static ICODE * pIcode; /* Ptr to Icode record filled in by scan() */
static void decodeBranchTgt(x86_insn_t &insn)
@ -338,7 +338,7 @@ static void decodeBranchTgt(x86_insn_t &insn)
pIcode->ll()->replaceSrc((uint32_t)addr);
pIcode->ll()->setFlags(I);
// PROG &prog(Project::get()->prog);
// long off = (short)getWord(); /* Signed displacement */
// long off = (short)getWord(); /* Signed displacement */
// assert(addr==(uint32_t)(off + (unsigned)(pInst - prog.image())));
}
@ -538,7 +538,7 @@ eErrorId scan(uint32_t ip, ICODE &p)
int op;
p = ICODE();
p.type = LOW_LEVEL;
p.ll()->label = ip; /* ip is absolute offset into image*/
p.ll()->label = ip; /* ip is absolute offset into image*/
if (ip >= (uint32_t)prog.cbImage)
{
return (IP_OUT_OF_RANGE);
@ -557,13 +557,13 @@ eErrorId scan(uint32_t ip, ICODE &p)
do
{
op = *pInst++; /* First state - trivial */
op = *pInst++; /* First state - trivial */
/* Convert to Icode.opcode */
p.ll()->set(stateTable[op].opcode,stateTable[op].flg & ICODEMASK);
(*stateTable[op].state1)(op); /* Second state */
(*stateTable[op].state2)(op); /* Third state */
(*stateTable[op].state1)(op); /* Second state */
(*stateTable[op].state2)(op); /* Third state */
} while (stateTable[op].state1 == prefix); /* Loop if prefix */
} while (stateTable[op].state1 == prefix); /* Loop if prefix */
if(p.insn.group == x86_insn_t::insn_controlflow)
{
if(p.insn.x86_get_branch_target())
@ -591,10 +591,9 @@ eErrorId scan(uint32_t ip, ICODE &p)
static bool relocItem(const uint8_t *p)
{
PROG &prog(Project::get()->prog);
int i;
uint32_t off = p - prog.image();
uint32_t off = p - prog.image();
for (i = 0; i < prog.cReloc; i++)
for (int i = 0; i < prog.cReloc; i++)
if (prog.relocTable[i] == off)
return true;
return false;
@ -621,11 +620,11 @@ static int signex(uint8_t b)
return ((b & 0x80)? (int)(0xFFFFFF00 | s): (int)s);
}
/****************************************************************************
* setAddress - Updates the source or destination field for the current
* icode, based on fdst and the TO_REG flag.
* Note: fdst == true is for the r/m part of the field (dest, unless TO_REG)
* fdst == false is for reg part of the field
/**
* \brief Updates the source or destination field for the current
* icode, based on fdst and the TO_REG flag.
* \note fdst == true is for the r/m part of the field (dest, unless TO_REG)
* fdst == false is for reg part of the field
***************************************************************************/
static void setAddress(int i, bool fdst, uint16_t seg, int16_t reg, uint16_t off)
{
@ -635,19 +634,19 @@ static void setAddress(int i, bool fdst, uint16_t seg, int16_t reg, uint16_t off
/* Set segment. A later procedure (lookupAddr in proclist.c) will
* provide the value of this segment in the field segValue.
*/
if (seg) /* segment override */
if (seg) /* segment override */
{
pm->seg = pm->segOver = (eReg)seg;
}
else
{ /* no override, check indexed register */
{ /* no override, check indexed register */
if ((reg >= INDEX_BX_SI) and (reg == INDEX_BP_SI or reg == INDEX_BP_DI or reg == INDEX_BP))
{
pm->seg = rSS; /* indexed on bp */
pm->seg = rSS; /* indexed on bp */
}
else
{
pm->seg = rDS; /* any other indexed reg */
pm->seg = rDS; /* any other indexed reg */
}
}
@ -658,7 +657,7 @@ static void setAddress(int i, bool fdst, uint16_t seg, int16_t reg, uint16_t off
pm->regi = Machine_X86::subRegL(pm->regi);
}
if (seg) /* So we can catch invalid use of segment overrides */
if (seg) /* So we can catch invalid use of segment overrides */
{
SegPrefix = 0;
}
@ -674,7 +673,7 @@ static void rm(int i)
uint8_t rm = *pInst++ & 7;
switch (mod) {
case 0: /* No disp unless rm == 6 */
case 0: /* No disp unless rm == 6 */
if (rm == 6) {
setAddress(i, true, SegPrefix, 0, getWord());
pIcode->ll()->setFlags(WORD_OFF);
@ -683,16 +682,16 @@ static void rm(int i)
setAddress(i, true, SegPrefix, rm + INDEX_BX_SI, 0);
break;
case 1: /* 1 uint8_t disp */
case 1: /* 1 uint8_t disp */
setAddress(i, true, SegPrefix, rm+INDEX_BX_SI, (uint16_t)signex(*pInst++));
break;
case 2: /* 2 uint8_t disp */
case 2: /* 2 uint8_t disp */
setAddress(i, true, SegPrefix, rm + INDEX_BX_SI, getWord());
pIcode->ll()->setFlags(WORD_OFF);
break;
case 3: /* reg */
case 3: /* reg */
setAddress(i, true, 0, rm + rAX, 0);
break;
}
@ -718,7 +717,7 @@ static void modrm(int i)
****************************************************************************/
static void segrm(int i)
{
int reg = REG(*pInst) + rES;
int reg = REG(*pInst) + rES;
if (reg > rDS or (reg == rCS and (stateTable[i].flg & TO_REG)))
pIcode->ll()->setOpcode((llIcode)0); // setCBW because it has that index
@ -814,7 +813,7 @@ static void immed(int i)
rm(i);
if (pIcode->ll()->getOpcode() == iADD or pIcode->ll()->getOpcode() == iSUB)
pIcode->ll()->clrFlags(NOT_HLL); /* Allow ADD/SUB SP, immed */
pIcode->ll()->clrFlags(NOT_HLL); /* Allow ADD/SUB SP, immed */
}
@ -826,7 +825,7 @@ static void shift(int i)
static llIcode shiftTable[8] =
{
(llIcode)iROL, (llIcode)iROR, (llIcode)iRCL, (llIcode)iRCR,
(llIcode)iSHL, (llIcode)iSHR, (llIcode)0, (llIcode)iSAR};
(llIcode)iSHL, (llIcode)iSHR, (llIcode)0, (llIcode)iSAR};
pIcode->ll()->setOpcode(shiftTable[REG(*pInst)]);
rm(i);
@ -884,7 +883,7 @@ static void arith(int i)
else if (not (opcode == iNOT or opcode == iNEG))
{
pIcode->ll()->replaceSrc( pIcode->ll()->m_dst );
setAddress(i, true, 0, rAX, 0); /* dst = AX */
setAddress(i, true, 0, rAX, 0); /* dst = AX */
}
else if (opcode == iNEG or opcode == iNOT)
pIcode->ll()->setFlags(NO_SRC);
@ -919,7 +918,7 @@ static void data2(int )
* but this field is being used as the number of bytes to allocate
* on the stack. The procedure level is stored in the immediate
* field. There is no source operand; therefore, the flag flg is
* set to NO_OPS. */
* set to NO_OPS. */
if (pIcode->ll()->getOpcode() == iENTER)
{
pIcode->ll()->m_dst.off = getWord();
@ -946,7 +945,7 @@ static void dispN(int )
{
//PROG &prog(Project::get()->prog);
/*long off = (short)*/getWord(); /* Signed displacement */
/*long off = (short)*/getWord(); /* Signed displacement */
/* Note: the result of the subtraction could be between 32k and 64k, and
still be positive; it is an offset from prog.Image. So this must be
@ -960,7 +959,7 @@ static void dispN(int )
***************************************************************************/
static void dispS(int )
{
/*long off =*/ signex(*pInst++); /* Signed displacement */
/*long off =*/ signex(*pInst++); /* Signed displacement */
// decodeBranchTgt();
}
@ -994,7 +993,7 @@ static void prefix(int )
inline void BumpOpcode(LLInst &ll)
{
llIcode ic((llIcode)ll.getOpcode());
ic = (llIcode)(((int)ic)+1); // Bump this icode via the int type
ic = (llIcode)(((int)ic)+1); // Bump this icode via the int type
ll.setOpcode(ic);
}

View File

@ -23,8 +23,6 @@ DccMainWindow::DccMainWindow(QWidget *parent) :
ui->statusbar->addPermanentWidget(new QLabel("Test"));
g_IDCC = IDcc::get();
g_IDCC->BaseInit();
g_IDCC->Init(this);
m_last_display = nullptr;
m_command_queue = new CommandQueueView(this);
@ -78,7 +76,6 @@ void DccMainWindow::onNewFunction(PtrFunction f) {
void DccMainWindow::onOptim()
{
Project::get()->processCommands();
g_IDCC->analysis_Once();
emit functionListChanged();
if(m_last_display==m_selected_func)
{
@ -87,8 +84,7 @@ void DccMainWindow::onOptim()
}
void DccMainWindow::onOptim10()
{
for(int i=0; i<10; i++)
g_IDCC->analysis_Once();
Project::get()->processCommands(10);
emit functionListChanged();
if(m_last_display==m_selected_func)
{

View File

@ -37,12 +37,12 @@ int LIB_PatternCollector::readSyms(FILE *fl)
{
int i;
int count = 0;
int firstSym = 0; /* First symbol this module */
int firstSym = 0; /* First symbol this module */
uint8_t b, c, type;
uint16_t w, len;
codeLNAMES = NONE; /* Invalidate indexes for code segment */
codeSEGDEF = NONE; /* Else won't be assigned */
codeLNAMES = NONE; /* Invalidate indexes for code segment */
codeSEGDEF = NONE; /* Else won't be assigned */
offset = 0; /* For diagnostics, really */
@ -61,7 +61,7 @@ int LIB_PatternCollector::readSyms(FILE *fl)
switch (type)
{
case 0x96: /* LNAMES */
case 0x96: /* LNAMES */
while (len > 1)
{
readString(fl);
@ -73,11 +73,11 @@ int LIB_PatternCollector::readSyms(FILE *fl)
}
len -= strlen((char *)buf)+1;
}
b = readByte(fl); /* Checksum */
b = readByte(fl); /* Checksum */
break;
case 0x98: /* Segment definition */
b = readByte(fl); /* Segment attributes */
case 0x98: /* Segment definition */
b = readByte(fl); /* Segment attributes */
if ((b & 0xE0) == 0)
{
/* Alignment field is zero. Frame and offset follow */
@ -85,25 +85,25 @@ int LIB_PatternCollector::readSyms(FILE *fl)
readByte(fl);
}
w = readWord(fl); /* Segment length */
w = readWord(fl); /* Segment length */
b = readByte(fl); /* Segment name index */
b = readByte(fl); /* Segment name index */
++segnum;
b = readByte(fl); /* Class name index */
b = readByte(fl); /* Class name index */
if ((b == codeLNAMES) and (codeSEGDEF == NONE))
{
/* This is the segment defining the code class */
codeSEGDEF = segnum;
}
b = readByte(fl); /* Overlay index */
b = readByte(fl); /* Checksum */
b = readByte(fl); /* Overlay index */
b = readByte(fl); /* Checksum */
break;
case 0x90: /* PUBDEF: public symbols */
b = readByte(fl); /* Base group */
c = readByte(fl); /* Base segment */
case 0x90: /* PUBDEF: public symbols */
b = readByte(fl); /* Base group */
c = readByte(fl); /* Base segment */
len -= 2;
if (c == 0)
{
@ -113,8 +113,8 @@ int LIB_PatternCollector::readSyms(FILE *fl)
while (len > 1)
{
readString(fl);
w = readWord(fl); /* Offset */
b = readByte(fl); /* Type index */
w = readWord(fl); /* Offset */
b = readByte(fl); /* Type index */
if (c == codeSEGDEF)
{
char *p;
@ -122,7 +122,7 @@ int LIB_PatternCollector::readSyms(FILE *fl)
p = (char *)buf;
if (buf[0] == '_') /* Leading underscore? */
{
p++; /* Yes, remove it*/
p++; /* Yes, remove it*/
}
i = std::min(size_t(SYMLEN-1), strlen(p));
memcpy(entry.name, p, i);
@ -134,21 +134,21 @@ int LIB_PatternCollector::readSyms(FILE *fl)
}
len -= strlen((char *)buf) + 1 + 2 + 1;
}
b = readByte(fl); /* Checksum */
b = readByte(fl); /* Checksum */
break;
case 0xA0: /* LEDATA */
case 0xA0: /* LEDATA */
{
b = readByte(fl); /* Segment index */
w = readWord(fl); /* Offset */
b = readByte(fl); /* Segment index */
w = readWord(fl); /* Offset */
len -= 3;
/*printf("LEDATA seg %d off %02X len %Xh, looking for %d\n", b, w, len-1, codeSEGDEF);//*/
if (b != codeSEGDEF)
{
readNN(len,fl); /* Skip the data */
break; /* Next record */
break; /* Next record */
}
@ -160,12 +160,12 @@ int LIB_PatternCollector::readSyms(FILE *fl)
offset += len-1;
maxLeData = std::max<uint16_t>(maxLeData, w+len-1);
readByte(fl); /* Checksum */
readByte(fl); /* Checksum */
break;
}
default:
readNN(len,fl); /* Just skip the lot */
readNN(len,fl); /* Just skip the lot */
if (type == 0x8A) /* Mod end */
{
@ -176,7 +176,7 @@ int LIB_PatternCollector::readSyms(FILE *fl)
uint16_t off = keys[i].offset;
if (off == (uint16_t)-1)
{
continue; /* Ignore if already done */
continue; /* Ignore if already done */
}
if (keys[i].offset > maxLeData)
{
@ -213,14 +213,14 @@ int LIB_PatternCollector::readSyms(FILE *fl)
while (readByte(fl) == 0);
readNN(-1,fl); /* Unget the last byte (= type) */
lnum = 0; /* Reset index into lnames */
segnum = 0; /* Reset index into snames */
readNN(-1,fl); /* Unget the last byte (= type) */
lnum = 0; /* Reset index into lnames */
segnum = 0; /* Reset index into snames */
firstSym = count; /* Remember index of first sym this mod */
codeLNAMES = NONE; /* Invalidate indexes for code segment */
codeSEGDEF = NONE;
memset(leData, 0, maxLeData); /* Clear out old junk */
maxLeData = 0; /* No data read this module */
maxLeData = 0; /* No data read this module */
}
else if (type == 0xF1)

View File

@ -6,15 +6,15 @@ struct LIB_PatternCollector : public PatternCollector
{
protected:
unsigned long offset;
uint8_t lnum = 0; /* Count of LNAMES so far */
uint8_t segnum = 0; /* Count of SEGDEFs so far */
uint8_t codeLNAMES; /* Index of the LNAMES for "CODE" class */
uint8_t codeSEGDEF; /* Index of the first SEGDEF that has class CODE */
#define NONE 0xFF /* Improbable segment index */
uint8_t lnum = 0; /* Count of LNAMES so far */
uint8_t segnum = 0; /* Count of SEGDEFs so far */
uint8_t codeLNAMES; /* Index of the LNAMES for "CODE" class */
uint8_t codeSEGDEF; /* Index of the first SEGDEF that has class CODE */
#define NONE 0xFF /* Improbable segment index */
uint8_t *leData; /* Pointer to 64K of alloc'd data. Some .lib files
have the symbols (PUBDEFs) *after* the data
(LEDATA), so you need to keep the data here */
uint16_t maxLeData; /* How much data we have in there */
uint16_t maxLeData; /* How much data we have in there */
/* read a length then string to buf[]; make it an asciiz string */
void readString( FILE *fl);

View File

@ -21,17 +21,17 @@ void TPL_PatternCollector::enterSym(FILE *f, const char *name, uint16_t pmapOffs
/* Enter a symbol with given name */
allocSym(count);
strcpy(keys[count].name, name);
pm = pmap + pmapOffset; /* Pointer to the 4 byte pmap structure */
pm = pmap + pmapOffset; /* Pointer to the 4 byte pmap structure */
fseek(f, unitBase+pm, SEEK_SET);/* Go there */
cm = readShort(f); /* CSeg map offset */
codeOffset = readShort(f); /* How far into the code segment is our rtn */
j = cm / 8; /* Index into the cmap array */
cm = readShort(f); /* CSeg map offset */
codeOffset = readShort(f); /* How far into the code segment is our rtn */
j = cm / 8; /* Index into the cmap array */
pcode = csegBase+csegoffs[j]+codeOffset;
fseek(f, unitBase+pcode, SEEK_SET); /* Go there */
grab(f,PATLEN); /* Grab the pattern to buf[] */
fixWildCards(buf); /* Fix the wild cards */
fseek(f, unitBase+pcode, SEEK_SET); /* Go there */
grab(f,PATLEN); /* Grab the pattern to buf[] */
fixWildCards(buf); /* Fix the wild cards */
memcpy(keys[count].pat, buf, PATLEN); /* Copy to the key array */
count++; /* Done one more */
count++; /* Done one more */
}
void TPL_PatternCollector::allocSym(int count)
@ -50,7 +50,7 @@ void TPL_PatternCollector::readCmapOffsets(FILE *f)
csegIdx = 0;
for (i=cmap; i < pmap; i+=8)
{
readShort(f); /* Always 0 */
readShort(f); /* Always 0 */
csize = readShort(f);
if (csize == 0xFFFF) continue; /* Ignore the first one... unit init */
csegoffs[csegIdx++] = cumsize;
@ -70,7 +70,7 @@ void TPL_PatternCollector::enterSystemUnit(FILE *f)
cmap = readShort(f);
pmap = readShort(f);
fseek(f, offStCseg, SEEK_SET);
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
printf("CMAP table at %04X\n", cmap);
printf("PMAP table at %04X\n", pmap);
printf("Code seg base %04X\n", csegBase);
@ -79,10 +79,10 @@ void TPL_PatternCollector::enterSystemUnit(FILE *f)
enterSym(f,"INITIALISE", 0x04);
enterSym(f,"UNKNOWN008", 0x08);
enterSym(f,"EXIT", 0x0C);
enterSym(f,"EXIT", 0x0C);
enterSym(f,"BlockMove", 0x10);
unknown(f,0x14, 0xC8);
enterSym(f,"PostIO", 0xC8);
enterSym(f,"PostIO", 0xC8);
enterSym(f,"UNKNOWN0CC", 0xCC);
enterSym(f,"STACKCHK", 0xD0);
enterSym(f,"UNKNOWN0D4", 0xD4);
@ -90,24 +90,24 @@ void TPL_PatternCollector::enterSystemUnit(FILE *f)
enterSym(f,"WriteInt", 0xDC);
enterSym(f,"UNKNOWN0E0", 0xE0);
enterSym(f,"UNKNOWN0E4", 0xE4);
enterSym(f,"CRLF", 0xE8);
enterSym(f,"CRLF", 0xE8);
enterSym(f,"UNKNOWN0EC", 0xEC);
enterSym(f,"UNKNOWN0F0", 0xF0);
enterSym(f,"UNKNOWN0F4", 0xF4);
enterSym(f,"ReadEOL", 0xF8);
enterSym(f,"Read", 0xFC);
enterSym(f,"Read", 0xFC);
enterSym(f,"UNKNOWN100", 0x100);
enterSym(f,"UNKNOWN104", 0x104);
enterSym(f,"PostWrite", 0x108);
enterSym(f,"UNKNOWN10C", 0x10C);
enterSym(f,"Randomize", 0x110);
unknown(f,0x114, 0x174);
enterSym(f,"Random", 0x174);
enterSym(f,"Random", 0x174);
unknown(f,0x178, 0x1B8);
enterSym(f,"FloatAdd", 0x1B8); /* A guess! */
enterSym(f,"FloatSub", 0x1BC); /* disicx - dxbxax -> dxbxax*/
enterSym(f,"FloatMult", 0x1C0); /* disicx * dxbxax -> dxbxax*/
enterSym(f,"FloatDivide", 0x1C4); /* disicx / dxbxax -> dxbxax*/
enterSym(f,"FloatAdd", 0x1B8); /* A guess! */
enterSym(f,"FloatSub", 0x1BC); /* disicx - dxbxax -> dxbxax*/
enterSym(f,"FloatMult", 0x1C0); /* disicx * dxbxax -> dxbxax*/
enterSym(f,"FloatDivide", 0x1C4); /* disicx / dxbxax -> dxbxax*/
enterSym(f,"UNKNOWN1C8", 0x1C8);
enterSym(f,"DoubleToFloat",0x1CC); /* dxax to dxbxax */
enterSym(f,"UNKNOWN1D0", 0x1D0);
@ -163,23 +163,23 @@ void TPL_PatternCollector::nextUnit(FILE *f)
void TPL_PatternCollector::setVersionSpecifics()
{
version = buf[3]; /* The x of TPUx */
version = buf[3]; /* The x of TPUx */
switch (version)
{
case '0': /* Version 4.0 */
case '0': /* Version 4.0 */
offStCseg = 0x14; /* Offset to the LL giving the Cseg start */
charProc = 'T'; /* Indicates a proc in the dictionary */
charFunc = 'U'; /* Indicates a function in the dictionary */
skipPmap = 6; /* Bytes to skip after Func to get pmap offset */
charProc = 'T'; /* Indicates a proc in the dictionary */
charFunc = 'U'; /* Indicates a function in the dictionary */
skipPmap = 6; /* Bytes to skip after Func to get pmap offset */
break;
case '5': /* Version 5.0 */
case '5': /* Version 5.0 */
offStCseg = 0x18; /* Offset to the LL giving the Cseg start */
charProc = 'T'; /* Indicates a proc in the dictionary */
charFunc = 'U'; /* Indicates a function in the dictionary */
skipPmap = 1; /* Bytes to skip after Func to get pmap offset */
charProc = 'T'; /* Indicates a proc in the dictionary */
charFunc = 'U'; /* Indicates a function in the dictionary */
skipPmap = 1; /* Bytes to skip after Func to get pmap offset */
break;
default:
@ -225,18 +225,18 @@ void TPL_PatternCollector::enterUnitProcs(FILE *f)
cmap = readShort(f);
pmap = readShort(f);
fseek(f, unitBase+offStCseg, SEEK_SET);
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
csegBase = roundUp(readShort(f)); /* Round up to next 16 bdry */
printf("CMAP table at %04X\n", cmap);
printf("PMAP table at %04X\n", pmap);
printf("Code seg base %04X\n", csegBase);
readCmapOffsets(f);
fseek(f, unitBase+pmap, SEEK_SET); /* Go to first pmap entry */
if (readShort(f) != 0xFFFF) /* FFFF means none */
fseek(f, unitBase+pmap, SEEK_SET); /* Go to first pmap entry */
if (readShort(f) != 0xFFFF) /* FFFF means none */
{
sprintf(name, "UNIT_INIT_%d", ++unitNum);
enterSym(f,name, 0); /* This is the unit init code */
enterSym(f,name, 0); /* This is the unit init code */
}
fseek(f, unitBase+0x0A, SEEK_SET);
@ -260,7 +260,7 @@ void TPL_PatternCollector::enterUnitProcs(FILE *f)
cat = readByte(f);
if ((cat == charProc) or (cat == charFunc))
{
grab(f,skipPmap); /* Skip to the pmap */
grab(f,skipPmap); /* Skip to the pmap */
pmapOff = readShort(f); /* pmap offset */
printf("pmap offset for %13s: %04X\n", name, pmapOff);
enterSym(f,name, pmapOff);

View File

@ -2,7 +2,7 @@
#include "LIB_PatternCollector.h"
#include "TPL_PatternCollector.h"
#include "perfhlib.h" /* Symbol table prototypes */
#include "perfhlib.h" /* Symbol table prototypes */
#include "msvc_fixes.h"
#include <QtCore/QCoreApplication>
@ -20,9 +20,9 @@
/* prototypes */
void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll); /* Save the info */
void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll); /* Save the info */
int numKeys; /* Number of useful codeview symbols */
int numKeys; /* Number of useful codeview symbols */
static void printUsage(bool longusage) {
@ -77,20 +77,20 @@ int main(int argc, char *argv[])
srand(s);
PerfectHash p_hash;
numKeys = collector->readSyms(srcfile); /* Read the keys (symbols) */
numKeys = collector->readSyms(srcfile); /* Read the keys (symbols) */
printf("Num keys: %d; vertices: %d\n", numKeys, (int)(numKeys*C));
/* Set the parameters for the hash table */
p_hash.setHashParams( numKeys, /* The number of symbols */
PATLEN, /* The length of the pattern to be hashed */
256, /* The character set of the pattern (0-FF) */
0, /* Minimum pattern character value */
numKeys*C); /* C is the sparseness of the graph. See Czech,
p_hash.setHashParams( numKeys, /* The number of symbols */
PATLEN, /* The length of the pattern to be hashed */
256, /* The character set of the pattern (0-FF) */
0, /* Minimum pattern character value */
numKeys*C); /* C is the sparseness of the graph. See Czech,
Havas and Majewski for details */
/* The following two functions are in perfhlib.c */
p_hash.map(collector); /* Perform the mapping. This will call getKey() repeatedly */
p_hash.assign(); /* Generate the function g */
p_hash.assign(); /* Generate the function g */
saveFile(f2,p_hash,collector); /* Save the resultant information */
@ -100,9 +100,9 @@ int main(int argc, char *argv[])
}
/* * * * * * * * * * * * *\
* *
* S a v e t h e s i g f i l e *
* *
* *
* S a v e t h e s i g f i l e *
* *
\* * * * * * * * * * * * */
@ -120,7 +120,7 @@ void writeFileShort(FILE *fl,uint16_t w)
uint8_t b;
b = (uint8_t)(w & 0xFF);
writeFile(fl,(char *)&b, 1); /* Write a short little endian */
writeFile(fl,(char *)&b, 1); /* Write a short little endian */
b = (uint8_t)(w>>8);
writeFile(fl,(char *)&b, 1);
}
@ -130,14 +130,14 @@ void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll)
int i, len;
const uint16_t *pTable;
writeFile(fl,"dccs", 4); /* Signature */
writeFileShort(fl,numKeys); /* Number of keys */
writeFile(fl,"dccs", 4); /* Signature */
writeFileShort(fl,numKeys); /* Number of keys */
writeFileShort(fl,(short)(numKeys * C)); /* Number of vertices */
writeFileShort(fl,PATLEN); /* Length of key part of entries */
writeFileShort(fl,SYMLEN); /* Length of symbol part of entries */
writeFileShort(fl,PATLEN); /* Length of key part of entries */
writeFileShort(fl,SYMLEN); /* Length of symbol part of entries */
/* Write out the tables T1 and T2, with their sig and byte lengths in front */
writeFile(fl,"T1", 2); /* "Signature" */
writeFile(fl,"T1", 2); /* "Signature" */
pTable = p_hash.readT1();
len = PATLEN * 256;
writeFileShort(fl,len * sizeof(uint16_t));
@ -154,7 +154,7 @@ void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll)
}
/* Write out g[] */
writeFile(fl,"gg", 2); /* "Signature" */
writeFile(fl,"gg", 2); /* "Signature" */
pTable = p_hash.readG();
len = (short)(numKeys * C);
writeFileShort(fl,len * sizeof(uint16_t));
@ -164,7 +164,7 @@ void saveFile(FILE *fl, const PerfectHash &p_hash, PatternCollector *coll)
}
/* Now the hash table itself */
writeFile(fl,"ht ", 2); /* "Signature" */
writeFile(fl,"ht ", 2); /* "Signature" */
writeFileShort(fl,numKeys * (SYMLEN + PATLEN + sizeof(uint16_t))); /* byte len */
for (i=0; i < numKeys; i++)
{