00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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