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.7 2005/11/13 00:14:07 debug Exp $ |
* $Id: cpu_avr.c,v 1.21 2006/09/19 10:50:08 debug Exp $ |
29 |
* |
* |
30 |
* Atmel AVR (8-bit) CPU emulation. |
* Atmel AVR (8-bit) CPU emulation. |
31 |
*/ |
*/ |
39 |
#include "machine.h" |
#include "machine.h" |
40 |
#include "memory.h" |
#include "memory.h" |
41 |
#include "misc.h" |
#include "misc.h" |
42 |
|
#include "settings.h" |
43 |
#include "symbol.h" |
#include "symbol.h" |
44 |
|
|
45 |
|
|
59 |
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, |
60 |
int cpu_id, char *cpu_type_name) |
int cpu_id, char *cpu_type_name) |
61 |
{ |
{ |
62 |
if (strcasecmp(cpu_type_name, "AVR") != 0) |
int type = 0, i; |
63 |
|
|
64 |
|
if (strcasecmp(cpu_type_name, "AVR") == 0 || |
65 |
|
strcasecmp(cpu_type_name, "AVR16") == 0 || |
66 |
|
strcasecmp(cpu_type_name, "AT90S2313") == 0 || |
67 |
|
strcasecmp(cpu_type_name, "AT90S8515") == 0) |
68 |
|
type = 16; |
69 |
|
if (strcasecmp(cpu_type_name, "AVR22") == 0) |
70 |
|
type = 22; |
71 |
|
|
72 |
|
if (type == 0) |
73 |
return 0; |
return 0; |
74 |
|
|
75 |
|
cpu->run_instr = avr_run_instr; |
76 |
cpu->memory_rw = avr_memory_rw; |
cpu->memory_rw = avr_memory_rw; |
77 |
cpu->update_translation_table = avr_update_translation_table; |
cpu->update_translation_table = avr_update_translation_table; |
78 |
cpu->invalidate_translation_caches = |
cpu->invalidate_translation_caches = |
82 |
|
|
83 |
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
cpu->byte_order = EMUL_LITTLE_ENDIAN; |
84 |
|
|
85 |
cpu->cd.avr.pc_mask = 0xffff; |
cpu->cd.avr.is_22bit = (type == 22); |
86 |
|
cpu->cd.avr.pc_mask = cpu->cd.avr.is_22bit? 0x3fffff : 0xffff; |
87 |
|
|
88 |
|
cpu->cd.avr.sram_mask = 0xff; /* 256 bytes ram */ |
89 |
|
cpu->cd.avr.sp = cpu->cd.avr.sram_mask - 2; |
90 |
|
|
91 |
/* 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): */ |
92 |
if (cpu_id == 0) { |
if (cpu_id == 0) { |
93 |
debug("%s", cpu->name); |
debug("%s", cpu->name); |
94 |
} |
} |
95 |
|
|
96 |
|
CPU_SETTINGS_ADD_REGISTER64("pc", cpu->pc); |
97 |
|
CPU_SETTINGS_ADD_REGISTER16("sp", cpu->cd.avr.sp); |
98 |
|
CPU_SETTINGS_ADD_REGISTER8("sreg", cpu->cd.avr.sreg); |
99 |
|
for (i=0; i<N_AVR_REGS; i++) { |
100 |
|
char tmpstr[5]; |
101 |
|
snprintf(tmpstr, sizeof(tmpstr), "r%i", i); |
102 |
|
CPU_SETTINGS_ADD_REGISTER8(tmpstr, cpu->cd.avr.r[i]); |
103 |
|
} |
104 |
|
|
105 |
return 1; |
return 1; |
106 |
} |
} |
107 |
|
|
113 |
*/ |
*/ |
114 |
void avr_cpu_list_available_types(void) |
void avr_cpu_list_available_types(void) |
115 |
{ |
{ |
116 |
debug("AVR\n"); |
debug("AVR\tAVR16\tAVR22\n"); |
|
/* TODO */ |
|
117 |
} |
} |
118 |
|
|
119 |
|
|
122 |
*/ |
*/ |
123 |
void avr_cpu_dumpinfo(struct cpu *cpu) |
void avr_cpu_dumpinfo(struct cpu *cpu) |
124 |
{ |
{ |
125 |
/* TODO */ |
debug(" (%i-bit program counter)\n", |
126 |
debug("\n"); |
cpu->cd.avr.is_22bit? 22 : 16); |
127 |
} |
} |
128 |
|
|
129 |
|
|
155 |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_N? 'N' : 'n'); |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_N? 'N' : 'n'); |
156 |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_Z? 'Z' : 'z'); |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_Z? 'Z' : 'z'); |
157 |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_C? 'C' : 'c'); |
debug("%c", cpu->cd.avr.sreg & AVR_SREG_C? 'C' : 'c'); |
158 |
debug(" pc = 0x%04x", x, (int)cpu->pc); |
if (cpu->cd.avr.is_22bit) |
159 |
|
debug(" pc = 0x%06x", (int)cpu->pc); |
160 |
|
else |
161 |
|
debug(" pc = 0x%04x", (int)cpu->pc); |
162 |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
163 |
|
|
164 |
for (i=0; i<N_AVR_REGS; i++) { |
for (i=0; i<N_AVR_REGS; i++) { |
165 |
if ((i % 4) == 0) |
int r = (i >> 3) + ((i & 7) << 2); |
166 |
debug("cpu%i:\t", x); |
if ((i % 8) == 0) |
167 |
debug("r%02i = 0x%02x", i, cpu->cd.avr.r[i]); |
debug("cpu%i:", x); |
168 |
debug((i % 4) == 3? "\n" : " "); |
debug(" r%-2i=0x%02x", r, cpu->cd.avr.r[r]); |
169 |
|
if ((i % 8) == 7) |
170 |
|
debug("\n"); |
171 |
} |
} |
172 |
|
|
173 |
|
debug("cpu%i: x=%i, y=%i, z=%i, sp=0x%04x\n", x, |
174 |
|
(int)(int16_t)(cpu->cd.avr.r[27]*256 + cpu->cd.avr.r[26]), |
175 |
|
(int)(int16_t)(cpu->cd.avr.r[29]*256 + cpu->cd.avr.r[28]), |
176 |
|
(int)(int16_t)(cpu->cd.avr.r[31]*256 + cpu->cd.avr.r[30]), |
177 |
|
cpu->cd.avr.sp); |
178 |
} |
} |
179 |
|
|
180 |
debug("cpu%i: nr of instructions: %lli\n", x, |
debug("cpu%i: nr of instructions: %lli\n", x, |
181 |
(long long)cpu->machine->ncycles); |
(long long)cpu->machine->ninstrs); |
182 |
debug("cpu%i: nr of cycles: %lli\n", x, |
debug("cpu%i: nr of cycles: %lli\n", x, |
183 |
(long long)(cpu->machine->ncycles + cpu->cd.avr.extra_cycles)); |
(long long)(cpu->machine->ninstrs + cpu->cd.avr.extra_cycles)); |
184 |
} |
} |
185 |
|
|
186 |
|
|
187 |
/* |
/* |
188 |
* avr_cpu_register_match(): |
* avr_cpu_tlbdump(): |
189 |
|
* |
190 |
|
* Called from the debugger to dump the TLB in a readable format. |
191 |
|
* x is the cpu number to dump, or -1 to dump all CPUs. |
192 |
|
* |
193 |
|
* If rawflag is nonzero, then the TLB contents isn't formated nicely, |
194 |
|
* just dumped. |
195 |
*/ |
*/ |
196 |
void avr_cpu_register_match(struct machine *m, char *name, |
void avr_cpu_tlbdump(struct machine *m, int x, int rawflag) |
|
int writeflag, uint64_t *valuep, int *match_register) |
|
197 |
{ |
{ |
198 |
int cpunr = 0; |
} |
199 |
|
|
|
/* CPU number: */ |
|
|
/* TODO */ |
|
200 |
|
|
201 |
if (strcasecmp(name, "pc") == 0) { |
/* |
202 |
if (writeflag) { |
* avr_cpu_gdb_stub(): |
203 |
m->cpus[cpunr]->pc = *valuep; |
* |
204 |
} else |
* Execute a "remote GDB" command. Returns a newly allocated response string |
205 |
*valuep = m->cpus[cpunr]->pc; |
* on success, NULL on failure. |
206 |
*match_register = 1; |
*/ |
207 |
} else if (name[0] == 'r' && isdigit((int)name[1])) { |
char *avr_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
208 |
int nr = atoi(name + 1); |
{ |
209 |
if (nr >= 0 && nr < N_AVR_REGS) { |
fatal("avr_cpu_gdb_stub(): TODO\n"); |
210 |
if (writeflag) |
return NULL; |
|
m->cpus[cpunr]->cd.avr.r[nr] = *valuep; |
|
|
else |
|
|
*valuep = m->cpus[cpunr]->cd.avr.r[nr]; |
|
|
*match_register = 1; |
|
|
} |
|
|
} |
|
211 |
} |
} |
212 |
|
|
213 |
|
|
251 |
* cpu->pc for relative addresses. |
* cpu->pc for relative addresses. |
252 |
*/ |
*/ |
253 |
int avr_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
int avr_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
254 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
255 |
{ |
{ |
256 |
uint64_t offset; |
uint64_t offset; |
257 |
int len = 0, addr, iw, rd, rr, imm; |
int len = 0, addr, iw, rd, rr, imm; |
278 |
if ((iw & 0xffff) == 0x0000) { |
if ((iw & 0xffff) == 0x0000) { |
279 |
print_spaces(len); |
print_spaces(len); |
280 |
debug("nop\n"); |
debug("nop\n"); |
281 |
} else if ((iw & 0xfc00) == 0x0c00) { |
} else if ((iw & 0xff00) == 0x0100) { |
282 |
|
print_spaces(len); |
283 |
|
rd = (iw >> 3) & 30; |
284 |
|
rr = (iw << 1) & 30; |
285 |
|
debug("movw\tr%i:r%i,r%i:r%i\n", rd+1, rd, rr+1, rr); |
286 |
|
} else if ((iw & 0xff00) == 0x0200) { |
287 |
|
print_spaces(len); |
288 |
|
rd = ((iw >> 4) & 15) + 16; |
289 |
|
rr = (iw & 15) + 16; |
290 |
|
debug("muls\tr%i,r%i\n", rd, rr); |
291 |
|
} else if ((iw & 0xff88) == 0x0300) { |
292 |
|
print_spaces(len); |
293 |
|
rd = ((iw >> 4) & 7) + 16; |
294 |
|
rr = (iw & 7) + 16; |
295 |
|
debug("mulsu\tr%i,r%i\n", rd, rr); |
296 |
|
} else if ((iw & 0xff88) == 0x0308) { |
297 |
|
print_spaces(len); |
298 |
|
rd = ((iw >> 4) & 7) + 16; |
299 |
|
rr = (iw & 7) + 16; |
300 |
|
debug("fmul\tr%i,r%i\n", rd, rr); |
301 |
|
} else if ((iw & 0xff88) == 0x0380) { |
302 |
|
print_spaces(len); |
303 |
|
rd = ((iw >> 4) & 7) + 16; |
304 |
|
rr = (iw & 7) + 16; |
305 |
|
debug("fmuls\tr%i,r%i\n", rd, rr); |
306 |
|
} else if ((iw & 0xff88) == 0x0388) { |
307 |
|
print_spaces(len); |
308 |
|
rd = ((iw >> 4) & 7) + 16; |
309 |
|
rr = (iw & 7) + 16; |
310 |
|
debug("fmulsu\tr%i,r%i\n", rd, rr); |
311 |
|
} else if ((iw & 0xec00) == 0x0400) { |
312 |
|
print_spaces(len); |
313 |
|
rd = (iw & 0x1f0) >> 4; |
314 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
315 |
|
debug("cp%s\tr%i,r%i\n", iw & 0x1000? "" : "c", rd, rr); |
316 |
|
} else if ((iw & 0xec00) == 0x0800) { |
317 |
|
print_spaces(len); |
318 |
|
rd = (iw & 0x1f0) >> 4; |
319 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
320 |
|
debug("%s\tr%i,r%i\n", iw & 0x1000? "sub" : "sbc", rd, rr); |
321 |
|
} else if ((iw & 0xec00) == 0x0c00) { |
322 |
print_spaces(len); |
print_spaces(len); |
323 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
324 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
325 |
debug("add\tr%i,r%i\n", rd, rr); |
debug("%s\tr%i,r%i\n", iw & 0x1000? "adc" : "add", rd, rr); |
326 |
} else if ((iw & 0xfc00) == 0x1c00) { |
} else if ((iw & 0xfc00) == 0x1000) { |
327 |
print_spaces(len); |
print_spaces(len); |
328 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
329 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
330 |
debug("adc\tr%i,r%i\n", rd, rr); |
debug("cpse\tr%i,r%i\n", rd, rr); |
331 |
} else if ((iw & 0xfc00) == 0x2000) { |
} else if ((iw & 0xfc00) == 0x2000) { |
332 |
print_spaces(len); |
print_spaces(len); |
333 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
334 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
335 |
debug("and\tr%i,r%i\n", rd, rr); |
debug("and\tr%i,r%i\n", rd, rr); |
336 |
|
} else if ((iw & 0xfc00) == 0x2400) { |
337 |
|
print_spaces(len); |
338 |
|
rd = (iw & 0x1f0) >> 4; |
339 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
340 |
|
debug("eor\tr%i,r%i\n", rd, rr); |
341 |
|
} else if ((iw & 0xfc00) == 0x2800) { |
342 |
|
print_spaces(len); |
343 |
|
rd = (iw & 0x1f0) >> 4; |
344 |
|
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
345 |
|
debug("or\tr%i,r%i\n", rd, rr); |
346 |
} else if ((iw & 0xfc00) == 0x2c00) { |
} else if ((iw & 0xfc00) == 0x2c00) { |
347 |
print_spaces(len); |
print_spaces(len); |
348 |
rd = (iw & 0x1f0) >> 4; |
rd = (iw & 0x1f0) >> 4; |
349 |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
rr = ((iw & 0x200) >> 5) | (iw & 0xf); |
350 |
debug("mov\tr%i,r%i\n", rd, rr); |
debug("mov\tr%i,r%i\n", rd, rr); |
351 |
|
} else if ((iw & 0xf000) == 0x3000) { |
352 |
|
print_spaces(len); |
353 |
|
rd = ((iw >> 4) & 15) + 16; |
354 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
355 |
|
debug("cpi\tr%i,0x%x\n", rd, imm); |
356 |
|
} else if ((iw & 0xf000) == 0x4000) { |
357 |
|
print_spaces(len); |
358 |
|
rd = ((iw >> 4) & 15) + 16; |
359 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
360 |
|
debug("sbci\tr%i,0x%x\n", rd, imm); |
361 |
|
} else if ((iw & 0xf000) == 0x5000) { |
362 |
|
print_spaces(len); |
363 |
|
rd = ((iw >> 4) & 15) + 16; |
364 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
365 |
|
debug("subi\tr%i,0x%x\n", rd, imm); |
366 |
|
} else if ((iw & 0xe000) == 0x6000) { |
367 |
|
print_spaces(len); |
368 |
|
rd = ((iw >> 4) & 15) + 16; |
369 |
|
imm = ((iw >> 4) & 0xf0) + (iw & 15); |
370 |
|
debug("%s\tr%i,0x%x\n", iw & 0x1000? "andi" : "ori", rd, imm); |
371 |
} else if ((iw & 0xfe0f) == 0x8000) { |
} else if ((iw & 0xfe0f) == 0x8000) { |
372 |
print_spaces(len); |
print_spaces(len); |
373 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
376 |
print_spaces(len); |
print_spaces(len); |
377 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
378 |
debug("ld\tr%i,Y\n", rd); |
debug("ld\tr%i,Y\n", rd); |
379 |
|
} else if ((iw & 0xfe0f) == 0x8208) { |
380 |
|
print_spaces(len); |
381 |
|
rd = (iw >> 4) & 31; |
382 |
|
debug("st\tY,r%i\n", rd); |
383 |
} else if ((iw & 0xfe0f) == 0x900c) { |
} else if ((iw & 0xfe0f) == 0x900c) { |
384 |
print_spaces(len); |
print_spaces(len); |
385 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
388 |
print_spaces(len); |
print_spaces(len); |
389 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
390 |
debug("%s\tr%i\n", iw & 0x200? "push" : "pop", rd); |
debug("%s\tr%i\n", iw & 0x200? "push" : "pop", rd); |
391 |
} else if ((iw & 0xfe0f) == 0x9200) { |
} else if ((iw & 0xfe0f) == 0x9000) { |
392 |
print_two(ib, &len); |
print_two(ib, &len); |
393 |
addr = (ib[3] << 8) + ib[2]; |
addr = (ib[3] << 8) + ib[2]; |
394 |
print_spaces(len); |
print_spaces(len); |
395 |
debug("sts\t0x%x,r%i\n", addr, (iw & 0x1f0) >> 4); |
if (iw & 0x200) |
396 |
|
debug("sts\t0x%x,r%i\n", addr, (iw & 0x1f0) >> 4); |
397 |
|
else |
398 |
|
debug("lds\tr%i,0x%x\n", (iw & 0x1f0) >> 4, addr); |
399 |
|
} else if ((iw & 0xfe0f) == 0x9209) { |
400 |
|
print_spaces(len); |
401 |
|
rr = (iw >> 4) & 31; |
402 |
|
debug("st\tY+,r%i\n", rr); |
403 |
|
} else if ((iw & 0xfe0f) == 0x920a) { |
404 |
|
print_spaces(len); |
405 |
|
rr = (iw >> 4) & 31; |
406 |
|
debug("st\t-Y,r%i\n", rr); |
407 |
|
} else if ((iw & 0xfe0f) == 0x9401) { |
408 |
|
print_spaces(len); |
409 |
|
rd = (iw >> 4) & 31; |
410 |
|
debug("neg\tr%i\n", rd); |
411 |
} else if ((iw & 0xfe0f) == 0x9402) { |
} else if ((iw & 0xfe0f) == 0x9402) { |
412 |
print_spaces(len); |
print_spaces(len); |
413 |
rd = (iw >> 4) & 31; |
rd = (iw >> 4) & 31; |
414 |
debug("swap\tr%i\n", rd); |
debug("swap\tr%i\n", rd); |
415 |
|
} else if ((iw & 0xfe0f) == 0x9403) { |
416 |
|
print_spaces(len); |
417 |
|
rd = (iw >> 4) & 31; |
418 |
|
debug("inc\tr%i\n", rd); |
419 |
} else if ((iw & 0xff0f) == 0x9408) { |
} else if ((iw & 0xff0f) == 0x9408) { |
420 |
print_spaces(len); |
print_spaces(len); |
421 |
rd = (iw >> 4) & 7; |
rd = (iw >> 4) & 7; |
422 |
debug("%s%c\n", iw & 0x80? "cl" : "se", sreg_names[rd]); |
debug("%s%c\n", iw & 0x80? "cl" : "se", sreg_names[rd]); |
423 |
|
} else if ((iw & 0xfe0f) == 0x940a) { |
424 |
|
print_spaces(len); |
425 |
|
rd = (iw >> 4) & 31; |
426 |
|
debug("dec\tr%i\n", rd); |
427 |
|
} else if ((iw & 0xff8f) == 0x9408) { |
428 |
|
print_spaces(len); |
429 |
|
debug("bset\t%i\n", (iw >> 4) & 7); |
430 |
|
} else if ((iw & 0xff8f) == 0x9488) { |
431 |
|
print_spaces(len); |
432 |
|
debug("bclr\t%i\n", (iw >> 4) & 7); |
433 |
} else if ((iw & 0xffef) == 0x9508) { |
} else if ((iw & 0xffef) == 0x9508) { |
434 |
/* ret and reti */ |
/* ret and reti */ |
435 |
print_spaces(len); |
print_spaces(len); |
437 |
} else if ((iw & 0xffff) == 0x9588) { |
} else if ((iw & 0xffff) == 0x9588) { |
438 |
print_spaces(len); |
print_spaces(len); |
439 |
debug("sleep\n"); |
debug("sleep\n"); |
440 |
|
} else if ((iw & 0xffff) == 0x9598) { |
441 |
|
print_spaces(len); |
442 |
|
debug("break\n"); |
443 |
} else if ((iw & 0xffff) == 0x95a8) { |
} else if ((iw & 0xffff) == 0x95a8) { |
444 |
print_spaces(len); |
print_spaces(len); |
445 |
debug("wdr\n"); |
debug("wdr\n"); |
446 |
|
} else if ((iw & 0xffef) == 0x95c8) { |
447 |
|
print_spaces(len); |
448 |
|
debug("%slpm\n", iw & 0x0010? "e" : ""); |
449 |
} else if ((iw & 0xff00) == 0x9600) { |
} else if ((iw & 0xff00) == 0x9600) { |
450 |
print_spaces(len); |
print_spaces(len); |
451 |
imm = ((iw & 0xc0) >> 2) | (iw & 0xf); |
imm = ((iw & 0xc0) >> 2) | (iw & 0xf); |
452 |
rd = ((iw >> 4) & 3) * 2 + 24; |
rd = ((iw >> 4) & 3) * 2 + 24; |
453 |
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); |
454 |
|
} else if ((iw & 0xfd00) == 0x9800) { |
455 |
|
print_spaces(len); |
456 |
|
imm = iw & 7; |
457 |
|
rd = (iw >> 3) & 31; /* A */ |
458 |
|
debug("%sbi\t0x%x,%i\n", iw & 0x0200? "s" : "c", rd, imm); |
459 |
|
} else if ((iw & 0xfd00) == 0x9900) { |
460 |
|
print_spaces(len); |
461 |
|
imm = iw & 7; |
462 |
|
rd = (iw >> 3) & 31; /* A */ |
463 |
|
debug("sbi%s\t0x%x,%i\n", iw & 0x0200? "s" : "c", rd, imm); |
464 |
|
} else if ((iw & 0xf000) == 0xb000) { |
465 |
|
print_spaces(len); |
466 |
|
imm = ((iw & 0x600) >> 5) | (iw & 0xf); |
467 |
|
rr = (iw >> 4) & 31; |
468 |
|
if (iw & 0x800) |
469 |
|
debug("out\t0x%x,r%i\n", imm, rr); |
470 |
|
else |
471 |
|
debug("in\tr%i,0x%x\n", rr, imm); |
472 |
} else if ((iw & 0xe000) == 0xc000) { |
} else if ((iw & 0xe000) == 0xc000) { |
473 |
print_spaces(len); |
print_spaces(len); |
474 |
addr = (int16_t)((iw & 0xfff) << 4); |
addr = (int16_t)((iw & 0xfff) << 4); |
479 |
rd = ((iw >> 4) & 0xf) + 16; |
rd = ((iw >> 4) & 0xf) + 16; |
480 |
imm = ((iw >> 4) & 0xf0) | (iw & 0xf); |
imm = ((iw >> 4) & 0xf0) | (iw & 0xf); |
481 |
debug("ldi\tr%i,0x%x\n", rd, imm); |
debug("ldi\tr%i,0x%x\n", rd, imm); |
482 |
|
} else if ((iw & 0xfc00) == 0xf000) { |
483 |
|
print_spaces(len); |
484 |
|
addr = (iw >> 3) & 0x7f; |
485 |
|
if (addr >= 64) |
486 |
|
addr -= 128; |
487 |
|
addr = (addr + 1) * 2 + dumpaddr; |
488 |
|
debug("brbs\t%c,0x%x\n", sreg_names[iw & 7], addr); |
489 |
|
} else if ((iw & 0xfc00) == 0xf400) { |
490 |
|
print_spaces(len); |
491 |
|
addr = (iw >> 3) & 0x7f; |
492 |
|
if (addr >= 64) |
493 |
|
addr -= 128; |
494 |
|
addr = (addr + 1) * 2 + dumpaddr; |
495 |
|
debug("brbc\t%c,0x%x\n", sreg_names[iw & 7], addr); |
496 |
|
} else if ((iw & 0xfc08) == 0xfc00) { |
497 |
|
print_spaces(len); |
498 |
|
rr = (iw >> 4) & 31; |
499 |
|
imm = iw & 7; |
500 |
|
debug("sbr%s\tr%i,%i\n", iw & 0x0200 ? "s" : "c", rr, imm); |
501 |
} else { |
} else { |
502 |
print_spaces(len); |
print_spaces(len); |
503 |
debug("UNIMPLEMENTED 0x%04x\n", iw); |
debug("UNIMPLEMENTED 0x%04x\n", iw); |