trunk/src/emu/cpu/avr8/avr8.c
| r18712 | r18713 | |
| 23 | 23 | |
| 24 | 24 | #define VERBOSE_LEVEL (0) |
| 25 | 25 | |
| 26 | | #define ENABLE_VERBOSE_LOG (1) |
| 26 | #define ENABLE_VERBOSE_LOG (0) |
| 27 | 27 | |
| 28 | 28 | #if ENABLE_VERBOSE_LOG |
| 29 | 29 | INLINE void verboselog(UINT16 pc, int n_level, const char *s_fmt, ...) |
| r18712 | r18713 | |
| 240 | 240 | // - Interrupts |
| 241 | 241 | static void avr8_set_irq_line(avr8_state *cpustate, UINT16 vector, int state); |
| 242 | 242 | static void avr8_update_interrupt_internal(avr8_state *cpustate, int source); |
| 243 | | static void avr8_poll_interrupt(avr8_state *cpustate); |
| 243 | //static void avr8_poll_interrupt(avr8_state *cpustate); |
| 244 | 244 | |
| 245 | 245 | // - Timers |
| 246 | 246 | static void avr8_timer_tick(avr8_state *cpustate, int cycles); |
| r18712 | r18713 | |
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | | static void avr8_poll_interrupt(avr8_state *cpustate) |
| 432 | /*static void avr8_poll_interrupt(avr8_state *cpustate) |
| 433 | 433 | { |
| 434 | 434 | for (int idx = 0; idx < AVR8_INTIDX_COUNT; idx++) |
| 435 | 435 | { |
| 436 | 436 | avr8_update_interrupt_internal(cpustate, idx); |
| 437 | 437 | } |
| 438 | | } |
| 438 | }*/ |
| 439 | 439 | |
| 440 | 440 | void avr8_update_interrupt(device_t *device, int source) |
| 441 | 441 | { |
| r18712 | r18713 | |
| 1132 | 1132 | |
| 1133 | 1133 | while (cpustate->icount > 0) |
| 1134 | 1134 | { |
| 1135 | opcycles = 1; |
| 1136 | |
| 1135 | 1137 | cpustate->pc &= cpustate->addr_mask; |
| 1136 | 1138 | |
| 1137 | 1139 | debugger_instruction_hook(device, cpustate->pc << 1); |
| r18712 | r18713 | |
| 1353 | 1355 | switch(op & 0x0208) |
| 1354 | 1356 | { |
| 1355 | 1357 | case 0x0000: // LDD Rd,Z+q |
| 1356 | | //output += sprintf( output, "LD(D) R%d, Z+%02x", RD5(op), QCONST6(op) ); |
| 1357 | | unimplemented_opcode(cpustate, op); |
| 1358 | cpustate->r[RD5(op)] = READ_IO_8(cpustate, ZREG + QCONST6(op)); |
| 1359 | opcycles = 2; |
| 1358 | 1360 | break; |
| 1359 | 1361 | case 0x0008: // LDD Rd,Y+q |
| 1360 | 1362 | cpustate->r[RD5(op)] = READ_IO_8(cpustate, YREG + QCONST6(op)); |
| r18712 | r18713 | |
| 1433 | 1435 | break; |
| 1434 | 1436 | case 0x000c: // LD Rd,X |
| 1435 | 1437 | cpustate->r[RD5(op)] = READ_IO_8(cpustate, XREG); |
| 1438 | opcycles = 2; |
| 1436 | 1439 | break; |
| 1437 | 1440 | case 0x000d: // LD Rd,X+ |
| 1438 | 1441 | pd = XREG; |
| r18712 | r18713 | |
| 1485 | 1488 | pd++; |
| 1486 | 1489 | cpustate->r[29] = (pd >> 8) & 0x00ff; |
| 1487 | 1490 | cpustate->r[28] = pd & 0x00ff; |
| 1491 | opcycles = 2; |
| 1488 | 1492 | break; |
| 1489 | 1493 | case 0x000a: // ST -Z,Rd |
| 1490 | 1494 | //output += sprintf( output, "ST -Y , R%d", RD5(op) ); |
| r18712 | r18713 | |
| 1499 | 1503 | pd++; |
| 1500 | 1504 | cpustate->r[27] = (pd >> 8) & 0x00ff; |
| 1501 | 1505 | cpustate->r[26] = pd & 0x00ff; |
| 1506 | opcycles = 2; |
| 1502 | 1507 | break; |
| 1503 | 1508 | case 0x000e: // ST -X,Rd |
| 1504 | 1509 | //output += sprintf( output, "ST -X , R%d", RD5(op) ); |
| r18712 | r18713 | |
| 1742 | 1747 | //printf("Pop: %04x\n", cpustate->pc); |
| 1743 | 1748 | cpustate->pc--; |
| 1744 | 1749 | SREG_W(AVR8_SREG_I, 1); |
| 1745 | | if (cpustate->interrupt_pending) |
| 1750 | /*if (cpustate->interrupt_pending) |
| 1746 | 1751 | { |
| 1747 | 1752 | avr8_poll_interrupt(cpustate); |
| 1748 | 1753 | cpustate->interrupt_pending = false; |
| 1749 | | } |
| 1754 | }*/ |
| 1750 | 1755 | opcycles = 4; |
| 1751 | 1756 | break; |
| 1752 | 1757 | case 0x0080: // SLEEP |
| r18712 | r18713 | |
| 1856 | 1861 | case 0x0900: // SBIC A,b |
| 1857 | 1862 | if(NOT(BIT(READ_IO_8(cpustate, 32 + ACONST5(op)), (1 << RR3(op))))) |
| 1858 | 1863 | { |
| 1859 | | opcycles += avr8_is_long_opcode(op) ? 2 : 1; |
| 1864 | opcycles = avr8_is_long_opcode(op) ? 3 : 2; |
| 1860 | 1865 | cpustate->pc += avr8_is_long_opcode(op) ? 2 : 1; |
| 1861 | 1866 | } |
| 1862 | 1867 | break; |
| r18712 | r18713 | |
| 1867 | 1872 | case 0x0b00: // SBIS A,b |
| 1868 | 1873 | if(BIT(READ_IO_8(cpustate, 32 + ACONST5(op)), (1 << RR3(op)))) |
| 1869 | 1874 | { |
| 1870 | | opcycles += avr8_is_long_opcode(op) ? 2 : 1; |
| 1875 | opcycles = avr8_is_long_opcode(op) ? 3 : 2; |
| 1871 | 1876 | cpustate->pc += avr8_is_long_opcode(op) ? 2 : 1; |
| 1872 | 1877 | } |
| 1873 | 1878 | break; |