--- trunk/src/bintrans_alpha.c 2007/10/08 16:17:52 3 +++ trunk/src/bintrans_alpha.c 2007/10/08 16:18:00 4 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: bintrans_alpha.c,v 1.114 2005/03/22 09:12:04 debug Exp $ + * $Id: bintrans_alpha.c,v 1.118 2005/04/18 22:30:31 debug Exp $ * * Alpha specific code for dynamic binary translation. * @@ -39,17 +39,16 @@ * a1..a5 17..21 5 * t8..t11 22..25 4 * - * These can be "mapped" to MIPS registers in the translated code, - * except a0 which points to the cpu struct, and t0..t4 (or so) - * which are used by the translated code as temporaries. + * These can be "mapped" to MIPS registers in the translated code, except a0 + * which points to the cpu struct, and t0..t4 (or so) which are used by the + * translated code as temporaries. * - * 3 + 7 + 5 + 4 = 19 available registers. Of course, all (except - * s0..s6) must be saved when calling external functions, such as - * when doing load/store. + * 3 + 7 + 5 + 4 = 19 available registers. Of course, all (except s0..s6) must + * be saved when calling external functions, such as when calling tlbp and + * other external functions. * - * Which are the 19 most commonly used MIPS registers? (This will - * include the pc, and the "current number of executed translated - * instructions.) + * Which are the 19 most commonly used MIPS registers? (This will include the + * pc, and the "current number of executed translated instructions.) * * The current allocation is as follows: * @@ -244,14 +243,8 @@ 0xa6730000, /* NULL? Then return failure at once. */ - /* bne a3, skip */ - 0xf6600003, - - 0x243f0000 | (BINTRANS_DONT_RUN_NEXT >> 16), /* ldah t0,256 */ - 0x44270407, /* or t0,t6,t6 */ - 0x6bfa8001, /* ret */ - - /* skip: */ + /* beq a3, return */ + 0xe6600004, /* 01 30 60 46 and a3,0x1,t0 */ 0x46603001, @@ -266,7 +259,12 @@ /* 04 04 62 42 addq a3,t1,t3 */ 0x42620404, - 0x6be50000 /* jmp (t4) */ + 0x6be50000, /* jmp (t4) */ + + /* return: */ + 0x243f0000 | (BINTRANS_DONT_RUN_NEXT >> 16), /* ldah t0,256 */ + 0x44270407, /* or t0,t6,t6 */ + 0x6bfa8001 /* ret */ }; static void (*bintrans_runchunk)(struct cpu *, unsigned char *); @@ -2581,7 +2579,7 @@ static void bintrans_backend_init(void) { int size; - uint32_t *p; + uint32_t *p, *q; /* "runchunk": */ @@ -2675,8 +2673,8 @@ *p++ = 0x205f0000 | (N_SAFE_BINTRANS_LIMIT-1); /* lda t1,safe-1 */ *p++ = 0x40e20da1; /* cmple t6,t1,t0 */ - *p++ = 0xf4200001; /* bne */ - *p++ = 0x6bfa8001; /* ret */ + q = p; /* *q is updated later */ + *p++ = 0xe4200001; /* beq ret (far below) */ *p++ = 0x40c01411; /* addq t5,0,a1 */ @@ -2704,7 +2702,7 @@ *p++ = 0x205f0ffc; /* lda t1,0xffc */ /* - * a3 = tbl1[t3] (load entry from tbl1 (whic is a3)) + * a3 = tbl1[t3] (load entry from tbl1 (which is a3)) */ *p++ = 0x42640413; /* addq a3,t3,a3 */ *p++ = 0x46220002; /* and a1,t1,t1 */ @@ -2728,6 +2726,9 @@ *p++ = 0x40230401; /* addq t0,t2,t0 */ *p++ = 0x6be10000; /* jmp (t0) */ + /* Now, update *q to point here: */ + *q = 0xe4200000 | (((size_t)p - (size_t)q)/4 - 1); /* beq ret */ + /* Return to the main translation loop. */ *p++ = 0x6bfa8001; /* ret */ }