This commit is contained in:
Artur K
2012-02-23 22:14:56 +01:00
parent 2b2eaeabe5
commit a51c5af87f
15 changed files with 242 additions and 258 deletions

View File

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

View File

@@ -4,6 +4,8 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <vector> #include <vector>
#include <llvm/MC/MCInst.h>
#include <llvm/MC/MCAsmInfo.h>
#include "Enums.h" #include "Enums.h"
//enum condId; //enum condId;
struct LOCAL_ID; struct LOCAL_ID;
@@ -254,17 +256,6 @@ struct DU_ICODE
#define MAX_USES 5 #define MAX_USES 5
/* LOW_LEVEL icode operand record */
struct ICODEMEM
{
byte seg; /* CS, DS, ES, SS */
int16 segValue; /* Value of segment seg during analysis */
byte segOver; /* CS, DS, ES, SS if segment override */
byte regi; /* 0 < regs < INDEXBASE <= index modes */
int16 off; /* memory address offset */
} ;
struct COND_EXPR; struct COND_EXPR;
struct HLTYPE struct HLTYPE
{ {
@@ -281,22 +272,34 @@ struct HLTYPE
} call; } call;
} oper; /* operand */ } oper; /* operand */
} ; } ;
/* LOW_LEVEL icode operand record */
struct LLOpcode : public llvm::MCOperand
{
byte seg; /* CS, DS, ES, SS */
int16 segValue; /* Value of segment seg during analysis */
byte segOver; /* CS, DS, ES, SS if segment override */
byte regi; /* 0 < regs < INDEXBASE <= index modes */
int16 off; /* memory address offset */
dword opz; /* idx of immed src op */
//union {/* Source operand if (flg & I) */
//dword opz; /* idx of immed src op */
struct { /* Call & # actual arg bytes */
Function *proc; /* pointer to target proc (for CALL(F))*/
int cb; /* # actual arg bytes */
} proc;
//} immed;
dword op() const {return opz;}
void SetImmediateOp(dword dw) {opz=dw;}
struct LLTYPE };
struct LLInst : public llvm::MCInst
{ {
llIcode opcode; /* llIcode instruction */ llIcode opcode; /* llIcode instruction */
byte numBytes; /* Number of bytes this instr */ byte numBytes; /* Number of bytes this instr */
flags32 flg; /* icode flags */ flags32 flg; /* icode flags */
dword label; /* offset in image (20-bit adr) */ dword label; /* offset in image (20-bit adr) */
ICODEMEM dst; /* destination operand */ LLOpcode dst; /* destination operand */
ICODEMEM src; /* source operand */ LLOpcode src; /* source operand */
union { /* Source operand if (flg & I) */
dword op; /* idx of immed src op */
struct { /* Call & # actual arg bytes */
Function *proc; /* pointer to target proc (for CALL(F))*/
int cb; /* # actual arg bytes */
} proc;
} immed;
DU flagDU; /* def/use of flags */ DU flagDU; /* def/use of flags */
struct { /* Case table if op==JMP && !I */ struct { /* Case table if op==JMP && !I */
Int numEntries; /* # entries in case table */ Int numEntries; /* # entries in case table */
@@ -308,6 +311,7 @@ struct LLTYPE
{ {
return (opcode >= iJB) && (opcode < iJCXZ); return (opcode >= iJB) && (opcode < iJCXZ);
} }
bool anyFlagSet(uint32_t x) const { return (flg & x)!=0;}
}; };
/* Icode definition: LOW_LEVEL and HIGH_LEVEL */ /* Icode definition: LOW_LEVEL and HIGH_LEVEL */
@@ -326,7 +330,7 @@ struct ICODE
DU1 du1; /* du chain 1 */ DU1 du1; /* du chain 1 */
Int codeIdx; /* Index into cCode.code */ Int codeIdx; /* Index into cCode.code */
struct IC { /* Different types of icodes */ struct IC { /* Different types of icodes */
LLTYPE ll; LLInst ll;
HLTYPE hl; /* For HIGH_LEVEL icodes */ HLTYPE hl; /* For HIGH_LEVEL icodes */
}; };
IC ic;/* intermediate code */ IC ic;/* intermediate code */
@@ -337,6 +341,8 @@ struct ICODE
dword GetLlFlag() {return ic.ll.flg;} dword GetLlFlag() {return ic.ll.flg;}
bool isLlFlag(dword flg) {return (ic.ll.flg&flg)!=0;} bool isLlFlag(dword flg) {return (ic.ll.flg&flg)!=0;}
llIcode GetLlOpcode() const { return ic.ll.opcode; } llIcode GetLlOpcode() const { return ic.ll.opcode; }
dword GetLlLabel() const { return ic.ll.label;}
void SetImmediateOp(dword dw) {ic.ll.src.SetImmediateOp(dw);}
void writeIntComment(std::ostringstream &s); void writeIntComment(std::ostringstream &s);
void setRegDU(byte regi, operDu du_in); void setRegDU(byte regi, operDu du_in);
@@ -356,19 +362,13 @@ public:
}; };
// This is the icode array object. // This is the icode array object.
// The bulk of this could well be done with a class library
class CIcodeRec : public std::vector<ICODE> class CIcodeRec : public std::vector<ICODE>
{ {
public: public:
CIcodeRec(); // Constructor CIcodeRec(); // Constructor
~CIcodeRec(); // Destructor
ICODE * addIcode(ICODE *pIcode); ICODE * addIcode(ICODE *pIcode);
// ICODE * GetNextIcode(ICODE * pCurIcode);
void SetInBB(int start, int end, BB* pnewBB); void SetInBB(int start, int end, BB* pnewBB);
void SetImmediateOp(int ip, dword dw);
dword GetLlLabel(int ip);
llIcode GetLlOpcode(int ip);
bool labelSrch(dword target, dword &pIndex); bool labelSrch(dword target, dword &pIndex);
ICODE * GetIcode(int ip); ICODE * GetIcode(int ip);
}; };

View File

