@@ -344,14 +344,15 @@ immutable:
344
344
ubyte val;
345
345
opflag_t ty;
346
346
347
- bool isSIL_DIL_BPL_SPL () const @safe
347
+ bool isSIL_DIL_BPL_SPL () const @trusted
348
348
{
349
+ bool caseSensitive = asmstate.statement.caseSensitive;
349
350
// Be careful as these have the same val's as AH CH DH BH
350
351
return ty == _r8 &&
351
- ((val == _SIL && regstr == " SIL" ) ||
352
- (val == _DIL && regstr == " DIL" ) ||
353
- (val == _BPL && regstr == " BPL" ) ||
354
- (val == _SPL && regstr == " SPL" ));
352
+ ((val == _SIL && stringEq( regstr, " SIL" , caseSensitive) ) ||
353
+ (val == _DIL && stringEq( regstr, " DIL" , caseSensitive) ) ||
354
+ (val == _BPL && stringEq( regstr, " BPL" , caseSensitive) ) ||
355
+ (val == _SPL && stringEq( regstr, " SPL" , caseSensitive) ));
355
356
}
356
357
}
357
358
@@ -2161,9 +2162,9 @@ private @safe pure bool asm_isNonZeroInt(const ref OPND o)
2161
2162
/* ******************************
2162
2163
*/
2163
2164
2164
- private @safe pure bool asm_is_fpreg(const (char )[] szReg)
2165
+ private @trusted bool asm_is_fpreg(const (char )[] szReg)
2165
2166
{
2166
- return szReg == " ST" ;
2167
+ return stringEq ( szReg, " ST" , asmstate.statement.caseSensitive) ;
2167
2168
}
2168
2169
2169
2170
/* ******************************
@@ -3395,9 +3396,10 @@ immutable(REG)* asm_reg_lookup(const(char)[] s)
3395
3396
{
3396
3397
// dbg_printf("asm_reg_lookup('%s')\n",s);
3397
3398
3399
+ bool caseSensitive = asmstate.statement.caseSensitive;
3398
3400
for (int i = 0 ; i < regtab.length; i++ )
3399
3401
{
3400
- if (s == regtab[i].regstr)
3402
+ if (stringEq(s, regtab[i].regstr, caseSensitive) )
3401
3403
{
3402
3404
return ®tab[i];
3403
3405
}
@@ -3406,7 +3408,7 @@ immutable(REG)* asm_reg_lookup(const(char)[] s)
3406
3408
{
3407
3409
for (int i = 0 ; i < regtab64.length; i++ )
3408
3410
{
3409
- if (s == regtab64[i].regstr)
3411
+ if (stringEq(s, regtab64[i].regstr, caseSensitive) )
3410
3412
{
3411
3413
return ®tab64[i];
3412
3414
}
@@ -4648,3 +4650,44 @@ unittest
4648
4650
assert ( isOneOf(_8, _anysize));
4649
4651
}
4650
4652
}
4653
+
4654
+ /* *********************************
4655
+ * Case insensitive string compare
4656
+ * Returns: true if equal
4657
+ */
4658
+
4659
+ bool stringEq (const (char )[] s1, const (char )[] s2, bool caseSensitive)
4660
+ {
4661
+ if (caseSensitive)
4662
+ return s1 == s2;
4663
+
4664
+ if (s1.length != s2.length)
4665
+ return false ;
4666
+ foreach (i, c; s1)
4667
+ {
4668
+ char c1 = c;
4669
+ if (' A' <= c1 && c1 <= ' Z' )
4670
+ c1 |= 0x20 ;
4671
+ char c2 = s2[i];
4672
+ if (' A' <= c2 && c2 <= ' Z' )
4673
+ c2 |= 0x20 ;
4674
+
4675
+ if (c1 != c2)
4676
+ return false ;
4677
+ }
4678
+ return true ;
4679
+ }
4680
+
4681
+ unittest
4682
+ {
4683
+ assert (! stringEq(" ABZ" , " ABZX" , true ));
4684
+
4685
+ assert ( stringEq(" ABZ" , " ABZ" , true ));
4686
+ assert (! stringEq(" aBz" , " ABZ" , true ));
4687
+ assert (! stringEq(" ABZ" , " ABz" , true ));
4688
+
4689
+ assert ( stringEq(" aBZ" , " ABZ" , false ));
4690
+ assert ( stringEq(" aBz" , " AbZ" , false ));
4691
+ assert ( stringEq(" ABZ" , " ABz" , false ));
4692
+ assert (! stringEq(" 3BZ" , " ABz" , false ));
4693
+ }
0 commit comments