Browse Source

mooing on

Artur K 12 years ago
parent
commit
8cb5449591
32 changed files with 1463 additions and 1431 deletions
  1. 7 4
      CMakeLists.txt
  2. 3 3
      include/BasicBlock.h
  3. 13 12
      include/Procedure.h
  4. 1 2
      include/StackFrame.h
  5. 1 2
      include/ast.h
  6. 0 1
      include/bundle.h
  7. 28 33
      include/dcc.h
  8. 25 22
      include/error.h
  9. 3 2
      include/icode.h
  10. 23 23
      include/locident.h
  11. 1 1
      include/perfhlib.h
  12. 0 31
      include/scanner.h
  13. 4 5
      src/BasicBlock.cpp
  14. 372 387
      src/ast.cpp
  15. 8 9
      src/backend.cpp
  16. 10 9
      src/chklib.cpp
  17. 14 16
      src/control.cpp
  18. 312 311
      src/dataflow.cpp
  19. 2 2
      src/dcc.cpp
  20. 1 1
      src/disassem.cpp
  21. 2 2
      src/error.cpp
  22. 55 84
      src/frontend.cpp
  23. 5 5
      src/graph.cpp
  24. 14 7
      src/hlicode.cpp
  25. 3 2
      src/icode.cpp
  26. 8 8
      src/idioms.cpp
  27. 8 8
      src/parser.cpp
  28. 38 38
      src/procs.cpp
  29. 211 131
      src/proplong.cpp
  30. 14 17
      src/reducible.cpp
  31. 275 246
      src/scanner.cpp
  32. 2 7
      src/udm.cpp

+ 7 - 4
CMakeLists.txt

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

+ 3 - 3
include/BasicBlock.h

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

+ 13 - 12
include/Procedure.h

@@ -113,20 +113,21 @@ public:
     void buildCFG();
     void buildCFG();
     void controlFlowAnalysis();
     void controlFlowAnalysis();
     void newRegArg(ICODE *picode, ICODE *ticode);
     void newRegArg(ICODE *picode, ICODE *ticode);
-protected:
+    protected:
     // TODO: replace those with friend visitor ?
     // TODO: replace those with friend visitor ?
-    void propLongReg(Int i, ID *pLocId);
+    void propLongReg(Int loc_ident_idx, ID *pLocId);
     void propLongStk(Int i, ID *pLocId);
     void propLongStk(Int i, ID *pLocId);
     void propLongGlb(Int i, ID *pLocId);
     void propLongGlb(Int i, ID *pLocId);
 
 
-    void structCases();
-    void findExps();
-    void genDU1();
-    void elimCondCodes();
-    void liveRegAnalysis(dword in_liveOut);
-    void findIdioms();
-    void propLong();
-    void genLiveKtes();
-    byte findDerivedSeq (derSeq *derivedGi);
-    bool nextOrderGraph(derSeq *derivedGi);
+    int     checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx);
+    void    structCases();
+    void    findExps();
+    void    genDU1();
+    void    elimCondCodes();
+    void    liveRegAnalysis(dword in_liveOut);
+    void    findIdioms();
+    void    propLong();
+    void    genLiveKtes();
+    byte    findDerivedSeq (derSeq *derivedGi);
+    bool    nextOrderGraph(derSeq *derivedGi);
 };
 };

+ 1 - 2
include/StackFrame.h

@@ -35,11 +35,10 @@ struct STKFRAME
     int16       maxOff;     /* Maximum offset in stack frame*/
     int16       maxOff;     /* Maximum offset in stack frame*/
     Int         cb;         /* Number of bytes in arguments */
     Int         cb;         /* Number of bytes in arguments */
     Int         numArgs;    /* No. of arguments in the table*/
     Int         numArgs;    /* No. of arguments in the table*/
-    void adjustForArgType(Int numArg_, hlType actType_);
+    void        adjustForArgType(Int numArg_, hlType actType_);
     STKFRAME() : sym(0),minOff(0),maxOff(0),cb(0),numArgs(0)
     STKFRAME() : sym(0),minOff(0),maxOff(0),cb(0),numArgs(0)
     {
     {
 
 
     }
     }
-public:
     Int getLocVar(Int off);
     Int getLocVar(Int off);
 };
 };

+ 1 - 2
include/ast.h

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

+ 0 - 1
include/bundle.h

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

+ 28 - 33
include/dcc.h

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

+ 25 - 22
include/error.h

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

+ 3 - 2
include/icode.h

@@ -294,13 +294,14 @@ struct LLTYPE
         dword   op;             /*   idx of immed src op        */
         dword   op;             /*   idx of immed src op        */
         struct {				/* Call & # actual arg bytes	*/
         struct {				/* Call & # actual arg bytes	*/
             Function *proc;     /*   pointer to target proc (for CALL(F))*/
             Function *proc;     /*   pointer to target proc (for CALL(F))*/
-            int		   cb;		/*   # actual arg bytes			*/
+            int     cb;		/*   # actual arg bytes			*/
         }		proc;
         }		proc;
     }           immed;
     }           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    */
         dword  *entries;        /*   array of offsets           */
         dword  *entries;        /*   array of offsets           */
+
     }           caseTbl;
     }           caseTbl;
     Int         hllLabNum;      /* label # for hll codegen      */
     Int         hllLabNum;      /* label # for hll codegen      */
     bool conditionalJump()
     bool conditionalJump()
@@ -375,7 +376,7 @@ public:
     void	SetLlInvalid(int ip, boolT fInv);
     void	SetLlInvalid(int ip, boolT fInv);
     dword	GetLlLabel(int ip);
     dword	GetLlLabel(int ip);
     llIcode	GetLlOpcode(int ip);
     llIcode	GetLlOpcode(int ip);
-    boolT	labelSrch(dword target, Int *pIndex);
+    bool	labelSrch(dword target, dword &pIndex);
     ICODE *	GetIcode(int ip);
     ICODE *	GetIcode(int ip);
 };
 };
 typedef CIcodeRec::iterator iICODE;
 typedef CIcodeRec::iterator iICODE;

+ 23 - 23
include/locident.h

@@ -34,7 +34,7 @@ typedef enum {
     TYPE_DOUBLE		/* double precision float	*/
     TYPE_DOUBLE		/* double precision float	*/
 } hlType;
 } hlType;
 
 
-static const char *hlTypes[13] = {"", "char", "unsigned char", "int", "unsigned int",
+static constexpr const char *hlTypes[13] = {"", "char", "unsigned char", "int", "unsigned int",
                                   "long", "unsigned long", "record", "int *", "char *",
                                   "long", "unsigned long", "record", "int *", "char *",
                                   "", "float", "double"};
                                   "", "float", "double"};
 
 