@@ -268,11 +268,11 @@ COND_EXPR *COND_EXPR::idLong(LOCAL_ID *localId, opLoc sd, iICODE pIcode, hlFirst
{ {
newExp->expr.ident.idType = CONSTANT; newExp->expr.ident.idType = CONSTANT;
if (f == HIGH_FIRST) if (f == HIGH_FIRST)
newExp->expr.ident.idNode.kte.kte = (pIcode->ic.ll.immed.op << 16) + newExp->expr.ident.idNode.kte.kte = (pIcode->ic.ll.src.op() << 16) +
(pIcode+off)->ic.ll.immed.op; (pIcode+off)->ic.ll.src.op();
else /* LOW_FIRST */ else /* LOW_FIRST */
newExp->expr.ident.idNode.kte.kte = newExp->expr.ident.idNode.kte.kte =
((pIcode+off)->ic.ll.immed.op << 16)+ pIcode->ic.ll.immed.op; ((pIcode+off)->ic.ll.src.op() << 16)+ pIcode->ic.ll.src.op();
newExp->expr.ident.idNode.kte.size = 4; newExp->expr.ident.idNode.kte.size = 4;
} }
/* Save it as a long expression (reg, stack or glob) */ /* Save it as a long expression (reg, stack or glob) */
@@ -350,10 +350,10 @@ COND_EXPR *COND_EXPR::id(const ICODE &pIcode, opLoc sd, Function * pProc, Int i,
Int idx; /* idx into pIcode->localId table */ Int idx; /* idx into pIcode->localId table */
const ICODEMEM * pm = (sd == SRC) ? &pIcode.ic.ll.src : &pIcode.ic.ll.dst; const LLOpcode &pm((sd == SRC) ? pIcode.ic.ll.src : pIcode.ic.ll.dst);
if (((sd == DST) && (pIcode.ic.ll.flg & IM_DST) == IM_DST) || if ( ((sd == DST) && pIcode.ic.ll.anyFlagSet(IM_DST)) or
((sd == SRC) && (pIcode.ic.ll.flg & IM_SRC)) || ((sd == SRC) && pIcode.ic.ll.anyFlagSet(IM_SRC)) or
(sd == LHS_OP)) /* for MUL lhs */ (sd == LHS_OP)) /* for MUL lhs */
{ /* implicit dx:ax */ { /* implicit dx:ax */
idx = pProc->localId.newLongReg (TYPE_LONG_SIGN, rDX, rAX, i); idx = pProc->localId.newLongReg (TYPE_LONG_SIGN, rDX, rAX, i);
@@ -362,52 +362,50 @@ COND_EXPR *COND_EXPR::id(const ICODE &pIcode, opLoc sd, Function * pProc, Int i,
duIcode.setRegDU (rAX, du); duIcode.setRegDU (rAX, du);
} }
else if ((sd == DST) && (pIcode.ic.ll.flg & IM_TMP_DST) == IM_TMP_DST) else if ((sd == DST) && pIcode.ic.ll.anyFlagSet(IM_TMP_DST))
{ /* implicit tmp */ { /* implicit tmp */
newExp = COND_EXPR::idReg (rTMP, 0, &pProc->localId); newExp = COND_EXPR::idReg (rTMP, 0, &pProc->localId);
duIcode.setRegDU(rTMP, (operDu)eUSE); duIcode.setRegDU(rTMP, (operDu)eUSE);
} }
else if ((sd == SRC) && ((pIcode.ic.ll.flg & I) == I)) /* constant */ else if ((sd == SRC) && pIcode.ic.ll.anyFlagSet(I)) /* constant */
newExp = COND_EXPR::idKte (pIcode.ic.ll.immed.op, 2); newExp = COND_EXPR::idKte (pIcode.ic.ll.src.op(), 2);
else if (pm.regi == 0) /* global variable */
else if (pm->regi == 0) /* global variable */ newExp = COND_EXPR::idGlob(pm.segValue, pm.off);
newExp = COND_EXPR::idGlob(pm->segValue, pm->off); else if (pm.regi < INDEXBASE) /* register */
else if (pm->regi < INDEXBASE) /* register */
{ {
newExp = COND_EXPR::idReg (pm->regi, (sd == SRC) ? pIcode.ic.ll.flg : newExp = COND_EXPR::idReg (pm.regi, (sd == SRC) ? pIcode.ic.ll.flg :
pIcode.ic.ll.flg & NO_SRC_B, &pProc->localId); pIcode.ic.ll.flg & NO_SRC_B, &pProc->localId);
duIcode.setRegDU( pm->regi, du); duIcode.setRegDU( pm.regi, du);
} }
else if (pm->off) /* offset */ else if (pm.off) /* offset */
{ {
if ((pm->seg == rSS) && (pm->regi == INDEXBASE + 6)) /* idx on bp */ if ((pm.seg == rSS) && (pm.regi == INDEXBASE + 6)) /* idx on bp */
{ {
if (pm->off >= 0) /* argument */ if (pm.off >= 0) /* argument */
newExp = COND_EXPR::idParam (pm->off, &pProc->args); newExp = COND_EXPR::idParam (pm.off, &pProc->args);
else /* local variable */ else /* local variable */
newExp = COND_EXPR::idLoc (pm->off, &pProc->localId); newExp = COND_EXPR::idLoc (pm.off, &pProc->localId);
} }
else if ((pm->seg == rDS) && (pm->regi == INDEXBASE + 7)) /* bx */ else if ((pm.seg == rDS) && (pm.regi == INDEXBASE + 7)) /* bx */
{ {
if (pm->off > 0) /* global variable */ if (pm.off > 0) /* global variable */
newExp = idCondExpIdxGlob (pm->segValue, pm->off, rBX,&pProc->localId); newExp = idCondExpIdxGlob (pm.segValue, pm.off, rBX,&pProc->localId);
else else
newExp = COND_EXPR::idOther (pm->seg, pm->regi, pm->off); newExp = COND_EXPR::idOther (pm.seg, pm.regi, pm.off);
duIcode.setRegDU( rBX, eUSE); duIcode.setRegDU( rBX, eUSE);
} }
else /* idx <> bp, bx */ else /* idx <> bp, bx */
newExp = COND_EXPR::idOther (pm->seg, pm->regi, pm->off); newExp = COND_EXPR::idOther (pm.seg, pm.regi, pm.off);
/**** check long ops, indexed global var *****/ /**** check long ops, indexed global var *****/
} }
else /* (pm->regi >= INDEXBASE && pm->off = 0) => indexed && no off */ else /* (pm->regi >= INDEXBASE && pm->off = 0) => indexed && no off */
{ {
if ((pm->seg == rDS) && (pm->regi > INDEXBASE + 3)) /* dereference */ if ((pm.seg == rDS) && (pm.regi > INDEXBASE + 3)) /* dereference */
{ {
switch (pm->regi) { switch (pm.regi) {
case INDEXBASE + 4: newExp = COND_EXPR::idReg(rSI, 0, &pProc->localId); case INDEXBASE + 4: newExp = COND_EXPR::idReg(rSI, 0, &pProc->localId);
duIcode.setRegDU( rSI, du); duIcode.setRegDU( rSI, du);
break; break;
@@ -426,7 +424,7 @@ COND_EXPR *COND_EXPR::id(const ICODE &pIcode, opLoc sd, Function * pProc, Int i,
newExp = COND_EXPR::unary (DEREFERENCE, newExp); newExp = COND_EXPR::unary (DEREFERENCE, newExp);
} }
else else
newExp = COND_EXPR::idOther (pm->seg, pm->regi, 0); newExp = COND_EXPR::idOther (pm.seg, pm.regi, 0);
} }
return (newExp); return (newExp);
@@ -436,19 +434,17 @@ COND_EXPR *COND_EXPR::id(const ICODE &pIcode, opLoc sd, Function * pProc, Int i,
/* Returns the identifier type */ /* Returns the identifier type */
condId ICODE::idType(opLoc sd) condId ICODE::idType(opLoc sd)
{ {
ICODEMEM *pm; LLOpcode &pm((sd == SRC) ? ic.ll.src : ic.ll.dst);
pm = (sd == SRC) ? &ic.ll.src : &ic.ll.dst;
if ((sd == SRC) && ((ic.ll.flg & I) == I)) if ((sd == SRC) && ((ic.ll.flg & I) == I))
return (CONSTANT); return (CONSTANT);
else if (pm->regi == 0) else if (pm.regi == 0)
return (GLOB_VAR); return (GLOB_VAR);
else if (pm->regi < INDEXBASE) else if (pm.regi < INDEXBASE)
return (REGISTER); return (REGISTER);
else if ((pm->seg == rSS) && (pm->regi == INDEXBASE)) else if ((pm.seg == rSS) && (pm.regi == INDEXBASE))
{ {
if (pm->off >= 0) if (pm.off >= 0)
return (PARAM); return (PARAM);
else else
return (LOCAL_VAR); return (LOCAL_VAR);

View File

@@ -150,15 +150,15 @@ static const char *intOthers[] = {
void ICODE::writeIntComment (std::ostringstream &s) void ICODE::writeIntComment (std::ostringstream &s)
{ {
s<<"\t/* "; s<<"\t/* ";
if (ic.ll.immed.op == 0x21) if (ic.ll.src.op() == 0x21)
{ {
s <<int21h[ic.ll.dst.off]; s <<int21h[ic.ll.dst.off];
} }
else if (ic.ll.immed.op > 0x1F && ic.ll.immed.op < 0x2F) else if (ic.ll.src.op() > 0x1F && ic.ll.src.op() < 0x2F)
{ {
s <<intOthers[ic.ll.immed.op - 0x20]; s <<intOthers[ic.ll.src.op() - 0x20];
} }
else if (ic.ll.immed.op == 0x2F) else if (ic.ll.src.op() == 0x2F)
{ {
switch (ic.ll.dst.off) switch (ic.ll.dst.off)
{ {

View File

@@ -88,9 +88,9 @@ static COND_EXPR *srcIdent (const ICODE &Icode, Function * pProc, Int i, ICODE &
if (Icode.ic.ll.flg & I) /* immediate operand */ if (Icode.ic.ll.flg & I) /* immediate operand */
{ {
if (Icode.ic.ll.flg & B) if (Icode.ic.ll.flg & B)
n = COND_EXPR::idKte (Icode.ic.ll.immed.op, 1); n = COND_EXPR::idKte (Icode.ic.ll.src.op(), 1);
else else
n = COND_EXPR::idKte (Icode.ic.ll.immed.op, 2); n = COND_EXPR::idKte (Icode.ic.ll.src.op(), 2);
} }
else else
n = COND_EXPR::id (Icode, SRC, pProc, i, duIcode, du); n = COND_EXPR::id (Icode, SRC, pProc, i, duIcode, du);

View File

@@ -6,13 +6,6 @@
#include "dcc.h" #include "dcc.h"
#include <string.h> #include <string.h>
#ifdef __UNIX__
//#include <unistd.h>
#else
#include <stdio.h>
#include <io.h> /* For unlink() */
#endif
/* Global variables - extern to other modules */ /* Global variables - extern to other modules */
char *progname; /* argv[0] - for error msgs */ char *progname; /* argv[0] - for error msgs */
@@ -28,15 +21,21 @@ CALL_GRAPH *callGraph; /* Call graph of the program */
static char *initargs(int argc, char *argv[]); static char *initargs(int argc, char *argv[]);
static void displayTotalStats(); static void displayTotalStats();
#include <llvm/Support/raw_os_ostream.h>
#include <llvm/Support/raw_ostream.h>
/**************************************************************************** /****************************************************************************
* main * main
***************************************************************************/ ***************************************************************************/
#include <iostream>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// llvm::MCOperand op=llvm::MCOperand::CreateImm(11);
// llvm::MCAsmInfo info;
// llvm::raw_os_ostream wrap(std::cerr);
// op.print(wrap,&info);
// wrap.flush();
/* Extract switches and filename */ /* Extract switches and filename */
strcpy(option.filename, initargs(argc, argv)); strcpy(option.filename, initargs(argc, argv));

View File

@@ -129,8 +129,8 @@ static const char *szPtr[2] = { "word ptr ", "byte ptr " };
static void dis1Line (Int i, Int pass); static void dis1Line (Int i, Int pass);
void dis1LineOp(Int i, boolT fWin, char attr, word *len, Function * pProc); void dis1LineOp(Int i, boolT fWin, char attr, word *len, Function * pProc);
static void formatRM(ostringstream &p, flags32 flg, ICODEMEM* pm); static void formatRM(ostringstream &p, flags32 flg, LLOpcode *pm);
static ostringstream &strDst(ostringstream &os, flags32 flg, ICODEMEM *pm); static ostringstream &strDst(ostringstream &os, flags32 flg, LLOpcode *pm);
static ostringstream &strSrc(ostringstream &os, ICODE *pc, bool skip_comma=false); static ostringstream &strSrc(ostringstream &os, ICODE *pc, bool skip_comma=false);
static char *strHex(dword d); static char *strHex(dword d);
static Int checkScanned(dword pcCur); static Int checkScanned(dword pcCur);
@@ -215,10 +215,12 @@ void disassem(Int pass, Function * ppProc)
JmpInst(pc[i].ic.ll.opcode)) JmpInst(pc[i].ic.ll.opcode))
{ {
/* Replace the immediate operand with an icode index */ /* Replace the immediate operand with an icode index */
if (pc.labelSrch(pc[i].ic.ll.immed.op,pc[i].ic.ll.immed.op)) dword labTgt;
if (pc.labelSrch(pc[i].ic.ll.src.op(),labTgt))
{ {
pc[i].ic.ll.src.SetImmediateOp(labTgt);
/* This icode is the target of a jump */ /* This icode is the target of a jump */
pc[pc[i].ic.ll.immed.op].ic.ll.flg |= TARGET; pc[labTgt].ic.ll.flg |= TARGET;
pc[i].ic.ll.flg |= JMP_ICODE; /* So its not done twice */ pc[i].ic.ll.flg |= JMP_ICODE; /* So its not done twice */
} }
else else
@@ -362,7 +364,7 @@ static void dis1Line(Int i, Int pass)
case iPUSH: case iPUSH:
if (pIcode->ic.ll.flg & I) if (pIcode->ic.ll.flg & I)
{ {
oper_stream<<strHex(pIcode->ic.ll.immed.op); oper_stream<<strHex(pIcode->ic.ll.src.op());
// strcpy(p + WID_PTR, strHex(pIcode->ic.ll.immed.op)); // strcpy(p + WID_PTR, strHex(pIcode->ic.ll.immed.op));
} }
else else
@@ -396,8 +398,8 @@ static void dis1Line(Int i, Int pass)
/* Check if there is a symbol here */ /* Check if there is a symbol here */
selectTable(Label); selectTable(Label);
if ((pIcode->ic.ll.immed.op < (dword)numIcode) && /* Ensure in range */ if ((pIcode->ic.ll.src.op() < (dword)numIcode) && /* Ensure in range */
readVal(oper_stream, pc[pIcode->ic.ll.immed.op].ic.ll.label, 0)) readVal(oper_stream, pc[pIcode->ic.ll.src.op()].ic.ll.label, 0))
{ {
break; /* Symbolic label. Done */ break; /* Symbolic label. Done */
} }
@@ -405,11 +407,11 @@ static void dis1Line(Int i, Int pass)
if (pIcode->ic.ll.flg & NO_LABEL) if (pIcode->ic.ll.flg & NO_LABEL)
{ {
//strcpy(p + WID_PTR, strHex(pIcode->ic.ll.immed.op)); //strcpy(p + WID_PTR, strHex(pIcode->ic.ll.immed.op));
oper_stream<<strHex(pIcode->ic.ll.immed.op); oper_stream<<strHex(pIcode->ic.ll.src.op());
} }
else if (pIcode->ic.ll.flg & I) else if (pIcode->ic.ll.flg & I)
{ {
j = pIcode->ic.ll.immed.op; j = pIcode->ic.ll.src.op();
if (! pl[j]) /* Forward jump */ if (! pl[j]) /* Forward jump */
{ {
pl[j] = ++lab; pl[j] = ++lab;
@@ -438,7 +440,7 @@ static void dis1Line(Int i, Int pass)
oper_stream<< "near"; oper_stream<< "near";
else else
oper_stream<< " far"; oper_stream<< " far";
oper_stream<<" ptr "<<(pIcode->ic.ll.immed.proc.proc)->name; oper_stream<<" ptr "<<(pIcode->ic.ll.src.proc.proc)->name;
} }
else if (pIcode->ic.ll.opcode == iCALLF) else if (pIcode->ic.ll.opcode == iCALLF)
{ {
@@ -451,13 +453,13 @@ static void dis1Line(Int i, Int pass)
case iENTER: case iENTER:
oper_stream<<strHex(pIcode->ic.ll.dst.off)<<", "; oper_stream<<strHex(pIcode->ic.ll.dst.off)<<", ";
oper_stream<<strHex(pIcode->ic.ll.immed.op); oper_stream<<strHex(pIcode->ic.ll.src.op());
break; break;
case iRET: case iRETF: case iINT: case iRET: case iRETF: case iINT:
if (pIcode->ic.ll.flg & I) if (pIcode->ic.ll.flg & I)
{ {
oper_stream<<strHex(pIcode->ic.ll.immed.op); oper_stream<<strHex(pIcode->ic.ll.src.op());
} }
break; break;
@@ -502,11 +504,11 @@ static void dis1Line(Int i, Int pass)
case iIN: case iIN:
oper_stream<<(pIcode->ic.ll.flg & B)?"al, ": "ax, "; oper_stream<<(pIcode->ic.ll.flg & B)?"al, ": "ax, ";
oper_stream<<(pIcode->ic.ll.flg & I)? strHex(pIcode->ic.ll.immed.op): "dx"; oper_stream<<(pIcode->ic.ll.flg & I)? strHex(pIcode->ic.ll.src.op()): "dx";
break; break;
case iOUT: case iOUT:
oper_stream<<(pIcode->ic.ll.flg & I)? strHex(pIcode->ic.ll.immed.op): "dx"; oper_stream<<(pIcode->ic.ll.flg & I)? strHex(pIcode->ic.ll.src.op()): "dx";
oper_stream<<(pIcode->ic.ll.flg & B)?", al": ", ax"; oper_stream<<(pIcode->ic.ll.flg & B)?", al": ", ax";
break; break;
@@ -597,7 +599,7 @@ static void dis1Line(Int i, Int pass)
/**************************************************************************** /****************************************************************************
* formatRM * formatRM
***************************************************************************/ ***************************************************************************/
static void formatRM(std::ostringstream &p, flags32 flg, ICODEMEM *pm) static void formatRM(std::ostringstream &p, flags32 flg, LLOpcode *pm)
{ {
char seg[4]; char seg[4];
@@ -644,7 +646,7 @@ static void formatRM(std::ostringstream &p, flags32 flg, ICODEMEM *pm)
/***************************************************************************** /*****************************************************************************
* strDst * strDst
****************************************************************************/ ****************************************************************************/
static ostringstream & strDst(ostringstream &os,flags32 flg, ICODEMEM *pm) static ostringstream & strDst(ostringstream &os,flags32 flg, LLOpcode *pm)
{ {
/* Immediates to memory require size descriptor */ /* Immediates to memory require size descriptor */
//os << setw(WID_PTR); //os << setw(WID_PTR);
@@ -664,7 +666,7 @@ static ostringstream &strSrc(ostringstream &os,ICODE *pc,bool skip_comma)
if(false==skip_comma) if(false==skip_comma)
os<<", "; os<<", ";
if (pc->ic.ll.flg & I) if (pc->ic.ll.flg & I)
os<<strHex(pc->ic.ll.immed.op); os<<strHex(pc->ic.ll.src.op());
else if (pc->ic.ll.flg & IM_SRC) /* level 2 */ else if (pc->ic.ll.flg & IM_SRC) /* level 2 */
os<<"dx:ax"; os<<"dx:ax";
else else
@@ -699,7 +701,7 @@ void interactDis(Function * initProc, Int initIC)
void flops(ICODE *pIcode,std::ostringstream &out) void flops(ICODE *pIcode,std::ostringstream &out)
{ {
char bf[30]; char bf[30];
byte op = (byte)pIcode->ic.ll.immed.op; byte op = (byte)pIcode->ic.ll.src.op();
/* Note that op is set to the escape number, e.g. /* Note that op is set to the escape number, e.g.
esc 0x38 is FILD */ esc 0x38 is FILD */

View File

@@ -70,7 +70,7 @@ CondJumps:
pBB->edges.pop_back(); pBB->edges.pop_back();
} }
else else
pBB->edges[1].ip = pIcode->ic.ll.immed.op; pBB->edges[1].ip = pIcode->ic.ll.src.op();
break; break;
case iLOOP: case iLOOPE: case iLOOPNE: case iLOOP: case iLOOPE: case iLOOPNE:
@@ -88,7 +88,7 @@ CondJumps:
else if ((pIcode->ic.ll.flg & (I | NO_LABEL)) == I) else if ((pIcode->ic.ll.flg & (I | NO_LABEL)) == I)
{ {
pBB = BB::Create(start, ip, ONE_BRANCH, 1, this); pBB = BB::Create(start, ip, ONE_BRANCH, 1, this);
pBB->edges[0].ip = pIcode->ic.ll.immed.op; pBB->edges[0].ip = pIcode->ic.ll.src.op();
} }
else else
BB::Create(start, ip, NOWHERE_NODE, 0, this); BB::Create(start, ip, NOWHERE_NODE, 0, this);
@@ -97,7 +97,7 @@ CondJumps:
case iCALLF: case iCALL: case iCALLF: case iCALL:
{ {
Function * p = pIcode->ic.ll.immed.proc.proc; Function * p = pIcode->ic.ll.src.proc.proc;
if (p) if (p)
i = ((p->flg) & TERMINATES) ? 0 : 1; i = ((p->flg) & TERMINATES) ? 0 : 1;
else else
@@ -217,7 +217,7 @@ void Function::compressCFG()
if (not pBB->edges.empty()) /* Might have been clobbered */ if (not pBB->edges.empty()) /* Might have been clobbered */
{ {
pBB->edges[i].BBptr = pNxt; pBB->edges[i].BBptr = pNxt;
Icode.SetImmediateOp(ip, (dword)pNxt->begin()); Icode[ip].SetImmediateOp((dword)pNxt->begin());
} }
} }
} }
@@ -289,7 +289,8 @@ BB *BB::rmJMP(Int marker, BB * pBB)
{ {
/* We are going around in circles */ /* We are going around in circles */
pBB->nodeType = NOWHERE_NODE; pBB->nodeType = NOWHERE_NODE;
pBB->front().ic.ll.immed.op = pBB->front().loc_ip; pBB->front().ic.ll.src.SetImmediateOp(pBB->front().loc_ip);
//pBB->front().ic.ll.src.immed.op = pBB->front().loc_ip;
do { do {
pBB = pBB->edges[0].BBptr; pBB = pBB->edges[0].BBptr;
pBB->inEdges.pop_back(); // was --numInedges pBB->inEdges.pop_back(); // was --numInedges

View File

@@ -46,11 +46,11 @@ void ICODE::newCallHl()
{ {
type = HIGH_LEVEL; type = HIGH_LEVEL;
ic.hl.opcode = HLI_CALL; ic.hl.opcode = HLI_CALL;
ic.hl.oper.call.proc = ic.ll.immed.proc.proc; ic.hl.oper.call.proc = ic.ll.src.proc.proc;
ic.hl.oper.call.args = new STKFRAME; ic.hl.oper.call.args = new STKFRAME;
if (ic.ll.immed.proc.cb != 0) if (ic.ll.src.proc.cb != 0)
ic.hl.oper.call.args->cb = ic.ll.immed.proc.cb; ic.hl.oper.call.args->cb = ic.ll.src.proc.cb;
else if(ic.hl.oper.call.proc) else if(ic.hl.oper.call.proc)
ic.hl.oper.call.args->cb =ic.hl.oper.call.proc->cbParam; ic.hl.oper.call.args->cb =ic.hl.oper.call.proc->cbParam;
else else

View File

@@ -18,10 +18,6 @@ CIcodeRec::CIcodeRec()
//reserve(512); //reserve(512);
} }
CIcodeRec::~CIcodeRec()
{
}
/* Copies the icode that is pointed to by pIcode to the icode array. /* Copies the icode that is pointed to by pIcode to the icode array.
* If there is need to allocate extra memory, it is done so, and * If there is need to allocate extra memory, it is done so, and
* the alloc variable is adjusted. */ * the alloc variable is adjusted. */
@@ -38,22 +34,6 @@ void CIcodeRec::SetInBB(int start, int end, BB *pnewBB)
at(i).inBB = pnewBB; at(i).inBB = pnewBB;
} }
void CIcodeRec::SetImmediateOp(int ip, dword dw)
{
at(ip).ic.ll.immed.op = dw;
}
dword CIcodeRec::GetLlLabel(int ip)
{
return at(ip).ic.ll.label;
}
llIcode CIcodeRec::GetLlOpcode(int ip)
{
return at(ip).ic.ll.opcode;
}
/* labelSrchRepl - Searches the icodes for instruction with label = target, and /* labelSrchRepl - Searches the icodes for instruction with label = target, and
replaces *pIndex with an icode index */ replaces *pIndex with an icode index */
bool CIcodeRec::labelSrch(dword target, dword &pIndex) bool CIcodeRec::labelSrch(dword target, dword &pIndex)

View File

@@ -323,7 +323,7 @@ static Int idiom3(iICODE pIcode, iICODE pEnd)
++pIcode; ++pIcode;
if ((pIcode < pEnd) && (pIcode->ic.ll.flg & I) && if ((pIcode < pEnd) && (pIcode->ic.ll.flg & I) &&
(pIcode->ic.ll.opcode == iADD) && (pIcode->ic.ll.dst.regi == rSP)) (pIcode->ic.ll.opcode == iADD) && (pIcode->ic.ll.dst.regi == rSP))
return (pIcode->ic.ll.immed.op); return (pIcode->ic.ll.src.op());
else if ((pIcode->ic.ll.opcode == iMOV) && (pIcode->ic.ll.dst.regi == rSP) else if ((pIcode->ic.ll.opcode == iMOV) && (pIcode->ic.ll.dst.regi == rSP)
&& (pIcode->ic.ll.src.regi == rBP)) && (pIcode->ic.ll.src.regi == rBP))
(pIcode-1)->ic.ll.flg |= REST_STK; (pIcode-1)->ic.ll.flg |= REST_STK;
@@ -404,7 +404,7 @@ static void idiom4 (iICODE pIcode, iICODE pEnd, Function * pProc)
/* Check for RET(F) immed */ /* Check for RET(F) immed */
if (pIcode->ic.ll.flg & I) if (pIcode->ic.ll.flg & I)
{ {
pProc->cbParam = (int16)pIcode->ic.ll.immed.op; pProc->cbParam = (int16)pIcode->ic.ll.src.op();
pProc->flg |= CALL_PASCAL; pProc->flg |= CALL_PASCAL;
} }
} }
@@ -457,7 +457,7 @@ static boolT idiom6 (iICODE pIcode, iICODE pEnd)
****************************************************************************/ ****************************************************************************/
static boolT idiom7 (iICODE pIcode) static boolT idiom7 (iICODE pIcode)
{ {
ICODEMEM *dst, *src; LLOpcode *dst, *src;
dst = &pIcode->ic.ll.dst; dst = &pIcode->ic.ll.dst;
src = &pIcode->ic.ll.src; src = &pIcode->ic.ll.src;
@@ -496,7 +496,8 @@ static boolT idiom7 (iICODE pIcode)
* Found in Borland Turbo C code. * Found in Borland Turbo C code.
****************************************************************************/ ****************************************************************************/
static boolT idiom21 (iICODE picode, iICODE pend) static boolT idiom21 (iICODE picode, iICODE pend)
{ ICODEMEM *dst, *src; {
LLOpcode *dst, *src;
dst = &picode->ic.ll.dst; dst = &picode->ic.ll.dst;
src = &picode->ic.ll.src; src = &picode->ic.ll.src;
@@ -526,14 +527,14 @@ static boolT idiom21 (iICODE picode, iICODE pend)
****************************************************************************/ ****************************************************************************/
static boolT idiom8 (iICODE pIcode, iICODE pEnd) static boolT idiom8 (iICODE pIcode, iICODE pEnd)
{ {
if (pIcode < pEnd) iICODE next=pIcode+1;
{ if((pIcode>=pEnd) and (next>=pEnd))
if (((pIcode->ic.ll.flg & I) == I) && (pIcode->ic.ll.immed.op == 1)) return false;
if (((pIcode+1)->ic.ll.opcode == iRCR) && if (pIcode->ic.ll.anyFlagSet(I) && (pIcode->ic.ll.src.op() == 1))
(((pIcode+1)->ic.ll.flg & I) == I) && if ((next->ic.ll.opcode == iRCR) &&
((pIcode+1)->ic.ll.immed.op == 1)) next->ic.ll.anyFlagSet(I) &&
return true; (next->ic.ll.src.op() == 1))
} return true;
return false; return false;
} }
@@ -550,22 +551,22 @@ static boolT idiom8 (iICODE pIcode, iICODE pEnd)
* Found in Borland Turbo C code to index an array (array multiplication) * Found in Borland Turbo C code to index an array (array multiplication)
****************************************************************************/ ****************************************************************************/
static Int idiom15 (iICODE picode, iICODE pend) static Int idiom15 (iICODE picode, iICODE pend)
{ Int n = 1; {
Int n = 1;
byte regi; byte regi;
if (picode < pend) if (picode < pend)
{ {
/* Match SHL reg, 1 */ /* Match SHL reg, 1 */
if ((picode->ic.ll.flg & I) && (picode->ic.ll.immed.op == 1)) if ((picode->ic.ll.flg & I) && (picode->ic.ll.src.op() == 1))
{ {
regi = picode->ic.ll.dst.regi; regi = picode->ic.ll.dst.regi;
while (1) for(auto iter=picode+1;iter < pend;++iter)
{ {
if (((picode+n) < pend) && if ((iter->ic.ll.opcode == iSHL) &&
((picode+n)->ic.ll.opcode == iSHL) && (iter->ic.ll.flg & I) &&
((picode+n)->ic.ll.flg & I) && (iter->ic.ll.src.op() == 1) &&
((picode+n)->ic.ll.immed.op == 1) && (iter->ic.ll.dst.regi == regi))
((picode+n)->ic.ll.dst.regi == regi))
n++; n++;
else else
break; break;
@@ -590,12 +591,13 @@ static Int idiom15 (iICODE picode, iICODE pend)
****************************************************************************/ ****************************************************************************/
static boolT idiom12 (iICODE pIcode, iICODE pEnd) static boolT idiom12 (iICODE pIcode, iICODE pEnd)
{ {
iICODE next=pIcode+1;
if (pIcode < pEnd) if (pIcode < pEnd)
{ {
if (((pIcode->ic.ll.flg & I) == I) && (pIcode->ic.ll.immed.op == 1)) if (pIcode->ic.ll.anyFlagSet(I) && (pIcode->ic.ll.src.op() == 1))
if (((pIcode+1)->ic.ll.opcode == iRCL) && if ((next->ic.ll.opcode == iRCL) &&
(((pIcode+1)->ic.ll.flg & I) == I) && (next->ic.ll.anyFlagSet(I)) &&
((pIcode+1)->ic.ll.immed.op == 1)) (next->ic.ll.src.op() == 1))
return true; return true;
} }
return false; return false;
@@ -613,12 +615,13 @@ static boolT idiom12 (iICODE pIcode, iICODE pEnd)
****************************************************************************/ ****************************************************************************/
static boolT idiom9 (iICODE pIcode, iICODE pEnd) static boolT idiom9 (iICODE pIcode, iICODE pEnd)
{ {
iICODE next=pIcode+1;
if (pIcode < pEnd) if (pIcode < pEnd)
{ {
if (((pIcode->ic.ll.flg & I) == I) && (pIcode->ic.ll.immed.op == 1)) if (((pIcode->ic.ll.flg & I) == I) && (pIcode->ic.ll.src.op() == 1))
if (((pIcode+1)->ic.ll.opcode == iRCR) && if ((next->ic.ll.opcode == iRCR) &&
(((pIcode+1)->ic.ll.flg & I) == I) && ((next->ic.ll.flg & I) == I) &&
((pIcode+1)->ic.ll.immed.op == 1)) (next->ic.ll.src.op() == 1))
return true; return true;
} }
return false; return false;
@@ -678,22 +681,22 @@ static boolT idiom10old (iICODE pIcode, iICODE pEnd)
****************************************************************************/ ****************************************************************************/
static void idiom10 (iICODE pIcode, iICODE pEnd) static void idiom10 (iICODE pIcode, iICODE pEnd)
{ {
if (pIcode < pEnd) iICODE next=pIcode+1;
{ if((pIcode>=pEnd) or (next>=pEnd))
/* Check OR reg, reg */ return;
if (((pIcode->ic.ll.flg & I) != I) && /* Check OR reg, reg */
(pIcode->ic.ll.src. regi > 0) && if (((pIcode->ic.ll.flg & I) != I) &&
(pIcode->ic.ll.src.regi < INDEXBASE) && (pIcode->ic.ll.src.regi > 0) &&
(pIcode->ic.ll.src.regi == pIcode->ic.ll.dst.regi)) (pIcode->ic.ll.src.regi < INDEXBASE) &&
if (((pIcode+1) < pEnd) && ((pIcode+1)->ic.ll.opcode == iJNE)) (pIcode->ic.ll.src.regi == pIcode->ic.ll.dst.regi))
{ if (next->ic.ll.opcode == iJNE)
pIcode->ic.ll.opcode = iCMP; {
pIcode->ic.ll.flg |= I; pIcode->ic.ll.opcode = iCMP;
pIcode->ic.ll.immed.op = 0; pIcode->ic.ll.flg |= I;
pIcode->du.def = 0; pIcode->ic.ll.src.SetImmediateOp(0); // todo check if proc should be zeroed too
pIcode->du1.numRegsDef = 0; pIcode->du.def = 0;
} pIcode->du1.numRegsDef = 0;
} }
} }
@@ -707,23 +710,24 @@ static void idiom10 (iICODE pIcode, iICODE pEnd)
* Found in Borland Turbo C, used for multiplication and division of * Found in Borland Turbo C, used for multiplication and division of
* byte operands (ie. they need to be extended to words). * byte operands (ie. they need to be extended to words).
****************************************************************************/ ****************************************************************************/
static byte idiom13 (iICODE picode, iICODE pend) static byte idiom13 (iICODE pIcode, iICODE pEnd)
{ byte regi; {
byte regi;
iICODE next=pIcode+1;
if((pIcode>=pEnd) or (next>=pEnd))
return 0;
if (picode < pend) /* Check for regL */
regi = pIcode->ic.ll.dst.regi;
if (((pIcode->ic.ll.flg & I) != I) && (regi >= rAL) && (regi <= rBH))
{ {
/* Check for regL */ /* Check for MOV regH, 0 */
regi = picode->ic.ll.dst.regi; if ((next->ic.ll.opcode == iMOV) &&
if (((picode->ic.ll.flg & I) != I) && (regi >= rAL) && (regi <= rBH)) (next->ic.ll.flg & I) &&
(next->ic.ll.src.op() == 0))
{ {
/* Check for MOV regH, 0 */ if (next->ic.ll.dst.regi == (regi + 4))
if (((picode+1)->ic.ll.opcode == iMOV) && return (regi - rAL + rAX);
((picode+1)->ic.ll.flg & I) &&
((picode+1)->ic.ll.immed.op == 0))
{
if ((picode+1)->ic.ll.dst.regi == (regi + 4))
return (regi - rAL + rAX);
}
} }
} }
return (0); return (0);
@@ -1175,13 +1179,12 @@ void Function::findIdioms()
case iCALL: case iCALLF: case iCALL: case iCALLF:
/* Check for library functions that return a long register. /* Check for library functions that return a long register.
* Propagate this result */ * Propagate this result */
if (pIcode->ic.ll.immed.proc.proc != 0) if (pIcode->ic.ll.src.proc.proc != 0)
if ((pIcode->ic.ll.immed.proc.proc->flg & PROC_ISLIB) && if ((pIcode->ic.ll.src.proc.proc->flg & PROC_ISLIB) &&
(pIcode->ic.ll.immed.proc.proc->flg & PROC_IS_FUNC)) (pIcode->ic.ll.src.proc.proc->flg & PROC_IS_FUNC))
{ {
if ((pIcode->ic.ll.immed.proc.proc->retVal.type==TYPE_LONG_SIGN) if ((pIcode->ic.ll.src.proc.proc->retVal.type==TYPE_LONG_SIGN)
|| (pIcode->ic.ll.immed.proc.proc->retVal.type == || (pIcode->ic.ll.src.proc.proc->retVal.type == TYPE_LONG_UNSIGN))
TYPE_LONG_UNSIGN))
localId.newLongReg(TYPE_LONG_SIGN, rDX, rAX, ip); localId.newLongReg(TYPE_LONG_SIGN, rDX, rAX, ip);
} }
@@ -1190,9 +1193,9 @@ void Function::findIdioms()
{ {
if (pIcode->ic.ll.flg & I) if (pIcode->ic.ll.flg & I)
{ {
(pIcode->ic.ll.immed.proc.proc)->cbParam = (int16)idx; (pIcode->ic.ll.src.proc.proc)->cbParam = (int16)idx;
pIcode->ic.ll.immed.proc.cb = idx; pIcode->ic.ll.src.proc.cb = idx;
(pIcode->ic.ll.immed.proc.proc)->flg |= CALL_C; (pIcode->ic.ll.src.proc.proc)->flg |= CALL_C;
pIcode++; pIcode++;
(pIcode++)->invalidate(); (pIcode++)->invalidate();
ip++; ip++;
@@ -1207,9 +1210,9 @@ void Function::findIdioms()
{ {
if (pIcode->isLlFlag(I)) if (pIcode->isLlFlag(I))
{ {
(pIcode->ic.ll.immed.proc.proc)->cbParam = (int16)idx; (pIcode->ic.ll.src.proc.proc)->cbParam = (int16)idx;
pIcode->ic.ll.immed.proc.cb = idx; pIcode->ic.ll.src.proc.cb = idx;
(pIcode->ic.ll.immed.proc.proc)->flg |= CALL_C; (pIcode->ic.ll.src.proc.proc)->flg |= CALL_C;
ip += idx/2 - 1; ip += idx/2 - 1;
pIcode++; pIcode++;
for (idx /= 2; idx > 0; idx--) for (idx /= 2; idx > 0; idx--)
@@ -1376,7 +1379,7 @@ void Function::findIdioms()
if (idiom21 (pIcode, pEnd)) if (idiom21 (pIcode, pEnd))
{ {
lhs = COND_EXPR::idLong (&localId, DST, pIcode,HIGH_FIRST, ip, eDEF, 1); lhs = COND_EXPR::idLong (&localId, DST, pIcode,HIGH_FIRST, ip, eDEF, 1);
rhs = COND_EXPR::idKte ((pIcode+1)->ic.ll.immed.op , 4); rhs = COND_EXPR::idKte ((pIcode+1)->ic.ll.src.op() , 4);
pIcode->setAsgn(lhs, rhs); pIcode->setAsgn(lhs, rhs);
pIcode->du.use = 0; /* clear register used in iXOR */ pIcode->du.use = 0; /* clear register used in iXOR */
(pIcode+1)->invalidate(); (pIcode+1)->invalidate();
@@ -1430,7 +1433,7 @@ void Function::bindIcodeOff()
for (i = 0; i < Icode.size(); i++) for (i = 0; i < Icode.size(); i++)
if ((pIcode[i].ic.ll.flg & I) && JmpInst(pIcode[i].ic.ll.opcode)) if ((pIcode[i].ic.ll.flg & I) && JmpInst(pIcode[i].ic.ll.opcode))
{ {
if (Icode.labelSrch(pIcode[i].ic.ll.immed.op, j)) if (Icode.labelSrch(pIcode[i].ic.ll.src.op(), j))
{ {
pIcode[j].ic.ll.flg |= TARGET; pIcode[j].ic.ll.flg |= TARGET;
} }
@@ -1445,8 +1448,14 @@ void Function::bindIcodeOff()
{ {
if (pIcode->ic.ll.flg & I) if (pIcode->ic.ll.flg & I)
{ {
if (! Icode.labelSrch(pIcode->ic.ll.immed.op, pIcode->ic.ll.immed.op)) dword found;
if (! Icode.labelSrch(pIcode->ic.ll.src.op(), found))
{
pIcode->ic.ll.flg |= NO_LABEL; pIcode->ic.ll.flg |= NO_LABEL;
}
else
pIcode->ic.ll.src.SetImmediateOp(found);
} }
else if (pIcode->ic.ll.flg & SWITCH) else if (pIcode->ic.ll.flg & SWITCH)
{ {

View File

@@ -252,7 +252,7 @@ Int LOCAL_ID::newLongStk(hlType t, Int offH, Int offL)
Int LOCAL_ID::newLong(opLoc sd, ICODE *pIcode, hlFirst f, Int ix,operDu du, Int off) Int LOCAL_ID::newLong(opLoc sd, ICODE *pIcode, hlFirst f, Int ix,operDu du, Int off)
{ {
Int idx; Int idx;
ICODEMEM *pmH, *pmL; LLOpcode *pmH, *pmL;
if (f == LOW_FIRST) if (f == LOW_FIRST)
{ {
@@ -308,7 +308,7 @@ Int LOCAL_ID::newLong(opLoc sd, ICODE *pIcode, hlFirst f, Int ix,operDu du, Int
boolT checkLongEq (LONG_STKID_TYPE longId, iICODE pIcode, Int i, Int idx, boolT checkLongEq (LONG_STKID_TYPE longId, iICODE pIcode, Int i, Int idx,
Function * pProc, COND_EXPR **rhs, COND_EXPR **lhs, Int off) Function * pProc, COND_EXPR **rhs, COND_EXPR **lhs, Int off)
{ {
ICODEMEM *pmHdst, *pmLdst, *pmHsrc, *pmLsrc; /* pointers to LOW_LEVEL icodes */ LLOpcode *pmHdst, *pmLdst, *pmHsrc, *pmLsrc; /* pointers to LOW_LEVEL icodes */
pmHdst = &pIcode->ic.ll.dst; pmHdst = &pIcode->ic.ll.dst;
pmLdst = &(pIcode+off)->ic.ll.dst; pmLdst = &(pIcode+off)->ic.ll.dst;
@@ -346,7 +346,7 @@ boolT checkLongEq (LONG_STKID_TYPE longId, iICODE pIcode, Int i, Int idx,
boolT checkLongRegEq (LONGID_TYPE longId, iICODE pIcode, Int i, Int idx, boolT checkLongRegEq (LONGID_TYPE longId, iICODE pIcode, Int i, Int idx,
Function * pProc, COND_EXPR *&rhs, COND_EXPR *&lhs, Int off) Function * pProc, COND_EXPR *&rhs, COND_EXPR *&lhs, Int off)
{ {
ICODEMEM *pmHdst, *pmLdst, *pmHsrc, *pmLsrc; /* pointers to LOW_LEVEL icodes */ LLOpcode *pmHdst, *pmLdst, *pmHsrc, *pmLsrc; /* pointers to LOW_LEVEL icodes */
pmHdst = &pIcode->ic.ll.dst; pmHdst = &pIcode->ic.ll.dst;
pmLdst = &(pIcode+off)->ic.ll.dst; pmLdst = &(pIcode+off)->ic.ll.dst;

View File

@@ -21,7 +21,7 @@ static void process_operands(ICODE * pIcode, Function * pProc, STATE * pstat
static void setBits(int16 type, dword start, dword len); static void setBits(int16 type, dword start, dword len);
static SYM * updateGlobSym(dword operand, Int size, word duFlag); static SYM * updateGlobSym(dword operand, Int size, word duFlag);
static void process_MOV(ICODE * pIcode, STATE * pstate); static void process_MOV(ICODE * pIcode, STATE * pstate);
static SYM * lookupAddr (ICODEMEM *pm, STATE * pstate, Int size, word duFlag); static SYM * lookupAddr (LLOpcode *pm, STATE * pstate, Int size, word duFlag);
void interactDis(Function * initProc, Int ic); void interactDis(Function * initProc, Int ic);
static dword SynthLab; static dword SynthLab;
@@ -156,7 +156,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
_Icode.type = LOW_LEVEL; _Icode.type = LOW_LEVEL;
_Icode.ic.ll.opcode = iJMP; _Icode.ic.ll.opcode = iJMP;
_Icode.ic.ll.flg = I | SYNTHETIC | NO_OPS; _Icode.ic.ll.flg = I | SYNTHETIC | NO_OPS;
_Icode.ic.ll.immed.op = Icode.GetLlLabel(lab); _Icode.ic.ll.src.SetImmediateOp(Icode[lab].GetLlLabel());
_Icode.ic.ll.label = SynthLab++; _Icode.ic.ll.label = SynthLab++;
} }
@@ -184,10 +184,10 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
eIcode.ic.ll.flg |= SYNTHETIC; eIcode.ic.ll.flg |= SYNTHETIC;
/* eIcode.ic.ll.label = SynthLab++; */ /* eIcode.ic.ll.label = SynthLab++; */
eIcode.ic.ll.label = _Icode.ic.ll.label; eIcode.ic.ll.label = _Icode.ic.ll.label;
pIcode = Icode.addIcode(&eIcode); Icode.addIcode(&eIcode);
/* iDIV, iIDIV */ /* iDIV, iIDIV */
pIcode = Icode.addIcode(&_Icode); Icode.addIcode(&_Icode);
/* iMOD */ /* iMOD */
memset (&eIcode, 0, sizeof (ICODE)); memset (&eIcode, 0, sizeof (ICODE));
@@ -212,13 +212,13 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
eIcode.ic.ll.flg |= SYNTHETIC; eIcode.ic.ll.flg |= SYNTHETIC;
/* eIcode.ic.ll.label = SynthLab++; */ /* eIcode.ic.ll.label = SynthLab++; */
eIcode.ic.ll.label = _Icode.ic.ll.label; eIcode.ic.ll.label = _Icode.ic.ll.label;
pIcode = Icode.addIcode(&eIcode); Icode.addIcode(&eIcode);
/* MOV regDst, regSrc */ /* MOV regDst, regSrc */
_Icode.ic.ll.opcode = iMOV; _Icode.ic.ll.opcode = iMOV;
_Icode.ic.ll.flg |= SYNTHETIC; _Icode.ic.ll.flg |= SYNTHETIC;
/* Icode.ic.ll.label = SynthLab++; */ /* Icode.ic.ll.label = SynthLab++; */
pIcode = Icode.addIcode(&_Icode); Icode.addIcode(&_Icode);
_Icode.ic.ll.opcode = iXCHG; /* for next case */ _Icode.ic.ll.opcode = iXCHG; /* for next case */
/* MOV regSrc, rTMP */ /* MOV regSrc, rTMP */
@@ -256,7 +256,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
*/ */
if (ip > 0 && prev.ic.ll.opcode == iCMP && (prev.ic.ll.flg & I)) if (ip > 0 && prev.ic.ll.opcode == iCMP && (prev.ic.ll.flg & I))
{ {
pstate->JCond.immed = (int16)prev.ic.ll.immed.op; pstate->JCond.immed = (int16)prev.ic.ll.src.op();
if (_Icode.ic.ll.opcode == iJA || _Icode.ic.ll.opcode == iJBE) if (_Icode.ic.ll.opcode == iJA || _Icode.ic.ll.opcode == iJBE)
pstate->JCond.immed++; pstate->JCond.immed++;
if (_Icode.ic.ll.opcode == iJAE || _Icode.ic.ll.opcode == iJA) if (_Icode.ic.ll.opcode == iJAE || _Icode.ic.ll.opcode == iJA)
@@ -264,8 +264,8 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
fBranch = (boolT) fBranch = (boolT)
(_Icode.ic.ll.opcode == iJB || _Icode.ic.ll.opcode == iJBE); (_Icode.ic.ll.opcode == iJB || _Icode.ic.ll.opcode == iJBE);
} }
StCopy = *pstate;
memcpy(&StCopy, pstate, sizeof(STATE)); //memcpy(&StCopy, pstate, sizeof(STATE));
/* Straight line code */ /* Straight line code */
this->FollowCtrl (pcallGraph, &StCopy); // recurrent ? this->FollowCtrl (pcallGraph, &StCopy); // recurrent ?
@@ -302,7 +302,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
break; break;
case iINT: case iINT:
if (_Icode.ic.ll.immed.op == 0x21 && pstate->f[rAH]) if (_Icode.ic.ll.src.op() == 0x21 && pstate->f[rAH])
{ {
Int funcNum = pstate->r[rAH]; Int funcNum = pstate->r[rAH];
Int operand; Int operand;
@@ -328,13 +328,13 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
updateSymType (operand, TYPE_STR, size); updateSymType (operand, TYPE_STR, size);
} }
} }
else if ((_Icode.ic.ll.immed.op == 0x2F) && (pstate->f[rAH])) else if ((_Icode.ic.ll.src.op() == 0x2F) && (pstate->f[rAH]))
{ {
Icode.back().ic.ll.dst.off = pstate->r[rAH]; Icode.back().ic.ll.dst.off = pstate->r[rAH];
} }
else /* Program termination: int20h, int27h */ else /* Program termination: int20h, int27h */
done = (boolT)(_Icode.ic.ll.immed.op == 0x20 || done = (boolT)(_Icode.ic.ll.src.op() == 0x20 ||
_Icode.ic.ll.immed.op == 0x27); _Icode.ic.ll.src.op() == 0x27);
if (done) if (done)
pIcode->ic.ll.flg |= TERMINATES; pIcode->ic.ll.flg |= TERMINATES;
break; break;
@@ -350,7 +350,7 @@ void Function::FollowCtrl(CALL_GRAPH * pcallGraph, STATE *pstate)
case iSHL: case iSHL:
if (pstate->JCond.regi == _Icode.ic.ll.dst.regi) if (pstate->JCond.regi == _Icode.ic.ll.dst.regi)
if ((_Icode.ic.ll.flg & I) && _Icode.ic.ll.immed.op == 1) if ((_Icode.ic.ll.flg & I) && _Icode.ic.ll.src.op() == 1)
pstate->JCond.immed *= 2; pstate->JCond.immed *= 2;
else else
pstate->JCond.regi = 0; pstate->JCond.regi = 0;
@@ -403,7 +403,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr
{ {
if (pIcode->ic.ll.opcode == iJMPF) if (pIcode->ic.ll.opcode == iJMPF)
pstate->setState( rCS, LH(prog.Image + pIcode->ic.ll.label + 3)); pstate->setState( rCS, LH(prog.Image + pIcode->ic.ll.label + 3));
i = pstate->IP = pIcode->ic.ll.immed.op; i = pstate->IP = pIcode->ic.ll.src.op();
if ((long)i < 0) if ((long)i < 0)
{ {
exit(1); exit(1);
@@ -491,7 +491,7 @@ boolT Function::process_JMP (ICODE * pIcode, STATE *pstate, CALL_GRAPH * pcallGr
Icode.GetIcode(ip)->ic.ll.caseTbl.numEntries = k++; Icode.GetIcode(ip)->ic.ll.caseTbl.numEntries = k++;
Icode.GetIcode(ip)->ic.ll.flg |= CASE; Icode.GetIcode(ip)->ic.ll.flg |= CASE;
*psw++ = Icode.GetLlLabel(ip); *psw++ = Icode[ip].GetLlLabel();
} }
return TRUE; return TRUE;
} }
@@ -550,11 +550,12 @@ boolT Function::process_CALL (ICODE * pIcode, CALL_GRAPH * pcallGraph, STATE *ps
/* Address of function is given by 4 (CALLF) or 2 (CALL) bytes at /* Address of function is given by 4 (CALLF) or 2 (CALL) bytes at
* previous offset into the program image */ * previous offset into the program image */
dword tgtAddr=0;
if (pIcode->ic.ll.opcode == iCALLF) if (pIcode->ic.ll.opcode == iCALLF)
pIcode->ic.ll.immed.op = LH(&prog.Image[off]) + tgtAddr= LH(&prog.Image[off]) + (dword)(LH(&prog.Image[off+2])) << 4;
((dword)(LH(&prog.Image[off+2])) << 4);
else else
pIcode->ic.ll.immed.op = LH(&prog.Image[off]) + ((dword)(word)state.r[rCS] << 4); tgtAddr= LH(&prog.Image[off]) + (dword)(word)state.r[rCS] << 4;
pIcode->ic.ll.src.SetImmediateOp( tgtAddr );
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
indirect = TRUE; indirect = TRUE;
} }
@@ -565,7 +566,7 @@ boolT Function::process_CALL (ICODE * pIcode, CALL_GRAPH * pcallGraph, STATE *ps
/* Search procedure list for one with appropriate entry point */ /* Search procedure list for one with appropriate entry point */
ilFunction iter= std::find_if(pProcList.begin(),pProcList.end(), ilFunction iter= std::find_if(pProcList.begin(),pProcList.end(),
[pIcode](const Function &f) -> [pIcode](const Function &f) ->
bool { return f.procEntry==pIcode->ic.ll.immed.op; }); bool { return f.procEntry==pIcode->ic.ll.src.op(); });
/* Create a new procedure node and save copy of the state */ /* Create a new procedure node and save copy of the state */
if (iter==pProcList.end()) if (iter==pProcList.end())
@@ -573,7 +574,7 @@ boolT Function::process_CALL (ICODE * pIcode, CALL_GRAPH * pcallGraph, STATE *ps
pProcList.push_back(Function::Create()); pProcList.push_back(Function::Create());
Function &x(pProcList.back()); Function &x(pProcList.back());
iter = (++pProcList.rbegin()).base(); iter = (++pProcList.rbegin()).base();
x.procEntry = pIcode->ic.ll.immed.op; x.procEntry = pIcode->ic.ll.src.op();
LibCheck(x); LibCheck(x);
if (x.flg & PROC_ISLIB) if (x.flg & PROC_ISLIB)
@@ -581,7 +582,7 @@ boolT Function::process_CALL (ICODE * pIcode, CALL_GRAPH * pcallGraph, STATE *ps
/* A library function. No need to do any more to it */ /* A library function. No need to do any more to it */
pcallGraph->insertCallGraph (this, iter); pcallGraph->insertCallGraph (this, iter);
iter = (++pProcList.rbegin()).base(); iter = (++pProcList.rbegin()).base();
Icode.GetIcode(ip)->ic.ll.immed.proc.proc = &x; Icode.GetIcode(ip)->ic.ll.src.proc.proc = &x;
return false; return false;
} }
@@ -597,7 +598,7 @@ boolT Function::process_CALL (ICODE * pIcode, CALL_GRAPH * pcallGraph, STATE *ps
/* Save machine state in localState, load up IP and CS.*/ /* Save machine state in localState, load up IP and CS.*/
localState = *pstate; localState = *pstate;
pstate->IP = pIcode->ic.ll.immed.op; pstate->IP = pIcode->ic.ll.src.op();
if (pIcode->ic.ll.opcode == iCALLF) if (pIcode->ic.ll.opcode == iCALLF)
pstate->setState( rCS, LH(prog.Image + pIcode->ic.ll.label + 3)); pstate->setState( rCS, LH(prog.Image + pIcode->ic.ll.label + 3));
x.state = *pstate; x.state = *pstate;
@@ -619,7 +620,7 @@ boolT Function::process_CALL (ICODE * pIcode, CALL_GRAPH * pcallGraph, STATE *ps
else else
pcallGraph->insertCallGraph (this, iter); pcallGraph->insertCallGraph (this, iter);
Icode[ip].ic.ll.immed.proc.proc = &(*iter); // ^ target proc Icode[ip].ic.ll.src.proc.proc = &(*iter); // ^ target proc
/* return ((p->flg & TERMINATES) != 0); */ /* return ((p->flg & TERMINATES) != 0); */
return FALSE; return FALSE;
@@ -638,7 +639,7 @@ static void process_MOV(ICODE * pIcode, STATE * pstate)
if (dstReg > 0 && dstReg < INDEXBASE) if (dstReg > 0 && dstReg < INDEXBASE)
{ {
if (pIcode->ic.ll.flg & I) if (pIcode->ic.ll.flg & I)
pstate->setState( dstReg, (int16)pIcode->ic.ll.immed.op); pstate->setState( dstReg, (int16)pIcode->ic.ll.src.op());
else if (srcReg == 0) /* direct memory offset */ else if (srcReg == 0) /* direct memory offset */
{ {
psym = lookupAddr(&pIcode->ic.ll.src, pstate, 2, eDuVal::USE); psym = lookupAddr(&pIcode->ic.ll.src, pstate, 2, eDuVal::USE);
@@ -658,8 +659,8 @@ static void process_MOV(ICODE * pIcode, STATE * pstate)
psym = lookupAddr (&pIcode->ic.ll.dst, pstate, 2, eDEF); psym = lookupAddr (&pIcode->ic.ll.dst, pstate, 2, eDEF);
if (psym && ! (psym->duVal.val)) /* no initial value yet */ if (psym && ! (psym->duVal.val)) /* no initial value yet */
if (pIcode->ic.ll.flg & I) { /* immediate */ if (pIcode->ic.ll.flg & I) { /* immediate */
prog.Image[psym->label] = (byte)pIcode->ic.ll.immed.op; prog.Image[psym->label] = (byte)pIcode->ic.ll.src.op();
prog.Image[psym->label+1] = (byte)(pIcode->ic.ll.immed.op>>8); prog.Image[psym->label+1] = (byte)(pIcode->ic.ll.src.op()>>8);
psym->duVal.val = 1; psym->duVal.val = 1;
} }
else if (srcReg == 0) { /* direct mem offset */ else if (srcReg == 0) { /* direct mem offset */
@@ -776,7 +777,7 @@ static void updateFrameOff (STKFRAME * ps, int16 off, Int size, word duFlag)
* if necessary. * if necessary.
* Returns a pointer to the symbol in the * Returns a pointer to the symbol in the
* symbol table, or Null if it's not a direct memory offset. */ * symbol table, or Null if it's not a direct memory offset. */
static SYM * lookupAddr (ICODEMEM *pm, STATE *pstate, Int size, word duFlag) static SYM * lookupAddr (LLOpcode *pm, STATE *pstate, Int size, word duFlag)
{ {
Int i; Int i;
SYM * psym; SYM * psym;
@@ -911,7 +912,7 @@ dword duReg[] = { 0x00,
* ix : current index into icode array */ * ix : current index into icode array */
static void use (opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int size, Int ix) static void use (opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int size, Int ix)
{ {
ICODEMEM * pm = (d == SRC)? &pIcode->ic.ll.src: &pIcode->ic.ll.dst; LLOpcode * pm = (d == SRC)? &pIcode->ic.ll.src: &pIcode->ic.ll.dst;
SYM * psym; SYM * psym;
if (pm->regi == 0 || pm->regi >= INDEXBASE) if (pm->regi == 0 || pm->regi >= INDEXBASE)
@@ -952,13 +953,13 @@ static void use (opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int
} }
static void def (opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int size,
Int ix)
/* Checks which registers were defined (ie. got a new value) and updates the /* Checks which registers were defined (ie. got a new value) and updates the
* du.d flag. * du.d flag.
* Places local variables in the local symbol table. */ * Places local variables in the local symbol table. */
static void def (opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int size,
Int ix)
{ {
ICODEMEM *pm = (d == SRC)? &pIcode->ic.ll.src: &pIcode->ic.ll.dst; LLOpcode *pm = (d == SRC)? &pIcode->ic.ll.src: &pIcode->ic.ll.dst;
SYM * psym; SYM * psym;
if (pm->regi == 0 || pm->regi >= INDEXBASE) if (pm->regi == 0 || pm->regi >= INDEXBASE)
@@ -1010,7 +1011,7 @@ static void def (opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int
static void use_def(opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int cb, static void use_def(opLoc d, ICODE * pIcode, Function * pProc, STATE * pstate, Int cb,
Int ix) Int ix)
{ {
ICODEMEM * pm = (d == SRC)? &pIcode->ic.ll.src: &pIcode->ic.ll.dst; LLOpcode * pm = (d == SRC)? &pIcode->ic.ll.src: &pIcode->ic.ll.dst;
use (d, pIcode, pProc, pstate, cb, ix); use (d, pIcode, pProc, pstate, cb, ix);

View File

@@ -302,7 +302,7 @@ void checkBack();
int Function::checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx,Assignment &asgn) int Function::checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx,Assignment &asgn)
{ {
int idx; int idx;
ICODEMEM * pmH,* pmL; LLOpcode * pmH,* pmL;
iICODE pIcode; iICODE pIcode;
for (idx = pLocId_idx - 1; idx > 0 ; idx--) for (idx = pLocId_idx - 1; idx > 0 ; idx--)
{ {
@@ -397,7 +397,7 @@ void Function::propLongReg (Int loc_ident_idx, ID *pLocId)
for (idx = pLocId_idx + 1; idx < Icode.size() - 1; idx++) for (idx = pLocId_idx + 1; idx < Icode.size() - 1; idx++)
{ {
iICODE pIcode; iICODE pIcode;
ICODEMEM * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */ LLOpcode * pmH,* pmL; /* Pointers to dst LOW_LEVEL icodes */
int off,arc; int off,arc;
pIcode = Icode.begin()+(idx); pIcode = Icode.begin()+(idx);
if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE)) if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))

View File

@@ -403,7 +403,7 @@ static Int signex(byte b)
***************************************************************************/ ***************************************************************************/
static void setAddress(Int i, boolT fdst, word seg, int16 reg, word off) static void setAddress(Int i, boolT fdst, word seg, int16 reg, word off)
{ {
ICODEMEM *pm; LLOpcode *pm;
/* If not to register (i.e. to r/m), and talking about r/m, /* If not to register (i.e. to r/m), and talking about r/m,
then this is dest */ then this is dest */
@@ -631,7 +631,7 @@ static void trans(Int i)
pIcode->ic.ll.opcode = transTable[REG(*pInst)]; /* valid on bytes */ pIcode->ic.ll.opcode = transTable[REG(*pInst)]; /* valid on bytes */
pIcode->ic.ll.flagDU.d = df[REG(*pInst)]; pIcode->ic.ll.flagDU.d = df[REG(*pInst)];
rm(i); rm(i);
memcpy(&pIcode->ic.ll.src, &pIcode->ic.ll.dst, sizeof(ICODEMEM)); pIcode->ic.ll.src = pIcode->ic.ll.dst;
if (pIcode->ic.ll.opcode == iJMP || pIcode->ic.ll.opcode == iCALL || pIcode->ic.ll.opcode == iCALLF) if (pIcode->ic.ll.opcode == iJMP || pIcode->ic.ll.opcode == iCALL || pIcode->ic.ll.opcode == iCALLF)
pIcode->ic.ll.flg |= NO_OPS; pIcode->ic.ll.flg |= NO_OPS;
else if (pIcode->ic.ll.opcode == iINC || pIcode->ic.ll.opcode == iPUSH || pIcode->ic.ll.opcode == iDEC) else if (pIcode->ic.ll.opcode == iINC || pIcode->ic.ll.opcode == iPUSH || pIcode->ic.ll.opcode == iDEC)
@@ -666,7 +666,7 @@ static void arith(Int i)
} }
else if (!(opcode == iNOT || opcode == iNEG)) else if (!(opcode == iNOT || opcode == iNEG))
{ {
memcpy(&pIcode->ic.ll.src, &pIcode->ic.ll.dst, sizeof(ICODEMEM)); pIcode->ic.ll.src = pIcode->ic.ll.dst;
setAddress(i, TRUE, 0, rAX, 0); /* dst = AX */ setAddress(i, TRUE, 0, rAX, 0); /* dst = AX */
} }
else if (opcode == iNEG || opcode == iNOT) else if (opcode == iNEG || opcode == iNOT)
@@ -685,8 +685,7 @@ static void arith(Int i)
*****************************************************************************/ *****************************************************************************/
static void data1(Int i) static void data1(Int i)
{ {
pIcode->ic.ll.immed.op = (stateTable[i].flg & S_EXT)? signex(*pInst++): pIcode->ic.ll.src.SetImmediateOp( (stateTable[i].flg & S_EXT)? signex(*pInst++): *pInst++ );
*pInst++;
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
} }
@@ -710,7 +709,7 @@ static void data2(Int )
pIcode->ic.ll.flg |= NO_OPS; pIcode->ic.ll.flg |= NO_OPS;
} }
else else
pIcode->ic.ll.immed.op = getWord(); pIcode->ic.ll.src.SetImmediateOp(getWord());
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
} }
@@ -735,7 +734,7 @@ static void dispN(Int )
/* Note: the result of the subtraction could be between 32k and 64k, and /* 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 still be positive; it is an offset from prog.Image. So this must be
treated as unsigned */ treated as unsigned */
pIcode->ic.ll.immed.op = (dword)(off + (unsigned)(pInst - prog.Image)); pIcode->ic.ll.src.SetImmediateOp((dword)(off + (unsigned)(pInst - prog.Image)));
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
} }
@@ -747,7 +746,7 @@ static void dispS(Int )
{ {
long off = signex(*pInst++); /* Signed displacement */ long off = signex(*pInst++); /* Signed displacement */
pIcode->ic.ll.immed.op = (dword)(off + (unsigned)(pInst - prog.Image)); pIcode->ic.ll.src.SetImmediateOp((dword)(off + (unsigned)(pInst - prog.Image)));
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
} }
@@ -760,7 +759,7 @@ static void dispF(Int )
dword off = (unsigned)getWord(); dword off = (unsigned)getWord();
dword seg = (unsigned)getWord(); dword seg = (unsigned)getWord();
pIcode->ic.ll.immed.op = off + ((dword)(unsigned)seg << 4); pIcode->ic.ll.src.SetImmediateOp(off + ((dword)(unsigned)seg << 4));
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
} }
@@ -808,7 +807,7 @@ static void strop(Int )
***************************************************************************/ ***************************************************************************/
static void escop(Int i) static void escop(Int i)
{ {
pIcode->ic.ll.immed.op = REG(*pInst) + (dword)((i & 7) << 3); pIcode->ic.ll.src.SetImmediateOp(REG(*pInst) + (dword)((i & 7) << 3));
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
rm(i); rm(i);
} }
@@ -819,7 +818,7 @@ static void escop(Int i)
****************************************************************************/ ****************************************************************************/
static void const1(Int ) static void const1(Int )
{ {
pIcode->ic.ll.immed.op = 1; pIcode->ic.ll.src.SetImmediateOp(1);
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
} }
@@ -829,7 +828,7 @@ static void const1(Int )
****************************************************************************/ ****************************************************************************/
static void const3(Int ) static void const3(Int )
{ {
pIcode->ic.ll.immed.op = 3; pIcode->ic.ll.src.SetImmediateOp(3);
pIcode->ic.ll.flg |= I; pIcode->ic.ll.flg |= I;
} }
@@ -856,12 +855,12 @@ static void none2(Int )
****************************************************************************/ ****************************************************************************/
static void checkInt(Int ) static void checkInt(Int )
{ {
word wOp = (word) pIcode->ic.ll.immed.op; word wOp = (word) pIcode->ic.ll.src.op();
if ((wOp >= 0x34) && (wOp <= 0x3B)) if ((wOp >= 0x34) && (wOp <= 0x3B))
{ {
/* This is a Borland/Microsoft floating point emulation instruction. /* This is a Borland/Microsoft floating point emulation instruction.
Treat as if it is an ESC opcode */ Treat as if it is an ESC opcode */
pIcode->ic.ll.immed.op = wOp - 0x34; pIcode->ic.ll.src.SetImmediateOp(wOp - 0x34);
pIcode->ic.ll.opcode = iESC; pIcode->ic.ll.opcode = iESC;
pIcode->ic.ll.flg |= FLOAT_OP; pIcode->ic.ll.flg |= FLOAT_OP;