25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_urisc.c,v 1.6 2005/04/04 20:08:58 debug Exp $ |
* $Id: cpu_urisc.c,v 1.8 2005/06/26 22:23:42 debug Exp $ |
29 |
* |
* |
30 |
* URISC CPU emulation. See http://en.wikipedia.org/wiki/URISC for more |
* URISC CPU emulation. See http://en.wikipedia.org/wiki/URISC for more |
31 |
* information about the "instruction set". |
* information about the "instruction set". |
93 |
* |
* |
94 |
* Create a new URISC cpu object. |
* Create a new URISC cpu object. |
95 |
*/ |
*/ |
96 |
struct cpu *urisc_cpu_new(struct memory *mem, struct machine *machine, |
int urisc_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine, |
97 |
int cpu_id, char *cpu_type_name) |
int cpu_id, char *cpu_type_name) |
98 |
{ |
{ |
99 |
struct cpu *cpu; |
if (strcmp(cpu_type_name, "URISC") != 0) |
100 |
|
return 0; |
|
if (cpu_type_name == NULL || strcmp(cpu_type_name, "URISC") != 0) |
|
|
return NULL; |
|
|
|
|
|
cpu = malloc(sizeof(struct cpu)); |
|
|
if (cpu == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
101 |
|
|
102 |
memset(cpu, 0, sizeof(struct cpu)); |
cpu->memory_rw = urisc_memory_rw; |
103 |
cpu->memory_rw = urisc_memory_rw; |
cpu->byte_order = EMUL_BIG_ENDIAN; |
|
cpu->name = cpu_type_name; |
|
|
cpu->mem = mem; |
|
|
cpu->machine = machine; |
|
|
cpu->cpu_id = cpu_id; |
|
|
cpu->byte_order = EMUL_BIG_ENDIAN; |
|
104 |
|
|
105 |
cpu->cd.urisc.wordlen = 32; |
cpu->cd.urisc.wordlen = 32; |
106 |
cpu->cd.urisc.acc_in_mem = 0; |
cpu->cd.urisc.acc_in_mem = 0; |
117 |
debug(")"); |
debug(")"); |
118 |
} |
} |
119 |
|
|
120 |
return cpu; |
return 1; |
121 |
} |
} |
122 |
|
|
123 |
|
|
165 |
|
|
166 |
symbol = get_symbol_name(&cpu->machine->symbol_context, |
symbol = get_symbol_name(&cpu->machine->symbol_context, |
167 |
cpu->pc, &offset); |
cpu->pc, &offset); |
168 |
sprintf(tmps, "cpu%%i: pc = 0x%%0%illx", (cpu->cd.urisc.wordlen/4)); |
snprintf(tmps, sizeof(tmps), "cpu%%i: pc = 0x%%0%illx", |
169 |
|
(cpu->cd.urisc.wordlen/4)); |
170 |
debug(tmps, x, (long long)cpu->pc); |
debug(tmps, x, (long long)cpu->pc); |
171 |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
172 |
sprintf(tmps, "cpu%%i: acc = 0x%%0%illx\n", (cpu->cd.urisc.wordlen/4)); |
snprintf(tmps, sizeof(tmps), "cpu%%i: acc = 0x%%0%illx\n", |
173 |
|
(cpu->cd.urisc.wordlen/4)); |
174 |
debug(tmps, x, (long long)cpu->cd.urisc.acc); |
debug(tmps, x, (long long)cpu->cd.urisc.acc); |
175 |
} |
} |
176 |
|
|
205 |
|
|
206 |
if (cpu->machine->ncpus > 1 && running) |
if (cpu->machine->ncpus > 1 && running) |
207 |
debug("cpu%i: ", cpu->cpu_id); |
debug("cpu%i: ", cpu->cpu_id); |
208 |
sprintf(tmps, "0x%%0%illx: 0x", nbytes * 2); |
snprintf(tmps, sizeof(tmps), "0x%%0%illx: 0x", nbytes * 2); |
209 |
debug(tmps, (long long)dumpaddr); |
debug(tmps, (long long)dumpaddr); |
210 |
|
|
211 |
/* TODO: Little-endian? */ |
/* TODO: Little-endian? */ |
339 |
} |
} |
340 |
|
|
341 |
if (cpu->machine->instruction_trace) { |
if (cpu->machine->instruction_trace) { |
342 |
sprintf(tmps, "\t[mem=0x%%0%illx", nbytes * 2); |
snprintf(tmps, sizeof(tmps), "\t[mem=0x%%0%illx", nbytes * 2); |
343 |
debug(tmps, (long long)data); |
debug(tmps, (long long)data); |
344 |
sprintf(tmps, "; acc: 0x%%0%illx", nbytes * 2); |
snprintf(tmps, sizeof(tmps), "; acc: 0x%%0%illx", nbytes * 2); |
345 |
debug(tmps, (long long)cpu->cd.urisc.acc); |
debug(tmps, (long long)cpu->cd.urisc.acc); |
346 |
} |
} |
347 |
|
|
353 |
cpu->cd.urisc.acc = data; |
cpu->cd.urisc.acc = data; |
354 |
|
|
355 |
if (cpu->machine->instruction_trace) { |
if (cpu->machine->instruction_trace) { |
356 |
sprintf(tmps, " ==> 0x%%0%illx", nbytes * 2); |
snprintf(tmps, sizeof(tmps), " ==> 0x%%0%illx", nbytes * 2); |
357 |
debug(tmps, (long long)cpu->cd.urisc.acc); |
debug(tmps, (long long)cpu->cd.urisc.acc); |
358 |
if (skip) |
if (skip) |
359 |
debug(", SKIP"); |
debug(", SKIP"); |