Skip to content
Snippets Groups Projects
Commit 59301cb6 authored by an7s's avatar an7s
Browse files

Added utility functions

Former-commit-id: d886e9842edddb672abcd3dfacc173872cb99bf1
parent 68a601ba
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ public:
static bool is32bit(RegisterName);
static bool is16bit(RegisterName);
static bool is8bit(RegisterName);
static int getBitWidth(RegisterName);
static std::string toString(RegisterName);
};
......
......@@ -98,3 +98,42 @@ std::string Register::toString(Register::RegisterName p_reg)
else if (p_reg == DL) return std::string("DL");
else return std::string("UNEXPECTED REGISTER VALUE");
}
int Register::getBitWidth(Register::RegisterName p_reg)
{
switch (p_reg)
{
case EAX:
case EBX:
case ECX:
case EDX:
case EDI:
case ESI:
case EBP:
case ESP:
return 32;
break;
case AX:
case BX:
case CX:
case DX:
return 16;
break;
case AH:
case BH:
case CH:
case DH:
case AL:
case BL:
case CL:
case DL:
return 8;
break;
default:
return -1;
break;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment