Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

param.cpp

Go to the documentation of this file.
00001 /*
00002 PeRdr - PE file disassembler
00003 Copyright (C) 1999-2002 Frediano Ziglio
00004 -----
00005 
00006 This program is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 -----
00020 
00021 INFORMATION
00022   www: https://freddy77.tripod.com/perdr/
00023   e-mail: freddy77@angelfire.com
00024 */
00025 #include "global.h"
00026 #ifdef HAVE_HDRSTOP
00027 #pragma hdrstop
00028 #endif
00029 
00030 #include "param.h"
00031 
00032 unsigned Param::memTypeSizes[Param::memTypeCount] =
00033 {
00034 #define DEFINE_MEMTYPE(name,size) size,
00035 #define DEFINE_MEMTYPEI(name,size) size,
00036 #include "memtype.h"
00037 #undef DEFINE_MEMTYPE
00038 #undef DEFINE_MEMTYPEI
00039 };
00040 
00041 extern void ReadInstruction(const char* s);
00042 extern void ReadParam(Param& prm,const char* s);
00043 
00044 Param::Param(enum TCRegistry ,reg_t reg):
00045         relocation(NULL)
00046 {
00047   type = t_registry;
00048   mem_reg1 = reg;
00049   mem_reg2 = null_reg;
00050   sm.size = 0;
00051   // size = ?? from reg
00052 }
00053 
00054 Param::Param(enum TCLiteral ,int _literal,unsigned char _size):
00055         relocation(NULL)
00056 {
00057   type = t_literal;
00058   mem_reg1 = null_reg;
00059   mem_reg2 = null_reg;
00060   literal = _literal;
00061   sm.size = _size;
00062 }
00063 
00064 Param::Param(enum TCFarLiteral ,int _literal,unsigned char _size,int segment):
00065         relocation(NULL)
00066 {
00067   type = t_farliteral;
00068   mem_reg1 = static_cast<reg_t>(segment); // !!!
00069   mem_reg2 = null_reg;
00070   literal = _literal;
00071   sm.size = _size;
00072 }
00073 
00074 Param::Param(enum TCMemory ,int address,MemoryTypes _memType):
00075         relocation(NULL)
00076 {
00077   type = t_memory;
00078   mem_reg1 = null_reg;
00079   mem_reg2 = null_reg;
00080   literal = address;
00081   sm.memType = _memType;
00082 }
00083 
00084 Param::Param(enum TCMemory ,reg_t reg,int address,MemoryTypes _memType):
00085         relocation(NULL)
00086 {
00087   type = t_memory;
00088   mem_reg1 = reg;
00089   mem_reg2 = null_reg;
00090   literal = address;
00091   sm.memType = _memType;
00092 }
00093 
00094 Param::Param(enum TCMemory ,reg_t reg1,reg_t reg2,int address,unsigned char multiplier,MemoryTypes _memType):
00095         relocation(NULL)
00096 {
00097   type = t_memory;
00098   mem_reg1 = reg1;
00099   mem_reg2 = reg2;
00100   literal = address;
00101   factor = multiplier;
00102   sm.memType = _memType;
00103 }
00104 
00105 #ifdef DEBUG
00106 void Param::InitInvalid()
00107 {
00108   sm.size = 0;
00109 }
00110 
00111 void Param::CheckValid()
00112 {
00113   if (type == t_literal)
00114   {
00115     _PRG_ASSERT(sm.size != 0);
00116   }
00117 }
00118 #endif
00119 
00120 unsigned char Param::GetSize() const
00121 {
00122   switch (type)
00123   {
00124   default:
00125     _PRG_ASSERT(0);
00126   case t_memory:
00127     return GetMemSize();
00128   case t_literal:
00129   case t_farliteral:
00130     return GetLiteralSize();
00131   case t_registry:
00132     return RegistryInfo::GetInfo(mem_reg1)->GetByteSize();
00133   }
00134 }
00135 

Generated on Mon Jan 13 22:20:34 2003 for perdr by doxygen1.2.15