Began removal of platform/. The Monitor:: namespace is completely converted.
[aesalon.git] / src / monitor / asm / Register.cpp
blobe169cdd0395f0d50af984251e8fc54aaef527971
1 #include <map>
2 #include <iostream>
3 #include "Register.h"
5 namespace Aesalon {
6 namespace Monitor {
7 namespace ASM {
9 Register::data_size_e Register::get_register_size() const {
10 #if AESALON_PLATFORM == AESALON_PLATFORM_x86 || AESALON_PLATFORM_x86_64
11 switch(reg) {
12 case AL:
13 case AH:
14 case BL:
15 case BH:
16 case CL:
17 case CH:
18 case DL:
19 case DH:
20 return SIZE_BYTE;
21 case AX:
22 case BX:
23 case CX:
24 case DX:
25 return SIZE_WORD;
26 case EAX:
27 case EBX:
28 case ECX:
29 case EDX:
30 case EDI:
31 case ESI:
32 case EBP:
33 case ESP:
34 return SIZE_DWORD;
35 #if AESALON_PLATFORM == AESALON_PLATFORM_x86_64
36 case RAX:
37 case RBX:
38 case RCX:
39 case RDX:
40 case R8:
41 case R9:
42 case R10:
43 case R11:
44 case R12:
45 case R13:
46 case R14:
47 case R15:
48 case RSI:
49 case RDI:
50 case RSP:
51 case RBP:
52 case RIP:
53 return SIZE_QWORD;
54 default:
55 return SIZE_BYTE;
56 #endif
58 #endif
59 return SIZE_BYTE;
62 Register Register::from_string(std::string string) {
63 std::map<std::string, register_e> reg_map;
65 reg_map["al"] = AL;
66 reg_map["ah"] = AH;
67 reg_map["bl"] = BL;
68 reg_map["bh"] = BH;
69 reg_map["cl"] = CL;
70 reg_map["ch"] = CH;
71 reg_map["dl"] = DL;
72 reg_map["dh"] = DH;
73 reg_map["ax"] = AX;
74 reg_map["bx"] = BX;
75 reg_map["cx"] = CX;
76 reg_map["dx"] = DX;
77 reg_map["eax"] = EAX;
78 reg_map["ebx"] = EBX;
79 reg_map["ecx"] = ECX;
80 reg_map["edx"] = EDX;
81 reg_map["esi"] = ESI;
82 reg_map["edi"] = EDI;
83 reg_map["esp"] = ESP;
84 reg_map["ebp"] = EBP;
85 reg_map["eip"] = EIP;
86 reg_map["rax"] = RAX;
87 reg_map["rbx"] = RBX;
88 reg_map["rcx"] = RCX;
89 reg_map["rdx"] = RDX;
90 reg_map["r8"] = R8;
91 reg_map["r9"] = R9;
92 reg_map["r10"] = R10;
93 reg_map["r11"] = R11;
94 reg_map["r12"] = R12;
95 reg_map["r13"] = R13;
96 reg_map["r14"] = R14;
97 reg_map["r15"] = R15;
98 reg_map["rsi"] = RSI;
99 reg_map["rdi"] = RDI;
100 reg_map["rsp"] = RSP;
101 reg_map["rbp"] = RBP;
102 reg_map["rip"] = RIP;
103 reg_map["cs"] = CS;
104 reg_map["ss"] = SS;
106 for(std::string::iterator i = string.begin(); i != string.end(); i ++) {
107 (*i) = std::tolower(*i);
110 return reg_map[string];
113 } // namespace ASM
114 } // namespace Monitor
115 } // namespace Aesalon