summaryrefslogtreecommitdiff
path: root/target-mips
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-10-23 23:58:21 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-10-23 23:58:21 +0000
commit60445285a84915cc4a064acf0a3d15e89f9fac40 (patch)
treebe08e860fe1c174c7ca60c41bf0aeb302fc51e6b /target-mips
parent7d307e9edc944e255fc3462ff536ffeb78ac2c68 (diff)
downloadqemu-60445285a84915cc4a064acf0a3d15e89f9fac40.tar.gz
Fix writable length of the index register.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3431 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-mips')
-rw-r--r--target-mips/op.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/target-mips/op.c b/target-mips/op.c
index ca367d763f..a666006ad6 100644
--- a/target-mips/op.c
+++ b/target-mips/op.c
@@ -1481,7 +1481,14 @@ void op_mfc0_desave (void)
void op_mtc0_index (void)
{
- env->CP0_Index = (env->CP0_Index & 0x80000000) | (T0 % env->tlb->nb_tlb);
+ int num = 1;
+ unsigned int tmp = env->tlb->nb_tlb;
+
+ do {
+ tmp >>= 1;
+ num <<= 1;
+ } while (tmp);
+ env->CP0_Index = (env->CP0_Index & 0x80000000) | (T0 & (num - 1));
RETURN();
}