From 3c4d7e371b6afe755ddfa7f15e01cbcddba3981b Mon Sep 17 00:00:00 2001 From: BCC <75528750+bcc2528@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:43:18 +0900 Subject: [PATCH] Optimize GetAsDword, and GetAsByte. pri timebalance(HOST CPU:Core i5 12600, VM FREQ:66 in TMENU) best value increased from 290000 to 300000. --- src/cpu/i486.h | 56 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/cpu/i486.h b/src/cpu/i486.h index 3d22ba14..0753a083 100644 --- a/src/cpu/i486.h +++ b/src/cpu/i486.h @@ -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. @@ -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; }