File: new_test_loadstore_a.c

package info (click to toggle)
gxemul 0.7.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,152 kB
  • sloc: ansic: 111,065; sh: 972; exp: 354; makefile: 118
file content (47 lines) | stat: -rw-r--r-- 957 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 *  Experimenting with dynamic-but-not-binary-translation load/store.
 *  See new_test_loadstore_b.c for the main() function.
 */

#include "new_test_loadstore.h"

static void inline general_store(struct cpu *cpu, struct ic *ic)
{
	general_store(cpu, ic);
}

void x(struct cpu *cpu, struct ic *ic)
{
	unsigned int addr = *ic->arg1; /* + ic->arg2; */
	unsigned char **table1, *page;

#ifdef AAA
	page = cpu->table0[addr >> 12];
#else
	table1 = cpu->table0[addr >> 22];
	page = table1[((addr >> 12) & 1023)*2 + 1];
#endif

	if (page != 0)
		page[addr & 4095] = *(ic->arg3);
	else
		general_store(cpu, ic);
}

void y(struct cpu *cpu, struct ic *ic)
{
	unsigned int addr = *ic->arg1; /* + ic->arg2; */
	unsigned char **table1, *page;

#ifdef AAA
	page = cpu->table0[addr >> 12];
#else
	table1 = cpu->table0[addr >> 22];
	page = table1[((addr >> 12) & 1023)*2 + 0];
#endif
	if (page != 0)
		*(ic->arg3) = page[addr & 4095];
	else
		general_store(cpu, ic);
}