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 <set>
00031 #include <algorithm>
00032 #include <string>
00033 #include "registers.h"
00034
00035 using namespace std;
00036
00037
00038 #define DEFINE_REG(size,type,name,string,complete,mask) \
00039 { reg_info::size, reg_info::type, string, complete, mask },
00040 reg_info regs[] =
00041 {
00042 #include "x86regs.h"
00043 };
00044 #undef DEFINE_REG
00045 #define NUM_REG (sizeof(regs)/sizeof(regs[0]))
00046
00047 struct __find_reg: public unary_function<const reg_info&,bool>
00048 {
00049 __find_reg(const char* _p):p(_p) {};
00050 bool operator()(const reg_info& info)
00051 { return strcmp(info.name,p) == 0; };
00052 const char* p;
00053 };
00054
00055 reg_t find_reg(const char *reg)
00056 {
00057 int n = find_if(regs,regs+NUM_REG,__find_reg(reg)) - regs;
00058 if (n == NUM_REG)
00059 return null_reg;
00060 return static_cast<reg_t>(n);
00061 }
00062
00063 const reg_info* RegistryInfo::GetInfo(const char* name)
00064 {
00065 reg_info *p = find_if(regs,regs+NUM_REG,__find_reg(name));
00066 if ( p == (regs+NUM_REG) )
00067 return NULL;
00068 return p;
00069 }
00070
00071 const reg_info* RegistryInfo::GetInfo(reg_t i)
00072 {
00073 if ( unsigned(i) >= NUM_REG )
00074 return NULL;
00075 return ®s[i];
00076 }
00077
00078 reg_t RegistryInfo::GetIndex(const char* name)
00079 {
00080 return find_reg(name);
00081 }
00082