src/emu/cpu/z8/z8.c
| r5552 | r5553 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | 14 | - expose register file to disassembler |
| 15 | | - arithmetic opcodes |
| 15 | - decimal adjust instruction |
| 16 | 16 | - interrupts |
| 17 | 17 | - counter/timer |
| 18 | 18 | - serial |
| r5552 | r5553 | |
| 52 | 52 | Z8_REGISTER_SPL |
| 53 | 53 | }; |
| 54 | 54 | |
| 55 | #define Z8_P3_DAV0_RDY0 0x04 /* not supported */ |
| 56 | #define Z8_P3_DAV1_RDY1 0x08 /* not supported */ |
| 57 | #define Z8_P3_DAV2_RDY2 0x02 /* not supported */ |
| 58 | #define Z8_P3_IRQ0 0x04 /* not supported */ |
| 59 | #define Z8_P3_IRQ1 0x08 /* not supported */ |
| 60 | #define Z8_P3_IRQ2 0x02 /* not supported */ |
| 61 | #define Z8_P3_IRQ3 0x01 /* not supported */ |
| 62 | #define Z8_P3_DI 0x01 /* not supported */ |
| 63 | #define Z8_P3_DO 0x80 /* not supported */ |
| 64 | #define Z8_P3_TIN 0x02 /* not supported */ |
| 65 | #define Z8_P3_TOUT 0x40 /* not supported */ |
| 66 | #define Z8_P3_DM 0x10 /* not supported */ |
| 67 | |
| 55 | 68 | #define Z8_P01M_P0L_MODE_MASK 0x03 |
| 56 | 69 | #define Z8_P01M_P0L_MODE_OUTPUT 0x00 |
| 57 | 70 | #define Z8_P01M_P0L_MODE_INPUT 0x01 |
| r5552 | r5553 | |
| 69 | 82 | #define Z8_P01M_P0H_MODE_A12_A15 0x80 /* not supported */ |
| 70 | 83 | |
| 71 | 84 | #define Z8_P3M_P2_ACTIVE_PULLUPS 0x01 /* not supported */ |
| 72 | | #define Z8_P3M_P0_STROBED 0x04 |
| 85 | #define Z8_P3M_P0_STROBED 0x04 /* not supported */ |
| 73 | 86 | #define Z8_P3M_P1_MODE_MASK 0x18 |
| 74 | 87 | //#define Z8_P3M_ 0x00 |
| 75 | 88 | //#define Z8_P3M_ 0x08 |
| 76 | 89 | //#define Z8_P3M_ 0x10 |
| 77 | | #define Z8_P3M_P1_STROBED 0x18 |
| 78 | | #define Z8_P3M_P2_STROBED 0x20 |
| 90 | #define Z8_P3M_P1_STROBED 0x18 /* not supported */ |
| 91 | #define Z8_P3M_P2_STROBED 0x20 /* not supported */ |
| 79 | 92 | #define Z8_P3M_P3_SERIAL 0x40 /* not supported */ |
| 80 | 93 | #define Z8_P3M_PARITY 0x80 /* not supported */ |
| 81 | 94 | |
| r5552 | r5553 | |
| 117 | 130 | /* registers */ |
| 118 | 131 | UINT16 pc; /* program counter */ |
| 119 | 132 | UINT8 r[256]; /* register file */ |
| 120 | | UINT16 fake_sp; /* fake stack pointer */ |
| 121 | | UINT8 fake_rp; /* fake register pointer */ |
| 122 | | UINT8 fake_r[16]; /* fake working registers */ |
| 123 | 133 | UINT8 input[4]; /* port input latches */ |
| 124 | 134 | UINT8 output[4]; /* port output latches */ |
| 125 | 135 | |
| 136 | /* fake registers */ |
| 137 | UINT16 fake_sp; /* fake stack pointer */ |
| 138 | UINT8 fake_r[16]; /* fake working registers */ |
| 139 | |
| 126 | 140 | /* interrupts */ |
| 127 | 141 | int irq[4]; /* external interrupt flip-flops */ |
| 128 | 142 | |
| r5552 | r5553 | |
| 532 | 546 | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { illegal, 0, 0 }, |
| 533 | 547 | |
| 534 | 548 | { decw_RR1, 10, 5 },{ decw_IR1, 10, 5 },{ lde_r1_Irr2, 12, 0 }, { ldei_Ir1_Irr2, 18, 0 },{ illegal, 0, 0 }, { illegal, 0, 0 }, { illegal, 0, 0 }, { illegal, 0, 0 }, |
| 535 | | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { illegal, 0, 0 }, |
| 549 | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { di, 6, 1 }, |
| 536 | 550 | |
| 537 | 551 | { rl_R1, 6, 5 }, { rl_IR1, 6, 5 }, { lde_r2_Irr1, 12, 0 }, { ldei_Ir2_Irr1, 18, 0 },{ illegal, 0, 0 }, { illegal, 0, 0 }, { illegal, 0, 0 }, { illegal, 0, 0 }, |
| 538 | | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { di, 6, 1 }, |
| 552 | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { ei, 6, 1 }, |
| 539 | 553 | |
| 540 | 554 | { incw_RR1, 10, 5 },{ incw_IR1, 10, 5 },{ cp_r1_r2, 6, 5 }, { cp_r1_Ir2, 6, 5 }, { cp_R2_R1, 10, 5 }, { cp_IR2_R1, 10, 5 }, { cp_R1_IM, 10, 5 }, { cp_IR1_IM, 10, 5 }, |
| 541 | | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { ei, 6, 1 }, |
| 555 | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { ret, 14, 0 }, |
| 542 | 556 | |
| 543 | 557 | { clr_R1, 6, 5 }, { clr_IR1, 6, 5 }, { xor_r1_r2, 6, 5 }, { xor_r1_Ir2, 6, 5 }, { xor_R2_R1, 10, 5 }, { xor_IR2_R1, 10, 5 }, { xor_R1_IM, 10, 5 }, { xor_IR1_IM, 10, 5 }, |
| 544 | | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { ret, 14, 0 }, |
| 558 | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { iret, 16, 0 }, |
| 545 | 559 | |
| 546 | 560 | { rrc_R1, 6, 5 }, { rrc_IR1, 6, 5 }, { ldc_r1_Irr2, 12, 0 }, { ldci_Ir1_Irr2, 18, 0 },{ illegal, 0, 0 }, { illegal, 0, 0 }, { illegal, 0, 0 }, { ld_r1_x_R2, 10, 5 }, |
| 547 | | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { iret, 16, 0 }, |
| 561 | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { rcf, 6, 5 }, |
| 548 | 562 | |
| 549 | 563 | { sra_R1, 6, 5 }, { sra_IR1, 6, 5 }, { ldc_r2_Irr1, 12, 0 }, { ldci_Ir2_Irr1, 18, 0 },{ call_IRR1, 20, 0 }, { illegal, 0, 0 }, { call_DA, 20, 0 }, { ld_r2_x_R1, 10, 5 }, |
| 550 | 564 | { ld_r1_R2, 6, 5 }, { ld_r2_R1, 6, 5 }, { djnz_r1_RA, 10, 5 }, { jr_cc_RA, 10, 0 }, { ld_r1_IM, 6, 5 }, { jp_cc_DA, 10, 0 }, { inc_r1, 6, 5 }, { scf, 6, 5 }, |
| r5552 | r5553 | |
| 577 | 591 | /* register for state saving */ |
| 578 | 592 | state_save_register_device_item(device, 0, cpustate->pc); |
| 579 | 593 | state_save_register_device_item_array(device, 0, cpustate->r); |
| 594 | state_save_register_device_item_array(device, 0, cpustate->input); |
| 595 | state_save_register_device_item_array(device, 0, cpustate->output); |
| 596 | state_save_register_device_item_array(device, 0, cpustate->irq); |
| 580 | 597 | } |
| 581 | 598 | |
| 582 | 599 | /*************************************************************************** |
| r5552 | r5553 | |
| 640 | 657 | AM_RANGE(0x0000, 0x0fff) AM_ROM |
| 641 | 658 | ADDRESS_MAP_END |
| 642 | 659 | |
| 643 | | static ADDRESS_MAP_START( register_128b, ADDRESS_SPACE_DATA, 8 ) |
| 644 | | AM_RANGE(0x0000, 0x007f) AM_RAM |
| 645 | | AM_RANGE(0x00f0, 0x00ff) AM_RAM |
| 646 | | ADDRESS_MAP_END |
| 647 | | |
| 648 | 660 | /************************************************************************** |
| 649 | 661 | * STATE IMPORT/EXPORT |
| 650 | 662 | **************************************************************************/ |
| r5552 | r5553 | |
| 778 | 790 | { |
| 779 | 791 | /* --- the following bits of info are returned as pointers --- */ |
| 780 | 792 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: info->internal_map8 = ADDRESS_MAP_NAME(program_2kb); break; |
| 781 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA: info->internal_map8 = ADDRESS_MAP_NAME(register_128b); break; |
| 782 | 793 | |
| 783 | 794 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 784 | 795 | case DEVINFO_STR_NAME: strcpy(info->s, "Z8601"); break; |
| r5552 | r5553 | |
| 793 | 804 | { |
| 794 | 805 | /* --- the following bits of info are returned as pointers --- */ |
| 795 | 806 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: info->internal_map8 = ADDRESS_MAP_NAME(program_2kb); break; |
| 796 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA: info->internal_map8 = ADDRESS_MAP_NAME(register_128b); break; |
| 797 | 807 | |
| 798 | 808 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 799 | 809 | case DEVINFO_STR_NAME: strcpy(info->s, "UB8830D"); break; |
| r5552 | r5553 | |
| 808 | 818 | { |
| 809 | 819 | /* --- the following bits of info are returned as pointers --- */ |
| 810 | 820 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_PROGRAM: info->internal_map8 = ADDRESS_MAP_NAME(program_4kb); break; |
| 811 | | case CPUINFO_PTR_INTERNAL_MEMORY_MAP_DATA: info->internal_map8 = ADDRESS_MAP_NAME(register_128b); break; |
| 812 | 821 | |
| 813 | 822 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 814 | 823 | case DEVINFO_STR_NAME: strcpy(info->s, "Z8611"); break; |