1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_avr.c,v 1.4 2005/09/17 22:34:52 debug Exp $ |
* $Id: cpu_avr.c,v 1.20 2006/07/16 13:32:26 debug Exp $ |
29 |
* |
* |
30 |
* Atmel AVR (8-bit) CPU emulation. |
* Atmel AVR (8-bit) CPU emulation. |
31 |
*/ |
*/ |
43 |
|
|
44 |
|
|
45 |
#define DYNTRANS_32 |
#define DYNTRANS_32 |
46 |
|
#define DYNTRANS_VARIABLE_INSTRUCTION_LENGTH |
47 |
#include "tmp_avr_head.c" |
#include "tmp_avr_head.c" |
48 |
|
|
49 |
|
|
58 |
int avr_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine, |
int avr_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine, |
59 |
int cpu_id, char *cpu_type_name) |
int cpu_id, char *cpu_type_name) |
60 |
{ |
{ |
61 |
if (strcasecmp(cpu_type_name, "AVR") != 0) |
int type = 0; |
62 |
|
|
63 |
|
if (strcasecmp(cpu_type_name, "AVR") == 0 || |
64 |
|
strcasecmp(cpu_type_name, "AVR16") == 0 || |
65 |
|
strcasecmp(cpu_type_name, "AT90S2313") == 0 || |
66 |
|
strcasecmp(cpu_type_name, "AT90S8515") == 0) |
67 |
|
type = 16; |
68 |
|
if (strcasecmp(cpu_type_name, "AVR22") == 0) |
69 |
|
type = 22; |
70 |
|
|
71 |
|
if (type == 0) |
72 |
return 0; |
return 0; |
73 |
|
|
74 |
|
cpu->run_instr = avr_run_instr; |
75 |
cpu->memory_rw = avr_memory_rw; |
cpu->memory_rw = avr_memory_rw; |
76 |
cpu->update_translation_table = avr_update_translation_table; |
cpu->update_translation_table = avr_update_translation_table; |
77 |
cpu->invalidate_translation_caches_paddr = |
cpu->invalidate_translation_caches = |
78 |
avr_invalidate_translation_caches_paddr; |
avr_invalidate_translation_caches; |
79 |
cpu->invalidate_code_translation = avr_invalidate_code_translation; |
cpu->invalidate_code_translation = avr_invalidate_code_translation; |
80 |
cpu->is_32bit = 1; |
cpu->is_32bit = 1; |
81 |
|
|
82 |
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
83 |
|
|
84 |
cpu->cd.avr.pc_mask = 0xffff; |
cpu->cd.avr.is_22bit = (type == 22); |
85 |
|
cpu->cd.avr.pc_mask = cpu->cd.avr.is_22bit? 0x3fffff : 0xffff; |
86 |
|
|
87 |
|
cpu->cd.avr.sram_mask = 0xff; /* 256 bytes ram */ |
88 |
|
cpu->cd.avr.sp = cpu->cd.avr.sram_mask - 2; |
89 |
|
|
90 |
/* Only show name and caches etc for CPU nr 0 (in SMP machines): */ |
/* Only show name and caches etc for CPU nr 0 (in SMP machines): */ |
91 |
if (cpu_id == 0) { |
if (cpu_id == 0) { |
103 |
*/ |
*/ |
104 |
void avr_cpu_list_available_types(void) |
void avr_cpu_list_available_types(void) |
105 |
{ |
{ |
106 |
debug("AVR\n"); |
debug("AVR\tAVR16\tAVR22\n"); |
|
/* TODO */ |
|
107 |
} |
} |
108 |
|
|
109 |
|
|
112 |
*/ |
*/ |
113 |
void avr_cpu_dumpinfo(struct cpu *cpu) |
void avr_cpu_dumpinfo(struct cpu *cpu) |
114 |
{ |
{ |
115 |
/* TODO */ |
debug(" (%i-bit program counter)\n", |
116 |
debug("\n"); |
cpu->cd.avr.is_22bit? 22 : 16); |
117 |
} |
} |
118 |
|
|
119 |
|
|
145 |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_N? 'N' : 'n'); |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_N? 'N' : 'n'); |
146 |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_Z? 'Z' : 'z'); |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_Z? 'Z' : 'z'); |
147 |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_C? 'C' : 'c'); |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_C? 'C' : 'c'); |
148 |
debug(" pc = 0x%04x", x, (int)cpu->pc); |
if (cpu->cd.avr.is_22bit) |
149 |
|
debug(" pc = 0x%06x", (int)cpu->pc); |
150 |
|
else |
151 |
|
debug(" pc = 0x%04x", (int)cpu->pc); |
152 |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
153 |
|
|
154 |
for (i=0; i<N_AVR_REGS; i++) { |
for (i=0; i<N_AVR_REGS; i++) { |
155 |
if ((i % 4) == 0) |
int r = (i >> 3) + ((i & 7) << 2); |
156 |
debug("cpu%i:\t", x); |
if ((i % 8) == 0) |
157 |
debug("r%02i = 0x%02x", i, cpu->cd.avr.r[i]); |
debug("cpu%i:", x); |
158 |
debug((i % 4) == 3? "\n" : " "); |
debug(" r%02i=0x%02x", r, cpu->cd.avr.r[r]); |
159 |
|
if ((i % 8) == 7) |
160 |
|
debug("\n"); |
161 |
} |
} |
162 |
|
|
163 |
|
debug("cpu%i: x=%i, y=%i, z=%i, sp=0x%04x\n", x, |
164 |
|
(int)(int16_t)(cpu->cd.avr.r[27]*256 + cpu->cd.avr.r[26]), |
165 |
|
(int)(int16_t)(cpu->cd.avr.r[29]*256 + cpu->cd.avr.r[28]), |
166 |
|
(int)(int16_t)(cpu->cd.avr.r[31]*256 + cpu->cd.avr.r[30]), |
167 |
|
cpu->cd.avr.sp); |
168 |
} |
} |
169 |
|
|
170 |
debug("cpu%i: nr of instructions: %lli\n", x, |
debug("cpu%i: nr of instructions: %lli\n", x, |
171 |
(long long)cpu->machine->ncycles); |
(long long)cpu->machine->ninstrs); |
172 |
debug("cpu%i: nr of cycles: %lli\n", x, |
debug("cpu%i: nr of cycles: %lli\n", x, |
173 |
(long long)(cpu->machine->ncycles + cpu->cd.avr.extra_cycles)); |
(long long)(cpu->machine->ninstrs + cpu->cd.avr.extra_cycles)); |
174 |
} |
} |
175 |
|
|
176 |
|
|
205 |
|
|
206 |
|
|
207 |
/* |
/* |
|
* avr_cpu_show_full_statistics(): |
|
|
* |
|
|
* Show detailed statistics on opcode usage on each cpu. |
|
|
*/ |
|
|
void avr_cpu_show_full_statistics(struct machine *m) |
|
|
{ |
|
|
fatal("avr_cpu_show_full_statistics(): TODO\n"); |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
208 |
* avr_cpu_tlbdump(): |
* avr_cpu_tlbdump(): |
209 |
* |
* |
210 |
* Called from the debugger to dump the TLB in a readable format. |
* Called from the debugger to dump the TLB in a readable format. |
215 |
*/ |
*/ |
216 |
void avr_cpu_tlbdump(struct machine *m, int x, int rawflag) |
void avr_cpu_tlbdump(struct machine *m, int x, int rawflag) |
217 |
{ |
{ |
218 |
fatal("avr_cpu_tlbdump(): TODO\n"); |
} |
219 |
|
|
220 |
|
|
221 |
|
/* |
222 |
|
* avr_cpu_gdb_stub(): |
223 |
|
* |
224 |
|
* Execute a "remote GDB" command. Returns a newly allocated response string |
225 |
|
* on success, NULL on failure. |
226 |
|
*/ |
227 |
|
char *avr_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
228 |
|
{ |
229 |
|
fatal("avr_cpu_gdb_stub(): TODO\n"); |
230 |
|
return NULL; |
231 |
} |
} |
232 |
|
|
233 |
|
|
271 |
* cpu->pc for relative addresses. |
* cpu->pc for relative addresses. |
272 |
*/ |
*/ |
273 |
int avr_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
int avr_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
274 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
275 |
{ |
{ |
276 |
uint64_t offset; |
uint64_t offset; |
277 |
int len = 0, addr, iw, rd, rr, imm; |
int len = 0, addr, iw, rd, rr, imm; |
298 |
if ((iw & 0xffff) == 0x0000) { |
if ((iw & 0xffff) == 0x0000) { |
299 |
print_spaces(len); |
print_spaces(len); |
300 |
debug("nop\n"); |
debug("nop\n"); |
301 |
} else if ((iw & 0xfc00) == 0x0c00) { |
} else if ((iw & 0xff00) == 0x0100) { |
302 |
|
print_spaces(len); |
303 |
|
rd = (iw >> 3) & 30; |
304 |
|
rr = (iw << 1) & 30; |
305 |
|
debug("movw\tr%i:r%i,r%i:r%i\n", rd+1, rd, rr+1, rr); |
306 |
|
} else if ((iw & 0xff00) == 0x0200) { |
307 |
|
print_spaces(len); |
308 |
|
rd = ((iw >> 4) & 15) + 16; |
309 |
|
rr = (iw & 15) + 16; |
310 |
|
debug("muls\tr%i,r%i\n", rd, rr); |
311 |
|
} else if ((iw & 0xff88) == 0x0300) { |
312 |
|
print_spaces(len); |
313 |
|
rd = ((iw >> 4) & 7) + 16; |
314 |
|
rr = (iw & 7) + 16; |
315 |
|
debug("mulsu\tr%i,r%i\n", rd, rr); |
316 |
|
} else if ((iw & 0xff88) == 0x0308) { |
317 |
|
print_spaces(len); |
318 |
|
rd = ((iw >> 4) & 7) + 16; |
319 |
|
rr = (iw & 7) + 16; |
320 |
|
debug("fmul\tr%i,r%i\n", rd, rr); |
321 |
|
} else if ((iw & 0xff88) == 0x0380) { |
322 |
|
print_spaces(len); |
323 |
|
rd = ((iw >> 4) & 7) + 16; |
324 |
|
rr = (iw & 7) + 16; |
325 |
|
debug("fmuls\tr%i,r%i\n", rd, rr); |
326 |
|
} else if ((iw & 0xff88) == 0x0388) { |
327 |
|
print_spaces(len); |
328 |
|
rd = ((iw >> 4) & 7) + 16; |
329 |
|
rr = (iw & 7) + 16; |
330 |
|
debug("fmulsu\tr%i,r%i\n", rd, rr); |
331 |
|
} else if ((iw & 0xec00) == 0x0400) { |
332 |
|
print_spaces(len); |
333 |
|
rd = (iw & 0x1f0) >> 4; |
334 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
335 |
|
debug("cp%s\tr%i,r%i\n", iw & 0x1000? "" : "c", rd, rr); |
336 |
|
} else if ((iw & 0xec00) == 0x0800) { |
337 |
print_spaces(len); |
print_spaces(len); |
338 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
339 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
340 |
debug("add\tr%i,r%i\n", rd, rr); |
debug("%s\tr%i,r%i\n", iw & 0x1000? "sub" : "sbc", rd, rr); |
341 |
} else if ((iw & 0xfc00) == 0x1c00) { |
} else if ((iw & 0xec00) == 0x0c00) { |
342 |
print_spaces(len); |
print_spaces(len); |
343 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
344 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
345 |
debug("adc\tr%i,r%i\n", rd, rr); |
debug("%s\tr%i,r%i\n", iw & 0x1000? "adc" : "add", rd, rr); |
346 |
|
} else if ((iw & 0xfc00) == 0x1000) { |
347 |
|
print_spaces(len); |
348 |
|
rd = (iw & 0x1f0) >> 4; |
349 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
350 |
|
debug("cpse\tr%i,r%i\n", rd, rr); |
351 |
} else if ((iw & 0xfc00) == 0x2000) { |
} else if ((iw & 0xfc00) == 0x2000) { |
352 |
print_spaces(len); |
print_spaces(len); |
353 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
354 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
355 |
debug("and\tr%i,r%i\n", rd, rr); |
debug("and\tr%i,r%i\n", rd, rr); |
356 |
|
} else if ((iw & 0xfc00) == 0x2400) { |
357 |
|
print_spaces(len); |
358 |
|
rd = (iw & 0x1f0) >> 4; |
359 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
360 |
|
debug("eor\tr%i,r%i\n", rd, rr); |
361 |
|
} else if ((iw & 0xfc00) == 0x2800) { |
362 |
|
print_spaces(len); |
363 |
|
rd = (iw & 0x1f0) >> 4; |
364 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
365 |
|
debug("or\tr%i,r%i\n", rd, rr); |
366 |
} else if ((iw & 0xfc00) == 0x2c00) { |
} else if ((iw & 0xfc00) == 0x2c00) { |
367 |
print_spaces(len); |
print_spaces(len); |
368 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
369 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
370 |
debug("mov\tr%i,r%i\n", rd, rr); |
debug("mov\tr%i,r%i\n", rd, rr); |
371 |
|
} else if ((iw & 0xf000) == 0x3000) { |
372 |
|
print_spaces(len); |
373 |
|
rd = ((iw >> 4) & 15) + 16; |
374 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
375 |
|
debug("cpi\tr%i,0x%x\n", rd, imm); |
376 |
|
} else if ((iw & 0xf000) == 0x4000) { |
377 |
|
print_spaces(len); |
378 |
|
rd = ((iw >> 4) & 15) + 16; |
379 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
380 |
|
debug("sbci\tr%i,0x%x\n", rd, imm); |
381 |
|
} else if ((iw & 0xf000) == 0x5000) { |
382 |
|
print_spaces(len); |
383 |
|
rd = ((iw >> 4) & 15) + 16; |
384 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
385 |
|
debug("subi\tr%i,0x%x\n", rd, imm); |
386 |
|
} else if ((iw & 0xe000) == 0x6000) { |
387 |
|
print_spaces(len); |
388 |
|
rd = ((iw >> 4) & 15) + 16; |
389 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
390 |
|
debug("%s\tr%i,0x%x\n", iw & 0x1000? "andi" : "ori", rd, imm); |
391 |
} else if ((iw & 0xfe0f) == 0x8000) { |
} else if ((iw & 0xfe0f) == 0x8000) { |
392 |
print_spaces(len); |
print_spaces(len); |
393 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
396 |
print_spaces(len); |
print_spaces(len); |
397 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
398 |
debug("ld\tr%i,Y\n", rd); |
debug("ld\tr%i,Y\n", rd); |
399 |
|
} else if ((iw & 0xfe0f) == 0x8208) { |
400 |
|
print_spaces(len); |
401 |
|
rd = (iw >> 4) & 31; |
402 |
|
debug("st\tY,r%i\n", rd); |
403 |
} else if ((iw & 0xfe0f) == 0x900c) { |
} else if ((iw & 0xfe0f) == 0x900c) { |
404 |
print_spaces(len); |
print_spaces(len); |
405 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
408 |
print_spaces(len); |
print_spaces(len); |
409 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
410 |
debug("%s\tr%i\n", iw & 0x200? "push" : "pop", rd); |
debug("%s\tr%i\n", iw & 0x200? "push" : "pop", rd); |
411 |
} else if ((iw & 0xfe0f) == 0x9200) { |
} else if ((iw & 0xfe0f) == 0x9000) { |
412 |
print_two(ib, &len); |
print_two(ib, &len); |
413 |
addr = (ib[3] << 8) + ib[2]; |
addr = (ib[3] << 8) + ib[2]; |
414 |
print_spaces(len); |
print_spaces(len); |
415 |
debug("sts\t0x%x,r%i\n", addr, (iw & 0x1f0) >> 4); |
if (iw & 0x200) |
416 |
|
debug("sts\t0x%x,r%i\n", addr, (iw & 0x1f0) >> 4); |
417 |
|
else |
418 |
|
debug("lds\tr%i,0x%x\n", (iw & 0x1f0) >> 4, addr); |
419 |
|
} else if ((iw & 0xfe0f) == 0x9209) { |
420 |
|
print_spaces(len); |
421 |
|
rr = (iw >> 4) & 31; |
422 |
|
debug("st\tY+,r%i\n", rr); |
423 |
|
} else if ((iw & 0xfe0f) == 0x920a) { |
424 |
|
print_spaces(len); |
425 |
|
rr = (iw >> 4) & 31; |
426 |
|
debug("st\t-Y,r%i\n", rr); |
427 |
|
} else if ((iw & 0xfe0f) == 0x9401) { |
428 |
|
print_spaces(len); |
429 |
|
rd = (iw >> 4) & 31; |
430 |
|
debug("neg\tr%i\n", rd); |
431 |
} else if ((iw & 0xfe0f) == 0x9402) { |
} else if ((iw & 0xfe0f) == 0x9402) { |
432 |
print_spaces(len); |
print_spaces(len); |
433 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
434 |
debug("swap\tr%i\n", rd); |
debug("swap\tr%i\n", rd); |
435 |
|
} else if ((iw & 0xfe0f) == 0x9403) { |
436 |
|
print_spaces(len); |
437 |
|
rd = (iw >> 4) & 31; |
438 |
|
debug("inc\tr%i\n", rd); |
439 |
} else if ((iw & 0xff0f) == 0x9408) { |
} else if ((iw & 0xff0f) == 0x9408) { |
440 |
print_spaces(len); |
print_spaces(len); |
441 |
rd = (iw >> 4) & 7; |
rd = (iw >> 4) & 7; |
442 |
debug("%s%c\n", iw & 0x80? "cl" : "se", sreg_names[rd]); |
debug("%s%c\n", iw & 0x80? "cl" : "se", sreg_names[rd]); |
443 |
|
} else if ((iw & 0xfe0f) == 0x940a) { |
444 |
|
print_spaces(len); |
445 |
|
rd = (iw >> 4) & 31; |
446 |
|
debug("dec\tr%i\n", rd); |
447 |
|
} else if ((iw & 0xff8f) == 0x9408) { |
448 |
|
print_spaces(len); |
449 |
|
debug("bset\t%i\n", (iw >> 4) & 7); |
450 |
|
} else if ((iw & 0xff8f) == 0x9488) { |
451 |
|
print_spaces(len); |
452 |
|
debug("bclr\t%i\n", (iw >> 4) & 7); |
453 |
} else if ((iw & 0xffef) == 0x9508) { |
} else if ((iw & 0xffef) == 0x9508) { |
454 |
/* ret and reti */ |
/* ret and reti */ |
455 |
print_spaces(len); |
print_spaces(len); |
457 |
} else if ((iw & 0xffff) == 0x9588) { |
} else if ((iw & 0xffff) == 0x9588) { |
458 |
print_spaces(len); |
print_spaces(len); |
459 |
debug("sleep\n"); |
debug("sleep\n"); |
460 |
|
} else if ((iw & 0xffff) == 0x9598) { |
461 |
|
print_spaces(len); |
462 |
|
debug("break\n"); |
463 |
} else if ((iw & 0xffff) == 0x95a8) { |
} else if ((iw & 0xffff) == 0x95a8) { |
464 |
print_spaces(len); |
print_spaces(len); |
465 |
debug("wdr\n"); |
debug("wdr\n"); |
466 |
|
} else if ((iw & 0xffef) == 0x95c8) { |
467 |
|
print_spaces(len); |
468 |
|
debug("%slpm\n", iw & 0x0010? "e" : ""); |
469 |
} else if ((iw & 0xff00) == 0x9600) { |
} else if ((iw & 0xff00) == 0x9600) { |
470 |
print_spaces(len); |
print_spaces(len); |
471 |
imm = ((iw & 0xc0) >> 2) | (iw & 0xf); |
imm = ((iw & 0xc0) >> 2) | (iw & 0xf); |
472 |
rd = ((iw >> 4) & 3) * 2 + 24; |
rd = ((iw >> 4) & 3) * 2 + 24; |
473 |
debug("adiw\tr%i:r%i,0x%x\n", rd, rd+1, imm); |
debug("adiw\tr%i:r%i,0x%x\n", rd, rd+1, imm); |
474 |
|
} else if ((iw & 0xfd00) == 0x9800) { |
475 |
|
print_spaces(len); |
476 |
|
imm = iw & 7; |
477 |
|
rd = (iw >> 3) & 31; /* A */ |
478 |
|
debug("%sbi\t0x%x,%i\n", iw & 0x0200? "s" : "c", rd, imm); |
479 |
|
} else if ((iw & 0xfd00) == 0x9900) { |
480 |
|
print_spaces(len); |
481 |
|
imm = iw & 7; |
482 |
|
rd = (iw >> 3) & 31; /* A */ |
483 |
|
debug("sbi%s\t0x%x,%i\n", iw & 0x0200? "s" : "c", rd, imm); |
484 |
|
} else if ((iw & 0xf000) == 0xb000) { |
485 |
|
print_spaces(len); |
486 |
|
imm = ((iw & 0x600) >> 5) | (iw & 0xf); |
487 |
|
rr = (iw >> 4) & 31; |
488 |
|
if (iw & 0x800) |
489 |
|
debug("out\t0x%x,r%i\n", imm, rr); |
490 |
|
else |
491 |
|
debug("in\tr%i,0x%x\n", rr, imm); |
492 |
} else if ((iw & 0xe000) == 0xc000) { |
} else if ((iw & 0xe000) == 0xc000) { |
493 |
print_spaces(len); |
print_spaces(len); |
494 |
addr = (int16_t)((iw & 0xfff) << 4); |
addr = (int16_t)((iw & 0xfff) << 4); |
499 |
rd = ((iw >> 4) & 0xf) + 16; |
rd = ((iw >> 4) & 0xf) + 16; |
500 |
imm = ((iw >> 4) & 0xf0) | (iw & 0xf); |
imm = ((iw >> 4) & 0xf0) | (iw & 0xf); |
501 |
debug("ldi\tr%i,0x%x\n", rd, imm); |
debug("ldi\tr%i,0x%x\n", rd, imm); |
502 |
|
} else if ((iw & 0xfc00) == 0xf000) { |
503 |
|
print_spaces(len); |
504 |
|
addr = (iw >> 3) & 0x7f; |
505 |
|
if (addr >= 64) |
506 |
|
addr -= 128; |
507 |
|
addr = (addr + 1) * 2 + dumpaddr; |
508 |
|
debug("brbs\t%c,0x%x\n", sreg_names[iw & 7], addr); |
509 |
|
} else if ((iw & 0xfc00) == 0xf400) { |
510 |
|
print_spaces(len); |
511 |
|
addr = (iw >> 3) & 0x7f; |
512 |
|
if (addr >= 64) |
513 |
|
addr -= 128; |
514 |
|
addr = (addr + 1) * 2 + dumpaddr; |
515 |
|
debug("brbc\t%c,0x%x\n", sreg_names[iw & 7], addr); |
516 |
|
} else if ((iw & 0xfc08) == 0xfc00) { |
517 |
|
print_spaces(len); |
518 |
|
rr = (iw >> 4) & 31; |
519 |
|
imm = iw & 7; |
520 |
|
debug("sbr%s\tr%i,%i\n", iw & 0x0200 ? "s" : "c", rr, imm); |
521 |
} else { |
} else { |
522 |
print_spaces(len); |
print_spaces(len); |
523 |
debug("UNIMPLEMENTED 0x%04x\n", iw); |
debug("UNIMPLEMENTED 0x%04x\n", iw); |