1 |
dpavlin |
12 |
/* |
2 |
|
|
* $Id: new_test_loadstore_a.c,v 1.3 2005/07/22 20:01:25 debug Exp $ |
3 |
|
|
* |
4 |
|
|
* Experimenting with dynamic-but-not-binary-translation load/store. |
5 |
|
|
* See new_test_loadstore_b.c for the main() function. |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "new_test_loadstore.h" |
9 |
|
|
|
10 |
|
|
static void inline general_store(struct cpu *cpu, struct ic *ic) |
11 |
|
|
{ |
12 |
|
|
general_store(cpu, ic); |
13 |
|
|
} |
14 |
|
|
|
15 |
|
|
void x(struct cpu *cpu, struct ic *ic) |
16 |
|
|
{ |
17 |
|
|
unsigned int addr = *ic->arg1; /* + ic->arg2; */ |
18 |
|
|
unsigned char **table1, *page; |
19 |
|
|
|
20 |
|
|
#ifdef AAA |
21 |
|
|
page = cpu->table0[addr >> 12]; |
22 |
|
|
#else |
23 |
|
|
table1 = cpu->table0[addr >> 22]; |
24 |
|
|
page = table1[((addr >> 12) & 1023)*2 + 1]; |
25 |
|
|
#endif |
26 |
|
|
|
27 |
|
|
if (page != 0) |
28 |
|
|
page[addr & 4095] = *(ic->arg3); |
29 |
|
|
else |
30 |
|
|
general_store(cpu, ic); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
void y(struct cpu *cpu, struct ic *ic) |
34 |
|
|
{ |
35 |
|
|
unsigned int addr = *ic->arg1; /* + ic->arg2; */ |
36 |
|
|
unsigned char **table1, *page; |
37 |
|
|
|
38 |
|
|
#ifdef AAA |
39 |
|
|
page = cpu->table0[addr >> 12]; |
40 |
|
|
#else |
41 |
|
|
table1 = cpu->table0[addr >> 22]; |
42 |
|
|
page = table1[((addr >> 12) & 1023)*2 + 0]; |
43 |
|
|
#endif |
44 |
|
|
if (page != 0) |
45 |
|
|
*(ic->arg3) = page[addr & 4095]; |
46 |
|
|
else |
47 |
|
|
general_store(cpu, ic); |
48 |
|
|
} |
49 |
|
|
|