@@ -68,33 +68,33 @@ typedef struct
 /* ID, LOCAL_ID */
 /* ID, LOCAL_ID */
 struct ID
 struct ID
 {
 {
-    hlType			type;	/* Probable type							 */
-    boolT			illegal;/* Boolean: not a valid field any more		 */
-    IDX_ARRAY		idx;	/* Index into icode array (REG_FRAME only)	 */
-    frameType		loc;	/* Frame location							 */
-    boolT			hasMacro;/* Identifier requires a macro				 */
-    char			macro[10];/* Macro for this identifier				 */
-    char			name[20];/* Identifier's name						 */
-    union {					/* Different types of identifiers 			 */
-        byte		regi;	/* For TYPE_BYTE(WORD)_(UN)SIGN registers    */
-        struct {			/* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */
-            byte	regOff; /*    register offset (if any)				 */
-            Int		off;	/*    offset from BP						 */
-        }			bwId;
+    hlType              type;       /* Probable type                            */
+    boolT               illegal;    /* Boolean: not a valid field any more      */
+    IDX_ARRAY           idx;        /* Index into icode array (REG_FRAME only)  */
+    frameType           loc;        /* Frame location                           */
+    boolT               hasMacro;   /* Identifier requires a macro              */
+    char                macro[10];  /* Macro for this identifier                */
+    char                name[20];   /* Identifier's name                        */
+    union {                         /* Different types of identifiers           */
+        byte		regi;       /* For TYPE_BYTE(WORD)_(UN)SIGN registers   */
+        struct {                    /* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */
+            byte	regOff;     /*    register offset (if any)              */
+            Int		off;        /*    offset from BP            		*/
+        }               bwId;
         BWGLB_TYPE	bwGlb;	/* For TYPE_BYTE(WORD)_(UN)SIGN globals		 */
         BWGLB_TYPE	bwGlb;	/* For TYPE_BYTE(WORD)_(UN)SIGN globals		 */
-        LONGID_TYPE longId; /* For TYPE_LONG_(UN)SIGN registers			 */
-        LONG_STKID_TYPE	longStkId;/* For TYPE_LONG_(UN)SIGN on the stack */
+        LONGID_TYPE     longId; /* For TYPE_LONG_(UN)SIGN registers			 */
+        LONG_STKID_TYPE	longStkId;  /* For TYPE_LONG_(UN)SIGN on the stack */
         struct {			/* For TYPE_LONG_(UN)SIGN globals			 */
         struct {			/* For TYPE_LONG_(UN)SIGN globals			 */
-            int16	seg;	/*   segment value							 */
-            int16	offH;	/*   offset high							 */
-            int16	offL;	/*   offset low								 */
-            byte	regi;	/*   optional indexed register				 */
+            int16	seg;	/*   segment value                                              */
+            int16	offH;	/*   offset high                                                */
+            int16	offL;	/*   offset low                                                 */
+            byte	regi;	/*   optional indexed register                                  */
         }			longGlb;
         }			longGlb;
-        struct {			/* For TYPE_LONG_(UN)SIGN constants			 */
+        struct {			/* For TYPE_LONG_(UN)SIGN constants                     */
             dword	h;		/*	 high word								 */
             dword	h;		/*	 high word								 */
             dword 	l;		/*	 low word								 */
             dword 	l;		/*	 low word								 */
-        }			longKte;
-    }				id;
+        } longKte;
+    } id;
     ID()
     ID()
     {
     {
         memset(this,0,sizeof(ID));
         memset(this,0,sizeof(ID));

+ 1 - 1
include/perfhlib.h

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

+ 0 - 31
include/scanner.h

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

+ 4 - 5
src/BasicBlock.cpp

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

File diff suppressed because it is too large
+ 372 - 387
src/ast.cpp


+ 8 - 9
src/backend.cpp

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

+ 10 - 9
src/chklib.cpp

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

+ 14 - 16
src/control.cpp

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

+ 312 - 311
src/dataflow.cpp

@@ -15,11 +15,11 @@ struct ExpStack
     typedef std::list<COND_EXPR *> EXP_STK;
     typedef std::list<COND_EXPR *> EXP_STK;
     EXP_STK expStk;      /* local expression stack */
     EXP_STK expStk;      /* local expression stack */
 
 
-    void	  init();
-    void	  push(COND_EXPR *);
-    COND_EXPR *pop();
-    Int       numElem();
-    boolT	  empty();
+    void        init();
+    void        push(COND_EXPR *);
+    COND_EXPR * pop();
+    Int         numElem();
+    boolT	empty();
 };
 };
 /***************************************************************************
 /***************************************************************************
  * Expression stack functions
  * Expression stack functions
@@ -70,7 +70,8 @@ ExpStack g_exp_stk;
 /* Returns the index of the local variable or parameter at offset off, if it
 /* Returns the index of the local variable or parameter at offset off, if it
  * is in the stack frame provided.  */
  * is in the stack frame provided.  */
 Int STKFRAME::getLocVar(Int off)
 Int STKFRAME::getLocVar(Int off)
-{   Int     i;
+{
+    Int     i;
 
 
     for (i = 0; i < sym.size(); i++)
     for (i = 0; i < sym.size(); i++)
         if (sym[i].off == off)
         if (sym[i].off == off)
@@ -84,16 +85,16 @@ static COND_EXPR *srcIdent (const ICODE &Icode, Function * pProc, Int i, ICODE &
 {
 {
     COND_EXPR *n;
     COND_EXPR *n;
 
 
-     if (Icode.ic.ll.flg & I)   /* immediate operand */
-     {
-         if (Icode.ic.ll.flg & B)
-             n = COND_EXPR::idKte (Icode.ic.ll.immed.op, 1);
-         else
-             n = COND_EXPR::idKte (Icode.ic.ll.immed.op, 2);
-     }
-     else
-         n = COND_EXPR::id (Icode, SRC, pProc, i, duIcode, du);
-      return (n);
+    if (Icode.ic.ll.flg & I)   /* immediate operand */
+    {
+        if (Icode.ic.ll.flg & B)
+            n = COND_EXPR::idKte (Icode.ic.ll.immed.op, 1);
+        else
+            n = COND_EXPR::idKte (Icode.ic.ll.immed.op, 2);
+    }
+    else
+        n = COND_EXPR::id (Icode, SRC, pProc, i, duIcode, du);
+    return (n);
 }
 }
 
 
 
 
@@ -145,35 +146,35 @@ void Function::elimCondCodes ()
                         {
                         {
                             switch (defAt->GetLlOpcode())
                             switch (defAt->GetLlOpcode())
                             {
                             {
-                                case iCMP:
-                                    rhs = srcIdent (*defAt, this, defAt->loc_ip,*useAt, eUSE);
-                                    lhs = dstIdent (*defAt, this, defAt->loc_ip,*useAt, eUSE);
-                                    break;
+                            case iCMP:
+                                rhs = srcIdent (*defAt, this, defAt->loc_ip,*useAt, eUSE);
+                                lhs = dstIdent (*defAt, this, defAt->loc_ip,*useAt, eUSE);
+                                break;
 
 
-                                case iOR:
-                                    lhs = defAt->ic.hl.oper.asgn.lhs->clone();
-                                    useAt->copyDU(*defAt, eUSE, eDEF);
-                                    if (defAt->isLlFlag(B))
-                                        rhs = COND_EXPR::idKte (0, 1);
-                                    else
-                                        rhs = COND_EXPR::idKte (0, 2);
-                                    break;
+                            case iOR:
+                                lhs = defAt->ic.hl.oper.asgn.lhs->clone();
+                                useAt->copyDU(*defAt, eUSE, eDEF);
+                                if (defAt->isLlFlag(B))
+                                    rhs = COND_EXPR::idKte (0, 1);
+                                else
+                                    rhs = COND_EXPR::idKte (0, 2);
+                                break;
 
 
-                                case iTEST:
-                                    rhs = srcIdent (*defAt,this, defAt->loc_ip,*useAt, eUSE);
-                                    lhs = dstIdent (*defAt,this, defAt->loc_ip,*useAt, eUSE);
-                                    lhs = COND_EXPR::boolOp (lhs, rhs, AND);
-                                    if (defAt->isLlFlag(B))
-                                        rhs = COND_EXPR::idKte (0, 1);
-                                    else
-                                        rhs = COND_EXPR::idKte (0, 2);
-                                    break;
+                            case iTEST:
+                                rhs = srcIdent (*defAt,this, defAt->loc_ip,*useAt, eUSE);
+                                lhs = dstIdent (*defAt,this, defAt->loc_ip,*useAt, eUSE);
+                                lhs = COND_EXPR::boolOp (lhs, rhs, AND);
+                                if (defAt->isLlFlag(B))
+                                    rhs = COND_EXPR::idKte (0, 1);
+                                else
+                                    rhs = COND_EXPR::idKte (0, 2);
+                                break;
 
 
-                                default:
-                                    notSup = TRUE;
-                                    std::cout << hex<<defAt->loc_ip;
-                                    reportError (JX_NOT_DEF, defAt->GetLlOpcode());
-                                    flg |= PROC_ASM;		/* generate asm */
+                            default:
+                                notSup = TRUE;
+                                std::cout << hex<<defAt->loc_ip;
+                                reportError (JX_NOT_DEF, defAt->GetLlOpcode());
+                                flg |= PROC_ASM;		/* generate asm */
                             }
                             }
                             if (! notSup)
                             if (! notSup)
                             {
                             {
@@ -326,7 +327,7 @@ void Function::liveRegAnalysis (dword in_liveOut)
                     else    /* library routine */
                     else    /* library routine */
                     {
                     {
                         if ((pcallee->flg & PROC_IS_FUNC) && /* returns a value */
                         if ((pcallee->flg & PROC_IS_FUNC) && /* returns a value */
-                            (pcallee->liveOut & pbb->edges[0].BBptr->liveIn))
+                                (pcallee->liveOut & pbb->edges[0].BBptr->liveIn))
                             pbb->liveOut = pcallee->liveOut;
                             pbb->liveOut = pcallee->liveOut;
                         else
                         else
                             pbb->liveOut = 0;
                             pbb->liveOut = 0;
@@ -335,13 +336,13 @@ void Function::liveRegAnalysis (dword in_liveOut)
                     if ((! (pcallee->flg & PROC_ISLIB)) || (pbb->liveOut != 0))
                     if ((! (pcallee->flg & PROC_ISLIB)) || (pbb->liveOut != 0))
                     {
                     {
                         switch (pcallee->retVal.type) {
                         switch (pcallee->retVal.type) {
-                            case TYPE_LONG_SIGN: case TYPE_LONG_UNSIGN:
-                                ticode.du1.numRegsDef = 2;
-                                break;
-                            case TYPE_WORD_SIGN: case TYPE_WORD_UNSIGN:
-                            case TYPE_BYTE_SIGN: case TYPE_BYTE_UNSIGN:
-                                ticode.du1.numRegsDef = 1;
-                                break;
+                        case TYPE_LONG_SIGN: case TYPE_LONG_UNSIGN:
+                            ticode.du1.numRegsDef = 2;
+                            break;
+                        case TYPE_WORD_SIGN: case TYPE_WORD_UNSIGN:
+                        case TYPE_BYTE_SIGN: case TYPE_BYTE_UNSIGN:
+                            ticode.du1.numRegsDef = 1;
+                            break;
                         } /*eos*/
                         } /*eos*/
 
 
                         /* Propagate def/use results to calling icode */
                         /* Propagate def/use results to calling icode */
@@ -454,7 +455,7 @@ void Function::genDU1 ()
                                      * next basic block (unoptimized code) or somewhere else
                                      * next basic block (unoptimized code) or somewhere else
                                      * on optimized code. */
                                      * on optimized code. */
                     if ((picode->ic.hl.opcode == HLI_CALL) &&
                     if ((picode->ic.hl.opcode == HLI_CALL) &&
-                        (picode->ic.hl.oper.call.proc->flg & PROC_IS_FUNC))
+                            (picode->ic.hl.oper.call.proc->flg & PROC_IS_FUNC))
                     {
                     {
                         tbb = pbb->edges[0].BBptr;
                         tbb = pbb->edges[0].BBptr;
                         useIdx = 0;
                         useIdx = 0;
@@ -476,7 +477,7 @@ void Function::genDU1 ()
                          * register is live out, if so, make it the last
                          * register is live out, if so, make it the last
                          * definition of this register */
                          * definition of this register */
                         if ((picode->du1.idx[defRegIdx][useIdx] == 0) &&
                         if ((picode->du1.idx[defRegIdx][useIdx] == 0) &&
-                            (tbb->liveOut & duReg[regi]))
+                                (tbb->liveOut & duReg[regi]))
                             picode->du.lastDefRegi |= duReg[regi];
                             picode->du.lastDefRegi |= duReg[regi];
                     }
                     }
 
 
@@ -487,11 +488,11 @@ void Function::genDU1 ()
                      * return an integer, which is normally not taken into
                      * return an integer, which is normally not taken into
                      * account by the programmer). 	*/
                      * account by the programmer). 	*/
                     if ((picode->invalid == FALSE) &&
                     if ((picode->invalid == FALSE) &&
-                        (picode->du1.idx[defRegIdx][0] == 0) &&
-                        (! (picode->du.lastDefRegi & duReg[regi])) &&
-                        //						(! ((picode->ic.hl.opcode != HLI_CALL) &&
-                        (! ((picode->ic.hl.opcode == HLI_CALL) &&
-                            (picode->ic.hl.oper.call.proc->flg & PROC_ISLIB))))
+                            (picode->du1.idx[defRegIdx][0] == 0) &&
+                            (! (picode->du.lastDefRegi & duReg[regi])) &&
+                            //						(! ((picode->ic.hl.opcode != HLI_CALL) &&
+                            (! ((picode->ic.hl.opcode == HLI_CALL) &&
+                                (picode->ic.hl.oper.call.proc->flg & PROC_ISLIB))))
                     {
                     {
                         if (! (pbb->liveOut & duReg[regi]))	/* not liveOut */
                         if (! (pbb->liveOut & duReg[regi]))	/* not liveOut */
                         {
                         {
@@ -525,7 +526,7 @@ void Function::genDU1 ()
 
 
                     /* Check if all defined registers have been processed */
                     /* Check if all defined registers have been processed */
                     if ((defRegIdx >= picode->du1.numRegsDef) ||
                     if ((defRegIdx >= picode->du1.numRegsDef) ||
-                        (defRegIdx == MAX_REGS_DEF))
+                            (defRegIdx == MAX_REGS_DEF))
                         break;
                         break;
                 }
                 }
             }
             }
@@ -611,38 +612,38 @@ static boolT xClear (COND_EXPR *rhs, iICODE f, Int t, iICODE lastBBinst, Functio
         return false;
         return false;
 
 
     switch (rhs->type) {
     switch (rhs->type) {
-        case IDENTIFIER:
-            if (rhs->expr.ident.idType == REGISTER)
-            {
-                picode = &pproc->Icode.front();
-                regi= pproc->localId.id_arr[rhs->expr.ident.idNode.regiIdx].id.regi;
-                for (i = (f + 1); (i != lastBBinst) && (i->loc_ip < t); i++)
-                    if ((i->type == HIGH_LEVEL) && (i->invalid == FALSE))
-                    {
-                        if (i->du.def & duReg[regi])
-                            return false;
-                    }
-                if (i != lastBBinst)
-                    return true;
-                return false;
-            }
-            else
+    case IDENTIFIER:
+        if (rhs->expr.ident.idType == REGISTER)
+        {
+            picode = &pproc->Icode.front();
+            regi= pproc->localId.id_arr[rhs->expr.ident.idNode.regiIdx].id.regi;
+            for (i = (f + 1); (i != lastBBinst) && (i->loc_ip < t); i++)
+                if ((i->type == HIGH_LEVEL) && (i->invalid == FALSE))
+                {
+                    if (i->du.def & duReg[regi])
+                        return false;
+                }
+            if (i != lastBBinst)
                 return true;
                 return true;
-            /* else if (rhs->expr.ident.idType == LONG_VAR)
+            return false;
+        }
+        else
+            return true;
+        /* else if (rhs->expr.ident.idType == LONG_VAR)
                         {
                         {
                             missing all other identifiers ****
                             missing all other identifiers ****
                         } */
                         } */
 
 
-        case BOOLEAN_OP:
-            res = xClear (rhs->expr.boolExpr.rhs, f, t, lastBBinst, pproc);
-            if (res == FALSE)
-                return false;
-            return (xClear (rhs->expr.boolExpr.lhs, f, t, lastBBinst, pproc));
+    case BOOLEAN_OP:
+        res = xClear (rhs->expr.boolExpr.rhs, f, t, lastBBinst, pproc);
+        if (res == FALSE)
+            return false;
+        return (xClear (rhs->expr.boolExpr.lhs, f, t, lastBBinst, pproc));
 
 
-        case NEGATION:
-        case ADDRESSOF:
-        case DEREFERENCE:
-            return (xClear (rhs->expr.unaryExp, f, t, lastBBinst, pproc));
+    case NEGATION:
+    case ADDRESSOF:
+    case DEREFERENCE:
+        return (xClear (rhs->expr.unaryExp, f, t, lastBBinst, pproc));
     } /* eos */
     } /* eos */
     return false;
     return false;
 }
 }
@@ -725,7 +726,7 @@ void Function::findExps()
                      * the last definition of the register in this BB, check
                      * the last definition of the register in this BB, check
                      * that it is not liveOut from this basic block */
                      * that it is not liveOut from this basic block */
                     if ((picode->du1.idx[0][0] != 0) &&
                     if ((picode->du1.idx[0][0] != 0) &&
-                        (picode->du1.idx[0][1] == 0))
+                            (picode->du1.idx[0][1] == 0))
                     {
                     {
                         /* Check that this register is not liveOut, if it
                         /* Check that this register is not liveOut, if it
                          * is the last definition of the register */
                          * is the last definition of the register */
@@ -733,134 +734,134 @@ void Function::findExps()
 
 
                         /* Check if we can forward substitute this register */
                         /* Check if we can forward substitute this register */
                         switch (picode->ic.hl.opcode) {
                         switch (picode->ic.hl.opcode) {
-                            case HLI_ASSIGN:
-                                /* Replace rhs of current icode into target
+                        case HLI_ASSIGN:
+                            /* Replace rhs of current icode into target
                              * icode expression */
                              * icode expression */
-                                ticode = Icode.begin()+picode->du1.idx[0][0];
-                                if ((picode->du.lastDefRegi & duReg[regi]) &&
+                            ticode = Icode.begin()+picode->du1.idx[0][0];
+                            if ((picode->du.lastDefRegi & duReg[regi]) &&
                                     ((ticode->ic.hl.opcode != HLI_CALL) &&
                                     ((ticode->ic.hl.opcode != HLI_CALL) &&
                                      (ticode->ic.hl.opcode != HLI_RET)))
                                      (ticode->ic.hl.opcode != HLI_RET)))
-                                    continue;
+                                continue;
 
 
-                                if (xClear (picode->ic.hl.oper.asgn.rhs, picode,
-                                            picode->du1.idx[0][0],  lastInst, this))
-                                {
-                                    switch (ticode->ic.hl.opcode) {
-                                        case HLI_ASSIGN:
-                                            forwardSubs (picode->ic.hl.oper.asgn.lhs,
-                                                         picode->ic.hl.oper.asgn.rhs,
-                                                         &(*picode), &(*ticode), &localId,
-                                                         &numHlIcodes);
-                                            break;
-
-                                        case HLI_JCOND: case HLI_PUSH: case HLI_RET:
-                                            res = insertSubTreeReg (
-                                                      picode->ic.hl.oper.asgn.rhs,
-                                                      &ticode->ic.hl.oper.exp,
-                                                      localId.id_arr[picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.regiIdx].id.regi,
-                                                      &localId);
-                                            if (res)
-                                            {
-                                                picode->invalidate();
-                                                numHlIcodes--;
-                                            }
-                                            break;
-
-                                        case HLI_CALL:    /* register arguments */
-                                            newRegArg (&(*picode), &(*ticode));
-                                            picode->invalidate();
-                                            numHlIcodes--;
-                                            break;
-                                    } /* eos */
-                                }
-                                break;
+                            if (xClear (picode->ic.hl.oper.asgn.rhs, picode,
+                                        picode->du1.idx[0][0],  lastInst, this))
+                            {
+                                switch (ticode->ic.hl.opcode) {
+                                case HLI_ASSIGN:
+                                    forwardSubs (picode->ic.hl.oper.asgn.lhs,
+                                                 picode->ic.hl.oper.asgn.rhs,
+                                                 &(*picode), &(*ticode), &localId,
+                                                 &numHlIcodes);
+                                    break;
 
 
-                            case HLI_POP:
-                                ticode = Icode.begin()+(picode->du1.idx[0][0]);
-                                if ((picode->du.lastDefRegi & duReg[regi]) &&
+                                case HLI_JCOND: case HLI_PUSH: case HLI_RET:
+                                    res = insertSubTreeReg (
+                                                picode->ic.hl.oper.asgn.rhs,
+                                                &ticode->ic.hl.oper.exp,
+                                                localId.id_arr[picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.regiIdx].id.regi,
+                                                &localId);
+                                    if (res)
+                                    {
+                                        picode->invalidate();
+                                        numHlIcodes--;
+                                    }
+                                    break;
+
+                                case HLI_CALL:    /* register arguments */
+                                    newRegArg (&(*picode), &(*ticode));
+                                    picode->invalidate();
+                                    numHlIcodes--;
+                                    break;
+                                } /* eos */
+                            }
+                            break;
+
+                        case HLI_POP:
+                            ticode = Icode.begin()+(picode->du1.idx[0][0]);
+                            if ((picode->du.lastDefRegi & duReg[regi]) &&
                                     ((ticode->ic.hl.opcode != HLI_CALL) &&
                                     ((ticode->ic.hl.opcode != HLI_CALL) &&
                                      (ticode->ic.hl.opcode != HLI_RET)))
                                      (ticode->ic.hl.opcode != HLI_RET)))
-                                    continue;
+                                continue;
 
 
-                                exp = g_exp_stk.pop();  /* pop last exp pushed */
-                                switch (ticode->ic.hl.opcode) {
-                                    case HLI_ASSIGN:
-                                        forwardSubs (picode->ic.hl.oper.exp, exp,
-                                                     &(*picode), &(*ticode), &localId,
-                                                     &numHlIcodes);
-                                        break;
+                            exp = g_exp_stk.pop();  /* pop last exp pushed */
+                            switch (ticode->ic.hl.opcode) {
+                            case HLI_ASSIGN:
+                                forwardSubs (picode->ic.hl.oper.exp, exp,
+                                             &(*picode), &(*ticode), &localId,
+                                             &numHlIcodes);
+                                break;
 
 
-                                    case HLI_JCOND: case HLI_PUSH: case HLI_RET:
-                                        res = insertSubTreeReg (exp,
-                                                                &ticode->ic.hl.oper.exp,
-                                                                localId.id_arr[picode->ic.hl.oper.exp->expr.ident.idNode.regiIdx].id.regi,
-                                                                &localId);
-                                        if (res)
-                                        {
-                                            picode->invalidate();
-                                            numHlIcodes--;
-                                        }
-                                        break;
+                            case HLI_JCOND: case HLI_PUSH: case HLI_RET:
+                                res = insertSubTreeReg (exp,
+                                                        &ticode->ic.hl.oper.exp,
+                                                        localId.id_arr[picode->ic.hl.oper.exp->expr.ident.idNode.regiIdx].id.regi,
+                                                        &localId);
+                                if (res)
+                                {
+                                    picode->invalidate();
+                                    numHlIcodes--;
+                                }
+                                break;
 
 
-                                        /****case HLI_CALL:    /* register arguments
+                                /****case HLI_CALL:    /* register arguments
                                 newRegArg (pProc, picode, ticode);
                                 newRegArg (pProc, picode, ticode);
                                 picode->invalidate();
                                 picode->invalidate();
                                 numHlIcodes--;
                                 numHlIcodes--;
                                 break;	*/
                                 break;	*/
-                                } /* eos */
+                            } /* eos */
+                            break;
+
+                        case HLI_CALL:
+                            ticode = Icode.begin()+(picode->du1.idx[0][0]);
+                            switch (ticode->ic.hl.opcode) {
+                            case HLI_ASSIGN:
+                                exp = COND_EXPR::idFunc (
+                                            picode->ic.hl.oper.call.proc,
+                                            picode->ic.hl.oper.call.args);
+                                res = insertSubTreeReg (exp,
+                                                        &ticode->ic.hl.oper.asgn.rhs,
+                                                        picode->ic.hl.oper.call.proc->retVal.id.regi,
+                                                        &localId);
+                                if (! res)
+                                    insertSubTreeReg (exp,
+                                                      &ticode->ic.hl.oper.asgn.lhs,
+                                                      picode->ic.hl.oper.call.proc->retVal.id.regi,
+                                                      &localId);
+                                /***  HERE missing: 2 regs ****/
+                                picode->invalidate();
+                                numHlIcodes--;
                                 break;
                                 break;
 
 
-                            case HLI_CALL:
-                                ticode = Icode.begin()+(picode->du1.idx[0][0]);
-                                switch (ticode->ic.hl.opcode) {
-                                    case HLI_ASSIGN:
-                                        exp = COND_EXPR::idFunc (
-                                                  picode->ic.hl.oper.call.proc,
-                                                  picode->ic.hl.oper.call.args);
-                                        res = insertSubTreeReg (exp,
-                                                                &ticode->ic.hl.oper.asgn.rhs,
-                                                                picode->ic.hl.oper.call.proc->retVal.id.regi,
-                                                                &localId);
-                                        if (! res)
-                                            insertSubTreeReg (exp,
-                                                              &ticode->ic.hl.oper.asgn.lhs,
-                                                              picode->ic.hl.oper.call.proc->retVal.id.regi,
-                                                              &localId);
-                                        /***  HERE missing: 2 regs ****/
-                                        picode->invalidate();
-                                        numHlIcodes--;
-                                        break;
+                            case HLI_PUSH: case HLI_RET:
+                                exp = COND_EXPR::idFunc (
+                                            picode->ic.hl.oper.call.proc,
+                                            picode->ic.hl.oper.call.args);
+                                ticode->ic.hl.oper.exp = exp;
+                                picode->invalidate();
+                                numHlIcodes--;
+                                break;
 
 
-                                    case HLI_PUSH: case HLI_RET:
-                                        exp = COND_EXPR::idFunc (
-                                                  picode->ic.hl.oper.call.proc,
-                                                  picode->ic.hl.oper.call.args);
-                                        ticode->ic.hl.oper.exp = exp;
-                                        picode->invalidate();
-                                        numHlIcodes--;
-                                        break;
-
-                                    case HLI_JCOND:
-                                        exp = COND_EXPR::idFunc (
-                                                  picode->ic.hl.oper.call.proc,
-                                                  picode->ic.hl.oper.call.args);
-                                        retVal = &picode->ic.hl.oper.call.proc->retVal,
-                                                res = insertSubTreeReg (exp,
-                                                                        &ticode->ic.hl.oper.exp,
-                                                                        retVal->id.regi, &localId);
-                                        if (res)	/* was substituted */
-                                        {
-                                            picode->invalidate();
-                                            numHlIcodes--;
-                                        }
-                                        else	/* cannot substitute function */
-                                        {
-                                            lhs = COND_EXPR::idID(retVal,&localId,picode->loc_ip);
-                                            picode->setAsgn(lhs, exp);
-                                        }
-                                        break;
-                                } /* eos */
+                            case HLI_JCOND:
+                                exp = COND_EXPR::idFunc (
+                                            picode->ic.hl.oper.call.proc,
+                                            picode->ic.hl.oper.call.args);
+                                retVal = &picode->ic.hl.oper.call.proc->retVal,
+                                        res = insertSubTreeReg (exp,
+                                                                &ticode->ic.hl.oper.exp,
+                                                                retVal->id.regi, &localId);
+                                if (res)	/* was substituted */
+                                {
+                                    picode->invalidate();
+                                    numHlIcodes--;
+                                }
+                                else	/* cannot substitute function */
+                                {
+                                    lhs = COND_EXPR::idID(retVal,&localId,picode->loc_ip);
+                                    picode->setAsgn(lhs, exp);
+                                }
                                 break;
                                 break;
+                            } /* eos */
+                            break;
                         } /* eos */
                         } /* eos */
                     }
                     }
                 }
                 }
@@ -869,129 +870,129 @@ void Function::findExps()
                 {
                 {
                     /* Check for only one use of these registers */
                     /* Check for only one use of these registers */
                     if ((picode->du1.idx[0][0] != 0) &&
                     if ((picode->du1.idx[0][0] != 0) &&
-                        (picode->du1.idx[0][1] == 0) &&
-                        (picode->du1.idx[1][0] != 0) &&
-                        (picode->du1.idx[1][1] == 0))
+                            (picode->du1.idx[0][1] == 0) &&
+                            (picode->du1.idx[1][0] != 0) &&
+                            (picode->du1.idx[1][1] == 0))
                     {
                     {
                         switch (picode->ic.hl.opcode) {
                         switch (picode->ic.hl.opcode) {
-                            case HLI_ASSIGN:
-                                /* Replace rhs of current icode into target
+                        case HLI_ASSIGN:
+                            /* Replace rhs of current icode into target
                              * icode expression */
                              * icode expression */
-                                if (picode->du1.idx[0][0] == picode->du1.idx[1][0])
-                                {
-                                    ticode = Icode.begin()+(picode->du1.idx[0][0]);
-                                    if ((picode->du.lastDefRegi & duReg[regi]) &&
+                            if (picode->du1.idx[0][0] == picode->du1.idx[1][0])
+                            {
+                                ticode = Icode.begin()+(picode->du1.idx[0][0]);
+                                if ((picode->du.lastDefRegi & duReg[regi]) &&
                                         ((ticode->ic.hl.opcode != HLI_CALL) &&
                                         ((ticode->ic.hl.opcode != HLI_CALL) &&
                                          (ticode->ic.hl.opcode != HLI_RET)))
                                          (ticode->ic.hl.opcode != HLI_RET)))
-                                        continue;
-
-                                    switch (ticode->ic.hl.opcode) {
-                                        case HLI_ASSIGN:
-                                            forwardSubsLong (picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.longIdx,
-                                                             picode->ic.hl.oper.asgn.rhs, &(*picode),
-                                                             &(*ticode), &numHlIcodes);
-                                            break;
-
-                                        case HLI_JCOND:  case HLI_PUSH:  case HLI_RET:
-                                            res = insertSubTreeLongReg (
-                                                      picode->ic.hl.oper.asgn.rhs,
-                                                      &ticode->ic.hl.oper.exp,
-                                                      picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.longIdx);
-                                            if (res)
-                                            {
-                                                picode->invalidate();
-                                                numHlIcodes--;
-                                            }
-                                            break;
-
-                                        case HLI_CALL:    /* register arguments */
-                                            newRegArg ( &(*picode), &(*ticode));
-                                            picode->invalidate();
-                                            numHlIcodes--;
-                                            break;
-                                    } /* eos */
-                                }
-                                break;
+                                    continue;
 
 
-                            case HLI_POP:
-                                if (picode->du1.idx[0][0] == picode->du1.idx[1][0])
-                                {
-                                    ticode = Icode.begin()+(picode->du1.idx[0][0]);
-                                    if ((picode->du.lastDefRegi & duReg[regi]) &&
-                                        ((ticode->ic.hl.opcode != HLI_CALL) &&
-                                         (ticode->ic.hl.opcode != HLI_RET)))
-                                        continue;
-
-                                    exp = g_exp_stk.pop(); /* pop last exp pushed */
-                                    switch (ticode->ic.hl.opcode) {
-                                        case HLI_ASSIGN:
-                                            forwardSubsLong (picode->ic.hl.oper.exp->expr.ident.idNode.longIdx,
-                                                             exp, &(*picode), &(*ticode), &numHlIcodes);
-                                            break;
-                                        case HLI_JCOND: case HLI_PUSH:
-                                            res = insertSubTreeLongReg (exp,
-                                                                        &ticode->ic.hl.oper.exp,
-                                                                        picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.longIdx);
-                                            if (res)
-                                            {
-                                                picode->invalidate();
-                                                numHlIcodes--;
-                                            }
-                                            break;
-                                        case HLI_CALL:	/*** missing ***/
-                                            break;
-                                    } /* eos */
-                                }
-                                break;
+                                switch (ticode->ic.hl.opcode) {
+                                case HLI_ASSIGN:
+                                    forwardSubsLong (picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.longIdx,
+                                                     picode->ic.hl.oper.asgn.rhs, &(*picode),
+                                                     &(*ticode), &numHlIcodes);
+                                    break;
 
 
-                            case HLI_CALL:    /* check for function return */
-                                ticode = Icode.begin()+(picode->du1.idx[0][0]);
-                                switch (ticode->ic.hl.opcode)
-                                {
-                                    case HLI_ASSIGN:
-                                        exp = COND_EXPR::idFunc (
-                                                  picode->ic.hl.oper.call.proc,
-                                                  picode->ic.hl.oper.call.args);
-                                        ticode->ic.hl.oper.asgn.lhs =
-                                                COND_EXPR::idLong(&localId, DST, ticode,
-                                                              HIGH_FIRST, picode->loc_ip, eDEF, 1);
-                                        ticode->ic.hl.oper.asgn.rhs = exp;
+                                case HLI_JCOND:  case HLI_PUSH:  case HLI_RET:
+                                    res = insertSubTreeLongReg (
+                                                picode->ic.hl.oper.asgn.rhs,
+                                                &ticode->ic.hl.oper.exp,
+                                                picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.longIdx);
+                                    if (res)
+                                    {
                                         picode->invalidate();
                                         picode->invalidate();
                                         numHlIcodes--;
                                         numHlIcodes--;
-                                        break;
+                                    }
+                                    break;
 
 
-                                    case HLI_PUSH:  case HLI_RET:
-                                        exp = COND_EXPR::idFunc (
-                                                  picode->ic.hl.oper.call.proc,
-                                                  picode->ic.hl.oper.call.args);
-                                        ticode->ic.hl.oper.exp = exp;
+                                case HLI_CALL:    /* register arguments */
+                                    newRegArg ( &(*picode), &(*ticode));
+                                    picode->invalidate();
+                                    numHlIcodes--;
+                                    break;
+                                } /* eos */
+                            }
+                            break;
+
+                        case HLI_POP:
+                            if (picode->du1.idx[0][0] == picode->du1.idx[1][0])
+                            {
+                                ticode = Icode.begin()+(picode->du1.idx[0][0]);
+                                if ((picode->du.lastDefRegi & duReg[regi]) &&
+                                        ((ticode->ic.hl.opcode != HLI_CALL) &&
+                                         (ticode->ic.hl.opcode != HLI_RET)))
+                                    continue;
+
+                                exp = g_exp_stk.pop(); /* pop last exp pushed */
+                                switch (ticode->ic.hl.opcode) {
+                                case HLI_ASSIGN:
+                                    forwardSubsLong (picode->ic.hl.oper.exp->expr.ident.idNode.longIdx,
+                                                     exp, &(*picode), &(*ticode), &numHlIcodes);
+                                    break;
+                                case HLI_JCOND: case HLI_PUSH:
+                                    res = insertSubTreeLongReg (exp,
+                                                                &ticode->ic.hl.oper.exp,
+                                                                picode->ic.hl.oper.asgn.lhs->expr.ident.idNode.longIdx);
+                                    if (res)
+                                    {
                                         picode->invalidate();
                                         picode->invalidate();
                                         numHlIcodes--;
                                         numHlIcodes--;
-                                        break;
-
-                                    case HLI_JCOND:
-                                        exp = COND_EXPR::idFunc (
-                                                  picode->ic.hl.oper.call.proc,
-                                                  picode->ic.hl.oper.call.args);
-                                        retVal = &picode->ic.hl.oper.call.proc->retVal;
-                                        res = insertSubTreeLongReg (exp,
-                                                                    &ticode->ic.hl.oper.exp,
-                                                                    localId.newLongReg
-                                                                    (
-                                                                        retVal->type, retVal->id.longId.h,
-                                                                        retVal->id.longId.l, picode->loc_ip));
-                                        if (res)	/* was substituted */
-                                        {
-                                            picode->invalidate();
-                                            numHlIcodes--;
-                                        }
-                                        else	/* cannot substitute function */
-                                        {
-                                            lhs = COND_EXPR::idID(retVal,&localId,picode->loc_ip);
-                                            picode->setAsgn(lhs, exp);
-                                        }
-                                        break;
+                                    }
+                                    break;
+                                case HLI_CALL:	/*** missing ***/
+                                    break;
                                 } /* eos */
                                 } /* eos */
+                            }
+                            break;
+
+                        case HLI_CALL:    /* check for function return */
+                            ticode = Icode.begin()+(picode->du1.idx[0][0]);
+                            switch (ticode->ic.hl.opcode)
+                            {
+                            case HLI_ASSIGN:
+                                exp = COND_EXPR::idFunc (
+                                            picode->ic.hl.oper.call.proc,
+                                            picode->ic.hl.oper.call.args);
+                                ticode->ic.hl.oper.asgn.lhs =
+                                        COND_EXPR::idLong(&localId, DST, ticode,
+                                                          HIGH_FIRST, picode->loc_ip, eDEF, 1);
+                                ticode->ic.hl.oper.asgn.rhs = exp;
+                                picode->invalidate();
+                                numHlIcodes--;
+                                break;
+
+                            case HLI_PUSH:  case HLI_RET:
+                                exp = COND_EXPR::idFunc (
+                                            picode->ic.hl.oper.call.proc,
+                                            picode->ic.hl.oper.call.args);
+                                ticode->ic.hl.oper.exp = exp;
+                                picode->invalidate();
+                                numHlIcodes--;
+                                break;
+
+                            case HLI_JCOND:
+                                exp = COND_EXPR::idFunc (
+                                            picode->ic.hl.oper.call.proc,
+                                            picode->ic.hl.oper.call.args);
+                                retVal = &picode->ic.hl.oper.call.proc->retVal;
+                                res = insertSubTreeLongReg (exp,
+                                                            &ticode->ic.hl.oper.exp,
+                                                            localId.newLongReg
+                                                            (
+                                                                retVal->type, retVal->id.longId.h,
+                                                                retVal->id.longId.l, picode->loc_ip));
+                                if (res)	/* was substituted */
+                                {
+                                    picode->invalidate();
+                                    numHlIcodes--;
+                                }
+                                else	/* cannot substitute function */
+                                {
+                                    lhs = COND_EXPR::idID(retVal,&localId,picode->loc_ip);
+                                    picode->setAsgn(lhs, exp);
+                                }
+                                break;
+                            } /* eos */
                         } /* eos */
                         } /* eos */
                     }
                     }
                 }
                 }
@@ -1010,7 +1011,7 @@ void Function::findExps()
                                  * pop them from the expression stack and place them on the
                                  * pop them from the expression stack and place them on the
                                  * procedure's argument list */
                                  * procedure's argument list */
                 if ((picode->ic.hl.opcode == HLI_CALL) &&
                 if ((picode->ic.hl.opcode == HLI_CALL) &&
-                    ! (picode->ic.hl.oper.call.proc->flg & REG_ARGS))
+                        ! (picode->ic.hl.oper.call.proc->flg & REG_ARGS))
                 { Function * pp;
                 { Function * pp;
                     Int cb, numArgs;
                     Int cb, numArgs;
                     boolT res;
                     boolT res;
@@ -1057,14 +1058,14 @@ void Function::findExps()
                 /* If we could not substitute the result of a function,
                 /* If we could not substitute the result of a function,
                                  * assign it to the corresponding registers */
                                  * assign it to the corresponding registers */
                 if ((picode->ic.hl.opcode == HLI_CALL) &&
                 if ((picode->ic.hl.opcode == HLI_CALL) &&
-                    ((picode->ic.hl.oper.call.proc->flg & PROC_ISLIB) !=
-                     PROC_ISLIB) && (picode->du1.idx[0][0] == 0) &&
-                    (picode->du1.numRegsDef > 0))
+                        ((picode->ic.hl.oper.call.proc->flg & PROC_ISLIB) !=
+                         PROC_ISLIB) && (picode->du1.idx[0][0] == 0) &&
+                        (picode->du1.numRegsDef > 0))
                 {
                 {
                     exp = COND_EXPR::idFunc (picode->ic.hl.oper.call.proc,
                     exp = COND_EXPR::idFunc (picode->ic.hl.oper.call.proc,
-                                         picode->ic.hl.oper.call.args);
+                                             picode->ic.hl.oper.call.args);
                     lhs = COND_EXPR::idID (&picode->ic.hl.oper.call.proc->retVal,
                     lhs = COND_EXPR::idID (&picode->ic.hl.oper.call.proc->retVal,
-                                       &localId, picode->loc_ip);
+                                           &localId, picode->loc_ip);
                     picode->setAsgn(lhs, exp);
                     picode->setAsgn(lhs, exp);
                 }
                 }
             }
             }

+ 2 - 2
src/dcc.cpp

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

+ 1 - 1
src/disassem.cpp

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

+ 2 - 2
src/error.cpp

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

+ 55 - 84
src/frontend.cpp

@@ -1,8 +1,8 @@
 /*****************************************************************************
 /*****************************************************************************
- *			dcc project Front End module
- * Loads a program into simulated main memory and builds the procedure list.
- * (C) Cristina Cifuentes
- ****************************************************************************/
+*			dcc project Front End module
+* Loads a program into simulated main memory and builds the procedure list.
+* (C) Cristina Cifuentes
+****************************************************************************/
 
 
 #include "dcc.h"
 #include "dcc.h"
 #include <stdio.h>
 #include <stdio.h>
@@ -58,9 +58,9 @@ static void displayLoadInfo(void);
 static void displayMemMap(void);
 static void displayMemMap(void);
 
 
 /*****************************************************************************
 /*****************************************************************************
- * FrontEnd - invokes the loader, parser, disassembler (if asm1), icode
- * rewritter, and displays any useful information.
- ****************************************************************************/
+* FrontEnd - invokes the loader, parser, disassembler (if asm1), icode
+* rewritter, and displays any useful information.
+****************************************************************************/
 void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
 void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
 {
 {
     /* Load program into memory */
     /* Load program into memory */
@@ -70,7 +70,7 @@ void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
         displayLoadInfo();
         displayLoadInfo();
 
 
     /* Do depth first flow analysis building call graph and procedure list,
     /* Do depth first flow analysis building call graph and procedure list,
-         * and attaching the I-code to each procedure          */
+* and attaching the I-code to each procedure          */
     parse (pcallGraph);
     parse (pcallGraph);
 
 
     if (option.asm1)
     if (option.asm1)
@@ -79,29 +79,30 @@ void FrontEnd (char *filename, CALL_GRAPH * *pcallGraph)
     }
     }
 
 
     /* Search through code looking for impure references and flag them */
     /* Search through code looking for impure references and flag them */
-    std::for_each(pProcList.begin(),pProcList.end(),
-                  [](Function &f)->void {
-                  f.markImpure();
-            if (option.asm1)
-            disassem(1, &f); });
-if (option.Interact)
-{
-    interactDis(&pProcList.front(), 0);			/* Interactive disassembler */
-}
+    for(Function &f : pProcList)
+    {
+        f.markImpure();
+        if (option.asm1)
+            disassem(1, &f);
+    }
+    if (option.Interact)
+    {
+        interactDis(&pProcList.front(), 0);     /* Interactive disassembler */
+    }
 
 
-/* Converts jump target addresses to icode offsets */
-std::for_each(pProcList.begin(),pProcList.end(),
-              [](Function &f)->void { f.bindIcodeOff(); });
+    /* Converts jump target addresses to icode offsets */
+    for(Function &f : pProcList)
+        f.bindIcodeOff();
 
 
-/* Print memory bitmap */
-if (option.Map)
-displayMemMap();
+    /* Print memory bitmap */
+    if (option.Map)
+        displayMemMap();
 }
 }
 
 
 
 
 /****************************************************************************
 /****************************************************************************
- * displayLoadInfo - Displays low level loader type info.
- ***************************************************************************/
+* displayLoadInfo - Displays low level loader type info.
+***************************************************************************/
 static void displayLoadInfo(void)
 static void displayLoadInfo(void)
 {
 {
     Int	i;
     Int	i;
@@ -133,8 +134,8 @@ static void displayLoadInfo(void)
 
 
 
 
 /*****************************************************************************
 /*****************************************************************************
- * fill - Fills line for displayMemMap()
- ****************************************************************************/
+* fill - Fills line for displayMemMap()
+****************************************************************************/
 static void fill(Int ip, char *bf)
 static void fill(Int ip, char *bf)
 {
 {
     static byte type[4] = {'.', 'd', 'c', 'x'};
     static byte type[4] = {'.', 'd', 'c', 'x'};
@@ -151,8 +152,8 @@ static void fill(Int ip, char *bf)
 
 
 
 
 /*****************************************************************************
 /*****************************************************************************
- * displayMemMap - Displays the memory bitmap
- ****************************************************************************/
+* displayMemMap - Displays the memory bitmap
+****************************************************************************/
 static void displayMemMap(void)
 static void displayMemMap(void)
 {
 {
     char	c, b1[33], b2[33], b3[33];
     char	c, b1[33], b2[33], b3[33];
@@ -187,8 +188,8 @@ static void displayMemMap(void)
 
 
 
 
 /*****************************************************************************
 /*****************************************************************************
- * LoadImage
- ****************************************************************************/
+* LoadImage
+****************************************************************************/
 static void LoadImage(char *filename)
 static void LoadImage(char *filename)
 {
 {
     FILE   *fp;
     FILE   *fp;
@@ -222,10 +223,10 @@ static void LoadImage(char *filename)
         }
         }
 
 
         /* Calculate the load module size.
         /* Calculate the load module size.
-                 * This is the number of pages in the file
-                 * less the length of the header and reloc table
-                 * less the number of bytes unused on last page
-                */
+* This is the number of pages in the file
+* less the length of the header and reloc table
+* less the number of bytes unused on last page
+*/
         cb = (dword)LH(&header.numPages) * 512 - (dword)LH(&header.numParaHeader) * 16;
         cb = (dword)LH(&header.numPages) * 512 - (dword)LH(&header.numParaHeader) * 16;
         if (header.lastPageSize)
         if (header.lastPageSize)
         {
         {
@@ -233,13 +234,13 @@ static void LoadImage(char *filename)
         }
         }
 
 
         /* We quietly ignore minAlloc and maxAlloc since for our
         /* We quietly ignore minAlloc and maxAlloc since for our
-                 * purposes it doesn't really matter where in real memory
-                 * the program would end up.  EXE programs can't really rely on
-                 * their load location so setting the PSP segment to 0 is fine.
-                 * Certainly programs that prod around in DOS or BIOS are going
-                 * to have to load DS from a constant so it'll be pretty
-                 * obvious.
-                */
+* purposes it doesn't really matter where in real memory
+* the program would end up.  EXE programs can't really rely on
+* their load location so setting the PSP segment to 0 is fine.
+* Certainly programs that prod around in DOS or BIOS are going
+* to have to load DS from a constant so it'll be pretty
+* obvious.
+*/
         prog.initCS = (int16)LH(&header.initCS) + EXE_RELOCATION;
         prog.initCS = (int16)LH(&header.initCS) + EXE_RELOCATION;
         prog.initIP = (int16)LH(&header.initIP);
         prog.initIP = (int16)LH(&header.initIP);
         prog.initSS = (int16)LH(&header.initSS) + EXE_RELOCATION;
         prog.initSS = (int16)LH(&header.initSS) + EXE_RELOCATION;
@@ -249,7 +250,7 @@ static void LoadImage(char *filename)
         /* Allocate the relocation table */
         /* Allocate the relocation table */
         if (prog.cReloc)
         if (prog.cReloc)
         {
         {
-            prog.relocTable = (dword*)allocMem(prog.cReloc * sizeof(Int));
+            prog.relocTable = new dword [prog.cReloc];
             fseek(fp, LH(&header.relocTabOffset), SEEK_SET);
             fseek(fp, LH(&header.relocTabOffset), SEEK_SET);
 
 
             /* Read in seg:offset pairs and convert to Image ptrs */
             /* Read in seg:offset pairs and convert to Image ptrs */
@@ -265,15 +266,15 @@ static void LoadImage(char *filename)
     }
     }
     else
     else
     {	/* COM file
     {	/* COM file
-                 * In this case the load module size is just the file length
-                */
+         * In this case the load module size is just the file length
+         */
         fseek(fp, 0, SEEK_END);
         fseek(fp, 0, SEEK_END);
         cb = ftell(fp);
         cb = ftell(fp);
 
 
         /* COM programs start off with an ORG 100H (to leave room for a PSP)
         /* COM programs start off with an ORG 100H (to leave room for a PSP)
-                 * This is also the implied start address so if we load the image
-                 * at offset 100H addresses should all line up properly again.
-                */
+         * This is also the implied start address so if we load the image
+         * at offset 100H addresses should all line up properly again.
+         */
         prog.initCS = 0;
         prog.initCS = 0;
         prog.initIP = 0x100;
         prog.initIP = 0x100;
         prog.initSS = 0;
         prog.initSS = 0;
@@ -285,7 +286,7 @@ static void LoadImage(char *filename)
 
 
     /* Allocate a block of memory for the program. */
     /* Allocate a block of memory for the program. */
     prog.cbImage  = cb + sizeof(PSP);
     prog.cbImage  = cb + sizeof(PSP);
-    prog.Image    = (byte*)allocMem(prog.cbImage);
+    prog.Image    = new byte [prog.cbImage];
     prog.Image[0] = 0xCD;		/* Fill in PSP Int 20h location */
     prog.Image[0] = 0xCD;		/* Fill in PSP Int 20h location */
     prog.Image[1] = 0x20;		/* for termination checking     */
     prog.Image[1] = 0x20;		/* for termination checking     */
 
 
@@ -304,7 +305,8 @@ static void LoadImage(char *filename)
 
 
     /* Set up memory map */
     /* Set up memory map */
     cb = (prog.cbImage + 3) / 4;
     cb = (prog.cbImage + 3) / 4;
-    prog.map = (byte *)memset(allocMem(cb), BM_UNKNOWN, (size_t)cb);
+    prog.map = (byte *)malloc(cb);
+    memset(prog.map, BM_UNKNOWN, (size_t)cb);
 
 
     /* Relocate segment constants */
     /* Relocate segment constants */
     if (prog.cReloc)
     if (prog.cReloc)
@@ -323,8 +325,8 @@ static void LoadImage(char *filename)
 
 
 
 
 /*****************************************************************************
 /*****************************************************************************
- * allocMem - malloc with failure test
- ****************************************************************************/
+* allocMem - malloc with failure test
+****************************************************************************/
 void *allocMem(Int cb)
 void *allocMem(Int cb)
 {
 {
     byte *p;
     byte *p;
@@ -336,37 +338,6 @@ void *allocMem(Int cb)
     {
     {
         fatalError(MALLOC_FAILED, cb);
         fatalError(MALLOC_FAILED, cb);
     }
     }
-    /*printf("allocMem: %p\n", p);/**/
+    // printf("allocMem: %p\n", p);
     return p;
     return p;
 }
 }
-
-
-/*****************************************************************************
- * reallocVar - reallocs extra variable space
- ****************************************************************************/
-void *reallocVar(void *p, Int newsize)
-{
-    /*printf("Attempt to reallocVar %5d bytes\n", newsize);/**/
-    if (! (p = realloc((byte *)p, (size_t)newsize)))
-    {
-        fatalError(MALLOC_FAILED, newsize);
-    }
-
-    /*printf("reallocVar: %p\n", p);/**/
-    return p;
-}
-
-#if 0
-void free(void *p)
-{
-    _ffree(p);
-    switch (_heapset('Z'))
-    {
-        case _HEAPBADBEGIN: printf("f: Bad heap begin\n"); getchar(); break;
-        case _HEAPBADNODE:	printf("f: Bad heap node\n");  getchar(); break;
-        case _HEAPEMPTY:	printf("f: Heap empty\n");		getchar(); break;
-        case _HEAPOK:putchar('!');break;
-    }/**/
-}
-#endif
-

+ 5 - 5
src/graph.cpp

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

+ 14 - 7
src/hlicode.cpp

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

+ 3 - 2
src/icode.cpp

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

+ 8 - 8
src/idioms.cpp

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

+ 8 - 8
src/parser.cpp

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

+ 38 - 38
src/procs.cpp

@@ -30,10 +30,9 @@ void CALL_GRAPH::insertArc (ilFunction newProc)
     Int i;
     Int i;
 
 
     /* Check if procedure already exists */
     /* Check if procedure already exists */
-    for (i = 0;  i < outEdges.size(); i++)
-        if (outEdges[i]->proc == newProc)
-            return;
-
+    auto res=std::find_if(outEdges.begin(),outEdges.end(),[newProc](CALL_GRAPH *e) {return e->proc==newProc;});
+    if(res!=outEdges.end())
+        return;
     /* Include new arc */
     /* Include new arc */
     pcg = new CALL_GRAPH;
     pcg = new CALL_GRAPH;
     pcg->proc = newProc;
     pcg->proc = newProc;
@@ -231,7 +230,7 @@ void allocStkArgs (ICODE *picode, Int num)
  *			FALSE elsewhere	*/
  *			FALSE elsewhere	*/
 boolT newStkArg (ICODE *picode, COND_EXPR *exp, llIcode opcode, Function * pproc)
 boolT newStkArg (ICODE *picode, COND_EXPR *exp, llIcode opcode, Function * pproc)
 {
 {
-	STKFRAME * ps;
+    STKFRAME * ps;
     byte regi;
     byte regi;
 
 
     /* Check for far procedure call, in which case, references to segment
     /* Check for far procedure call, in which case, references to segment
@@ -275,52 +274,53 @@ void placeStkArg (ICODE *picode, COND_EXPR *exp, Int pos)
  * same type as the given type (from the procedure's formal list).  If not,
  * same type as the given type (from the procedure's formal list).  If not,
  * the actual argument gets modified */
  * the actual argument gets modified */
 void adjustActArgType (COND_EXPR *exp, hlType forType, Function * pproc)
 void adjustActArgType (COND_EXPR *exp, hlType forType, Function * pproc)
-{ hlType actType;
+{
+    hlType actType;
     Int offset, offL;
     Int offset, offL;
 
 
     if (exp == NULL)
     if (exp == NULL)
         return;
         return;
 
 
     actType = expType (exp, pproc);
     actType = expType (exp, pproc);
-    if ((actType != forType) && (exp->type == IDENTIFIER))
+    if (((actType == forType) || (exp->type != IDENTIFIER)))
+        return;
+    switch (forType)
     {
     {
-        switch (forType) {
-            case TYPE_UNKNOWN: case TYPE_BYTE_SIGN:
-            case TYPE_BYTE_UNSIGN: case TYPE_WORD_SIGN:
-            case TYPE_WORD_UNSIGN: case TYPE_LONG_SIGN:
-            case TYPE_LONG_UNSIGN: case TYPE_RECORD:
-                break;
+        case TYPE_UNKNOWN: case TYPE_BYTE_SIGN:
+        case TYPE_BYTE_UNSIGN: case TYPE_WORD_SIGN:
+        case TYPE_WORD_UNSIGN: case TYPE_LONG_SIGN:
+        case TYPE_LONG_UNSIGN: case TYPE_RECORD:
+            break;
 
 
-            case TYPE_PTR:
-            case TYPE_CONST:
-                break;
+        case TYPE_PTR:
+        case TYPE_CONST:
+            break;
 
 
-            case TYPE_STR:
-                switch (actType) {
-                    case TYPE_CONST:
-                        /* It's an offset into image where a string is
+        case TYPE_STR:
+            switch (actType) {
+                case TYPE_CONST:
+                    /* It's an offset into image where a string is
                                          * found.  Point to the string.	*/
                                          * found.  Point to the string.	*/
-                        offL = exp->expr.ident.idNode.kte.kte;
-                        if (prog.fCOM)
-                            offset = (pproc->state.r[rDS]<<4) + offL + 0x100;
-                        else
-                            offset = (pproc->state.r[rDS]<<4) + offL;
-                        exp->expr.ident.idNode.strIdx = offset;
-                        exp->expr.ident.idType = STRING;
-                        break;
-
-                    case TYPE_PTR:
-                        /* It's a pointer to a char rather than a pointer to
+                    offL = exp->expr.ident.idNode.kte.kte;
+                    if (prog.fCOM)
+                        offset = (pproc->state.r[rDS]<<4) + offL + 0x100;
+                    else
+                        offset = (pproc->state.r[rDS]<<4) + offL;
+                    exp->expr.ident.idNode.strIdx = offset;
+                    exp->expr.ident.idType = STRING;
+                    break;
+
+                case TYPE_PTR:
+                    /* It's a pointer to a char rather than a pointer to
                                          * an integer */
                                          * an integer */
-                        /***HERE - modify the type ****/
-                        break;
+                    /***HERE - modify the type ****/
+                    break;
 
 
-                    case TYPE_WORD_SIGN:
+                case TYPE_WORD_SIGN:
 
 
-                        break;
-                } /* eos */
-                break;
-        }
+                    break;
+            } /* eos */
+            break;
     }
     }
 }
 }
 
 

+ 211 - 131
src/proplong.cpp

@@ -24,7 +24,7 @@ static boolT isJCond (llIcode opcode)
 /* Returns whether the conditions for a 2-3 long variable are satisfied */
 /* Returns whether the conditions for a 2-3 long variable are satisfied */
 static boolT isLong23 (Int i, BB * pbb, Int *off, Int *arc)
 static boolT isLong23 (Int i, BB * pbb, Int *off, Int *arc)
 {
 {
- BB * t, * e, * obb2;
+    BB * t, * e, * obb2;
 
 
     if (pbb->nodeType != TWO_BRANCH)
     if (pbb->nodeType != TWO_BRANCH)
         return false;
         return false;
@@ -94,68 +94,68 @@ static void longJCond23 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode,
         /* Modify in edges of target basic block */
         /* Modify in edges of target basic block */
         auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
         auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
                                     [obb1,obb2](BB *b) -> bool
                                     [obb1,obb2](BB *b) -> bool
-                                    {
-                                        return (b==obb1) || (b==obb2);
-                                    }
-                                    );
-        tbb->inEdges.erase(newlast,tbb->inEdges.end());
-        tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
-
-        /* Modify in edges of the ELSE basic block */
-        tbb = pbb->edges[ELSE].BBptr;
-        auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
-        assert(iter!=tbb->inEdges.end());
-        tbb->inEdges.erase(iter); /* looses 1 arc */
-        /* Update icode index */
-        (*idx) += 5;
+        {
+                                    return (b==obb1) || (b==obb2);
     }
     }
+    );
+    tbb->inEdges.erase(newlast,tbb->inEdges.end());
+    tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
+
+    /* Modify in edges of the ELSE basic block */
+    tbb = pbb->edges[ELSE].BBptr;
+    auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
+    assert(iter!=tbb->inEdges.end());
+    tbb->inEdges.erase(iter); /* looses 1 arc */
+    /* Update icode index */
+    (*idx) += 5;
+}
 
 
-    else  /* ELSE arc */
-    {
-        /* Find intermediate basic blocks and target block */
-        pbb = pIcode->inBB;
-        obb1 = pbb->edges[ELSE].BBptr;
-        obb2 = obb1->edges[THEN].BBptr;
-        tbb = obb2->edges[THEN].BBptr;
-
-        /* Modify in edges of target basic block */
-        auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
-        assert(iter!=tbb->inEdges.end());
-        tbb->inEdges.erase(iter); /* looses 1 arc */
-
-        /* Modify in edges of the ELSE basic block */
-        tbb = obb2->edges[ELSE].BBptr;
-        auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
-                                    [obb1,obb2](BB *b) -> bool
-                                    {
-                                        return (b==obb1) || (b==obb2);
-                                    }
-                                    );
-        tbb->inEdges.erase(newlast,tbb->inEdges.end());
-        tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
-
-        /* Modify out edge of header basic block */
-        pbb->edges[ELSE].BBptr = tbb;
+else  /* ELSE arc */
+{
+/* Find intermediate basic blocks and target block */
+pbb = pIcode->inBB;
+obb1 = pbb->edges[ELSE].BBptr;
+obb2 = obb1->edges[THEN].BBptr;
+tbb = obb2->edges[THEN].BBptr;
+
+/* Modify in edges of target basic block */
+auto iter=std::find(tbb->inEdges.begin(),tbb->inEdges.end(),obb2);
+assert(iter!=tbb->inEdges.end());
+tbb->inEdges.erase(iter); /* looses 1 arc */
+
+/* Modify in edges of the ELSE basic block */
+tbb = obb2->edges[ELSE].BBptr;
+auto newlast=std::remove_if(tbb->inEdges.begin(),tbb->inEdges.end(),
+                            [obb1,obb2](BB *b) -> bool
+{
+                            return (b==obb1) || (b==obb2);
+        }
+);
+tbb->inEdges.erase(newlast,tbb->inEdges.end());
+tbb->inEdges.push_back(pbb); /* looses 2 arcs, gains 1 arc */
 
 
-        /* Update icode index */
-        (*idx) += 2;
-    }
+/* Modify out edge of header basic block */
+pbb->edges[ELSE].BBptr = tbb;
 
 
-    /* Create new HLI_JCOND and condition */
-    lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[(pIcode+off+1)->ic.ll.opcode-iJB]);
-    (pIcode+1)->setJCond(lhs);
-    (pIcode+1)->copyDU(*pIcode, eUSE, eUSE);
-    (pIcode+1)->du.use |= (pIcode+off)->du.use;
-
-    /* Update statistics */
-    obb1->flg |= INVALID_BB;
-    obb2->flg |= INVALID_BB;
-    stats.numBBaft -= 2;
+/* Update icode index */
+(*idx) += 2;
+}
 
 
-    pIcode->invalidate();
-    obb1->front().invalidate();
-    obb2->front().invalidate();
-    (obb2->begin2()+1)->invalidate();
+/* Create new HLI_JCOND and condition */
+lhs = COND_EXPR::boolOp (lhs, rhs, condOpJCond[(pIcode+off+1)->ic.ll.opcode-iJB]);
+(pIcode+1)->setJCond(lhs);
+(pIcode+1)->copyDU(*pIcode, eUSE, eUSE);
+(pIcode+1)->du.use |= (pIcode+off)->du.use;
+
+/* Update statistics */
+obb1->flg |= INVALID_BB;
+obb2->flg |= INVALID_BB;
+stats.numBBaft -= 2;
+
+pIcode->invalidate();
+obb1->front().invalidate();
+obb2->front().invalidate();
+(obb2->begin2()+1)->invalidate();
 }
 }
 
 
 
 
@@ -201,8 +201,8 @@ static void longJCond22 (COND_EXPR *rhs, COND_EXPR *lhs, iICODE pIcode, Int *idx
         tbb->inEdges.erase(iter);
         tbb->inEdges.erase(iter);
         if ((pIcode+3)->ic.ll.opcode == iJE)	/* replace */
         if ((pIcode+3)->ic.ll.opcode == iJE)	/* replace */
             tbb->inEdges.push_back(pbb);
             tbb->inEdges.push_back(pbb);
-//        else
-//            tbb->numInEdges--;		/* iJNE => looses 1 arc */
+        //        else
+        //            tbb->numInEdges--;		/* iJNE => looses 1 arc */
 
 
 
 
         /* Update statistics */
         /* Update statistics */
@@ -237,7 +237,8 @@ void Function::propLongStk (Int i, ID *pLocId)
 
 
         if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
         if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
         {
         {
-            switch (pIcode->ic.ll.opcode) {
+            switch (pIcode->ic.ll.opcode)
+            {
                 case iMOV:
                 case iMOV:
                     if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
                     if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
                                      &rhs, &lhs, 1) == TRUE)
                                      &rhs, &lhs, 1) == TRUE)
@@ -252,7 +253,8 @@ void Function::propLongStk (Int i, ID *pLocId)
                     if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
                     if (checkLongEq (pLocId->id.longStkId, pIcode, i, idx, this,
                                      &rhs, &lhs, 1) == TRUE)
                                      &rhs, &lhs, 1) == TRUE)
                     {
                     {
-                        switch (pIcode->ic.ll.opcode) {
+                        switch (pIcode->ic.ll.opcode)
+                        {
                             case iAND: 	rhs = COND_EXPR::boolOp (lhs, rhs, AND);
                             case iAND: 	rhs = COND_EXPR::boolOp (lhs, rhs, AND);
                                 break;
                                 break;
                             case iOR: 	rhs = COND_EXPR::boolOp (lhs, rhs, OR);
                             case iOR: 	rhs = COND_EXPR::boolOp (lhs, rhs, OR);
@@ -296,94 +298,172 @@ void Function::propLongStk (Int i, ID *pLocId)
         }
         }
     }
     }
 }
 }
-
+void checkBack();
+//int     Function::checkBackwarLongDefs(int loc_ident_idx, ID *pLocId, int pLocId_idx)
+//{
+//    int idx;
+//    for (idx = pLocId_idx - 1; idx > 0 ; idx--)
+//    {
+//        pIcode = Icode.begin()+(idx-1);
+//        if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
+//            continue;
+
+//        if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode)
+//            continue;
+//        switch (pIcode->ic.ll.opcode)
+//        {
+//            case iMOV:
+//                pmH = &pIcode->ic.ll.dst;
+//                pmL = &(pIcode+1)->ic.ll.dst;
+//                if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
+//                {
+//                    lhs = COND_EXPR::idLongIdx (i);
+//                    this->localId.id_arr[i].idx.push_back(idx-1);
+//                    pIcode->setRegDU( pmL->regi, eDEF);
+//                    rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
+//                    pIcode->setAsgn(lhs, rhs);
+//                    (pIcode+1)->invalidate();
+//                    idx = 0;    /* to exit the loop */
+//                }
+//                break;
+
+//            case iPOP:
+//                pmH = &(pIcode+1)->ic.ll.dst;
+//                pmL = &pIcode->ic.ll.dst;
+//                if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
+//                {
+//                    lhs = COND_EXPR::idLongIdx (i);
+//                    pIcode->setRegDU( pmH->regi, eDEF);
+//                    pIcode->setUnary(HLI_POP, lhs);
+//                    (pIcode+1)->invalidate();
+//                    idx = 0;        /* to exit the loop */
+//                }
+//                break;
+
+//                /**** others missing ***/
+
+//            case iAND: case iOR: case iXOR:
+//                pmL = &pIcode->ic.ll.dst;
+//                pmH = &(pIcode+1)->ic.ll.dst;
+//                if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
+//                {
+//                    lhs = COND_EXPR::idLongIdx (i);
+//                    pIcode->setRegDU( pmH->regi, USE_DEF);
+//                    rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
+//                    switch (pIcode->ic.ll.opcode) {
+//                        case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
+//                            break;
+//                        case iOR:
+//                            rhs = COND_EXPR::boolOp (lhs, rhs, OR);
+//                            break;
+//                        case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
+//                            break;
+//                    } /* eos */
+//                    pIcode->setAsgn(lhs, rhs);
+//                    (pIcode+1)->invalidate();
+//                    idx = 0;
+//                }
+//                break;
+//        } /* eos */
+//    }
+//}
 
 
 /* Finds the definition of the long register pointed to by pLocId, and
 /* Finds the definition of the long register pointed to by pLocId, and
  * transforms that instruction into a HIGH_LEVEL icode instruction.
  * transforms that instruction into a HIGH_LEVEL icode instruction.
  * Arguments: i     : index into the local identifier table
  * Arguments: i     : index into the local identifier table
  *            pLocId: ptr to the long local identifier
  *            pLocId: ptr to the long local identifier
  *            pProc : ptr to current procedure's record.        */
  *            pProc : ptr to current procedure's record.        */
-void Function::propLongReg (Int i, ID *pLocId)
+void Function::propLongReg (Int loc_ident_idx, ID *pLocId)
 {
 {
-    COND_EXPR *lhs, *rhs;
-    Int idx, j, off, arc;
-    iICODE pIcode, pEnd;
-    ICODEMEM * pmH,* pmL;            /* Pointers to dst LOW_LEVEL icodes */
+    Int idx;
+    iICODE pEnd;
 
 
     /* Process all definitions/uses of long registers at an icode position */
     /* Process all definitions/uses of long registers at an icode position */
     pEnd = this->Icode.end();
     pEnd = this->Icode.end();
-    for (j = 0; j < pLocId->idx.size(); j++)
+    //    for (int pLocId_idx : pLocId->idx)
+    // WARNING: this loop modifies the iterated-over container.
+    for (int j = 0; j < pLocId->idx.size(); j++)
     {
     {
+        int pLocId_idx=pLocId->idx[j];
         /* Check backwards for a definition of this long register */
         /* Check backwards for a definition of this long register */
-        for (idx = pLocId->idx[j] - 1; idx > 0 ; idx--)
+
+        COND_EXPR *lhs, *rhs;
+
+        for (idx = pLocId_idx - 1; idx > 0 ; idx--)
         {
         {
+            iICODE pIcode;
+            ICODEMEM * pmH,* pmL;            /* Pointers to dst LOW_LEVEL icodes */
             pIcode = Icode.begin()+(idx-1);
             pIcode = Icode.begin()+(idx-1);
             if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
             if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
                 continue;
                 continue;
 
 
-            if (pIcode->ic.ll.opcode == (pIcode+1)->ic.ll.opcode)
-                switch (pIcode->ic.ll.opcode)
-                {
-                    case iMOV:
-                        pmH = &pIcode->ic.ll.dst;
-                        pmL = &(pIcode+1)->ic.ll.dst;
-                        if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
-                        {
-                            lhs = COND_EXPR::idLongIdx (i);
-                            this->localId.id_arr[i].idx.push_back(idx-1);
-                            pIcode->setRegDU( pmL->regi, eDEF);
-                            rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
-                            pIcode->setAsgn(lhs, rhs);
-                            (pIcode+1)->invalidate();
-                            idx = 0;    /* to exit the loop */
-                        }
-                        break;
+            if (pIcode->ic.ll.opcode != (pIcode+1)->ic.ll.opcode)
+                continue;
+            switch (pIcode->ic.ll.opcode)
+            {
+                case iMOV:
+                    pmH = &pIcode->ic.ll.dst;
+                    pmL = &(pIcode+1)->ic.ll.dst;
+                    if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
+                    {
+                        lhs = COND_EXPR::idLongIdx (loc_ident_idx);
+                        this->localId.id_arr[loc_ident_idx].idx.push_back(idx-1);
+                        pIcode->setRegDU( pmL->regi, eDEF);
+                        rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, HIGH_FIRST, idx, eUSE, 1);
+                        pIcode->setAsgn(lhs, rhs);
+                        (pIcode+1)->invalidate();
+                        idx = 0;    /* to exit the loop */
+                    }
+                    break;
 
 
-                    case iPOP:
-                        pmH = &(pIcode+1)->ic.ll.dst;
-                        pmL = &pIcode->ic.ll.dst;
-                        if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
-                        {
-                            lhs = COND_EXPR::idLongIdx (i);
-                            pIcode->setRegDU( pmH->regi, eDEF);
-                            pIcode->setUnary(HLI_POP, lhs);
-                            (pIcode+1)->invalidate();
-                            idx = 0;        /* to exit the loop */
-                        }
-                        break;
+                case iPOP:
+                    pmH = &(pIcode+1)->ic.ll.dst;
+                    pmL = &pIcode->ic.ll.dst;
+                    if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
+                    {
+                        lhs = COND_EXPR::idLongIdx (loc_ident_idx);
+                        pIcode->setRegDU( pmH->regi, eDEF);
+                        pIcode->setUnary(HLI_POP, lhs);
+                        (pIcode+1)->invalidate();
+                        idx = 0;        /* to exit the loop */
+                    }
+                    break;
 
 
-                        /**** others missing ***/
+                    /**** others missing ***/
 
 
-                    case iAND: case iOR: case iXOR:
-                        pmL = &pIcode->ic.ll.dst;
-                        pmH = &(pIcode+1)->ic.ll.dst;
-                        if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
-                        {
-                            lhs = COND_EXPR::idLongIdx (i);
-                            pIcode->setRegDU( pmH->regi, USE_DEF);
-                            rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
-                            switch (pIcode->ic.ll.opcode) {
-                                case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
-                                    break;
-                                case iOR:
-                                           rhs = COND_EXPR::boolOp (lhs, rhs, OR);
-                                    break;
-                                case iXOR: rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
-                                    break;
-                            } /* eos */
-                            pIcode->setAsgn(lhs, rhs);
-                            (pIcode+1)->invalidate();
-                            idx = 0;
-                        }
-                        break;
-                } /* eos */
+                case iAND: case iOR: case iXOR:
+                    pmL = &pIcode->ic.ll.dst;
+                    pmH = &(pIcode+1)->ic.ll.dst;
+                    if ((pLocId->id.longId.h == pmH->regi) && (pLocId->id.longId.l == pmL->regi))
+                    {
+                        lhs = COND_EXPR::idLongIdx (loc_ident_idx);
+                        pIcode->setRegDU( pmH->regi, USE_DEF);
+                        rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode, LOW_FIRST, idx, eUSE, 1);
+                        switch (pIcode->ic.ll.opcode) {
+                            case iAND: rhs = COND_EXPR::boolOp (lhs, rhs, AND);
+                                break;
+                            case iOR:
+                                rhs = COND_EXPR::boolOp (lhs, rhs, OR);
+                                break;
+                            case iXOR:
+                                rhs = COND_EXPR::boolOp (lhs, rhs, XOR);
+                                break;
+                        } /* eos */
+                        pIcode->setAsgn(lhs, rhs);
+                        (pIcode+1)->invalidate();
+                        idx = 0;
+                    }
+                    break;
+            } /* eos */
         }
         }
-
         /* If no definition backwards, check forward for a use of this long reg */
         /* If no definition backwards, check forward for a use of this long reg */
         if (idx > 0)
         if (idx > 0)
             continue;
             continue;
-        for (idx = pLocId->idx[j] + 1; idx < Icode.size() - 1; idx++)
+        for (idx = pLocId_idx + 1; idx < Icode.size() - 1; idx++)
         {
         {
+            iICODE pIcode;
+            ICODEMEM * pmH,* pmL;            /* Pointers to dst LOW_LEVEL icodes */
+            int off,arc;
             pIcode = Icode.begin()+(idx);
             pIcode = Icode.begin()+(idx);
             if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
             if ((pIcode->type == HIGH_LEVEL) || (pIcode->invalid == TRUE))
                 continue;
                 continue;
@@ -394,7 +474,7 @@ void Function::propLongReg (Int i, ID *pLocId)
                         if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
                         if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
                                 (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
                                 (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
                         {
                         {
-                            rhs = COND_EXPR::idLongIdx (i);
+                            rhs = COND_EXPR::idLongIdx (loc_ident_idx);
                             pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
                             pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
                             lhs = COND_EXPR::idLong (&this->localId, DST, pIcode,
                             lhs = COND_EXPR::idLong (&this->localId, DST, pIcode,
                                                      HIGH_FIRST, idx, eDEF, 1);
                                                      HIGH_FIRST, idx, eDEF, 1);
@@ -408,7 +488,7 @@ void Function::propLongReg (Int i, ID *pLocId)
                         if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
                         if ((pLocId->id.longId.h == pIcode->ic.ll.src.regi) &&
                                 (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
                                 (pLocId->id.longId.l == (pIcode+1)->ic.ll.src.regi))
                         {
                         {
-                            rhs = COND_EXPR::idLongIdx (i);
+                            rhs = COND_EXPR::idLongIdx (loc_ident_idx);
                             pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
                             pIcode->setRegDU( (pIcode+1)->ic.ll.src.regi, eUSE);
                             pIcode->setUnary(HLI_PUSH, lhs);
                             pIcode->setUnary(HLI_PUSH, lhs);
                             (pIcode+1)->invalidate();
                             (pIcode+1)->invalidate();
@@ -424,7 +504,7 @@ void Function::propLongReg (Int i, ID *pLocId)
                         if ((pLocId->id.longId.h == pmH->regi) &&
                         if ((pLocId->id.longId.h == pmH->regi) &&
                                 (pLocId->id.longId.l == pmL->regi))
                                 (pLocId->id.longId.l == pmL->regi))
                         {
                         {
-                            lhs = COND_EXPR::idLongIdx (i);
+                            lhs = COND_EXPR::idLongIdx (loc_ident_idx);
                             pIcode->setRegDU( pmH->regi, USE_DEF);
                             pIcode->setRegDU( pmH->regi, USE_DEF);
                             rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode,
                             rhs = COND_EXPR::idLong (&this->localId, SRC, pIcode,
                                                      LOW_FIRST, idx, eUSE, 1);
                                                      LOW_FIRST, idx, eUSE, 1);
@@ -447,7 +527,7 @@ void Function::propLongReg (Int i, ID *pLocId)
             else if ((pIcode->ic.ll.opcode == iCMP) &&
             else if ((pIcode->ic.ll.opcode == iCMP) &&
                      (isLong23 (idx, pIcode->inBB, &off, &arc)))
                      (isLong23 (idx, pIcode->inBB, &off, &arc)))
             {
             {
-                if (checkLongRegEq (pLocId->id.longId, pIcode, i, idx, this,
+                if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this,
                                     &rhs, &lhs, off) == TRUE)
                                     &rhs, &lhs, off) == TRUE)
                     longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off);
                     longJCond23 (rhs, lhs, pIcode, &idx, this, arc, off);
             }
             }
@@ -457,7 +537,7 @@ void Function::propLongReg (Int i, ID *pLocId)
             else if ((pIcode->ic.ll.opcode == iCMP) &&
             else if ((pIcode->ic.ll.opcode == iCMP) &&
                      (isLong22 (pIcode, pEnd, &off)))
                      (isLong22 (pIcode, pEnd, &off)))
             {
             {
-                if (checkLongRegEq (pLocId->id.longId, pIcode, i, idx, this,
+                if (checkLongRegEq (pLocId->id.longId, pIcode, loc_ident_idx, idx, this,
                                     &rhs, &lhs, off) == TRUE)
                                     &rhs, &lhs, off) == TRUE)
                     longJCond22 (rhs, lhs, pIcode, &idx);
                     longJCond22 (rhs, lhs, pIcode, &idx);
             }
             }
@@ -472,7 +552,7 @@ void Function::propLongReg (Int i, ID *pLocId)
                 if ((pIcode->ic.ll.dst.regi == pLocId->id.longId.h) &&
                 if ((pIcode->ic.ll.dst.regi == pLocId->id.longId.h) &&
                         (pIcode->ic.ll.src.regi == pLocId->id.longId.l))
                         (pIcode->ic.ll.src.regi == pLocId->id.longId.l))
                 {
                 {
-                    lhs = COND_EXPR::idLongIdx (i);
+                    lhs = COND_EXPR::idLongIdx (loc_ident_idx);
 
 
                     rhs = COND_EXPR::idKte (0, 4);	/* long 0 */
                     rhs = COND_EXPR::idKte (0, 4);	/* long 0 */
                     lhs = COND_EXPR::boolOp (lhs, rhs,
                     lhs = COND_EXPR::boolOp (lhs, rhs,

+ 14 - 17
src/reducible.cpp

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

+ 275 - 246
src/scanner.cpp

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

+ 2 - 7
src/udm.cpp

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

Some files were not shown because too many files changed in this diff