Skip to content

Commit

Permalink
Optimize GetAsDword, and GetAsByte.
Browse files Browse the repository at this point in the history
pri timebalance(HOST CPU:Core i5 12600, VM FREQ:66 in TMENU) best value increased from 290000 to 300000.
  • Loading branch information
bcc2528 authored Nov 16, 2023
1 parent 6d8ae05 commit 3c4d7e3
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/cpu/i486.h
Original file line number Diff line number Diff line change
Expand Up @@ -1367,20 +1367,23 @@ class i486DXCommon : public CPU
*/
inline unsigned int GetAsDword(void) const
{
static const unsigned int numBytesMask[MAX_NUM_BYTES]=
unsigned int dword=cpputil::GetDword(byteData);
switch(numBytes)
{
0x00000000,
0x000000FF,
0x0000FFFF,
0x00FFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
0xFFFFFFFF,
};
return cpputil::GetDword(byteData)&numBytesMask[numBytes];
case 0:
dword=0;
break;
case 1:
dword&=0x000000FF;
break;
case 2:
dword&=0x0000FFFF;
break;
case 3:
dword&=0x00FFFFFF;
break;
}
return dword;
}
/*! Returns a value as an unsigned byte.
It won't evaluate beyond numBytes.
Expand All @@ -1395,22 +1398,19 @@ class i486DXCommon : public CPU
*/
inline unsigned int GetAsWord(void) const
{
static const unsigned int numBytesMask[MAX_NUM_BYTES]=
{
0x00000000,
0x000000FF,
0x0000FFFF,
0x0000FFFF,
0x0000FFFF,
0x0000FFFF,
0x0000FFFF,
0x0000FFFF,
0x0000FFFF,
0x0000FFFF,
};

unsigned int word=cpputil::GetWord(byteData);
word&=numBytesMask[numBytes];
switch(numBytes)
{
case 0:
word=0;
break;
case 1:
word&=0x000000FF;
break;
default:
word&=0x0000FFFF;
break;
}
return word;
}

Expand Down

0 comments on commit 3c4d7e3

Please sign in to comment.