Commit 60445285a84915cc4a064acf0a3d15e89f9fac40

Authored by ths
1 parent 7d307e9e

Fix writable length of the index register.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3431 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 8 additions and 1 deletions
target-mips/op.c
... ... @@ -1481,7 +1481,14 @@ void op_mfc0_desave (void)
1481 1481  
1482 1482 void op_mtc0_index (void)
1483 1483 {
1484   - env->CP0_Index = (env->CP0_Index & 0x80000000) | (T0 % env->tlb->nb_tlb);
  1484 + int num = 1;
  1485 + unsigned int tmp = env->tlb->nb_tlb;
  1486 +
  1487 + do {
  1488 + tmp >>= 1;
  1489 + num <<= 1;
  1490 + } while (tmp);
  1491 + env->CP0_Index = (env->CP0_Index & 0x80000000) | (T0 & (num - 1));
1485 1492 RETURN();
1486 1493 }
1487 1494  
... ...