===========================================================================
| 951 | |
| 952 | //=========================================================================== |
| 953 | Hash_t AssemblerHashMnemonic ( const char * pMnemonic ) |
| 954 | { |
| 955 | const char *pText = pMnemonic; |
| 956 | Hash_t nMnemonicHash = 0; |
| 957 | int iHighBits; |
| 958 | |
| 959 | const int NUM_LOW_BITS = 19; // 24 -> 19 prime |
| 960 | const int NUM_MSK_BITS = 5; // 4 -> 5 prime |
| 961 | const Hash_t BIT_MSK_HIGH = ((1 << NUM_MSK_BITS) - 1) << NUM_LOW_BITS; |
| 962 | |
| 963 | #if DEBUG_ASSEMBLER |
| 964 | int nLen = strlen( pMnemonic ); |
| 965 | static int nMaxLen = 0; |
| 966 | if (nMaxLen < nLen) { |
| 967 | nMaxLen = nLen; |
| 968 | ConsolePrintFormat( "New Max Len: %d %s", nMaxLen, pMnemonic ); |
| 969 | } |
| 970 | #endif |
| 971 | |
| 972 | while ( *pText ) |
| 973 | // for ( int iChar = 0; iChar < 4; iChar++ ) |
| 974 | { |
| 975 | char c = tolower( *pText ); // TODO: based on ALLOW_INPUT_LOWERCASE ?? |
| 976 | |
| 977 | nMnemonicHash = (nMnemonicHash << NUM_MSK_BITS) + c; |
| 978 | iHighBits = (nMnemonicHash & BIT_MSK_HIGH); |
| 979 | if (iHighBits) |
| 980 | { |
| 981 | nMnemonicHash = (nMnemonicHash ^ (iHighBits >> NUM_LOW_BITS)) & ~ BIT_MSK_HIGH; |
| 982 | } |
| 983 | pText++; |
| 984 | } |
| 985 | |
| 986 | return nMnemonicHash; |
| 987 | } |
| 988 | |
| 989 | |
| 990 | //=========================================================================== |
no test coverage detected