+
+ case M6812_IDIVS:
+ {
+ int32 src1 = (int16) cpu_get_d (cpu);
+ int32 src2 = (int16) cpu_get_x (cpu);
+
+ if (src2 == 0)
+ {
+ cpu_set_ccr_C (cpu, 1);
+ }
+ else
+ {
+ cpu_set_d (cpu, src1 % src2);
+ src1 = src1 / src2;
+ cpu_set_x (cpu, src1);
+ cpu_set_ccr_C (cpu, 0);
+ cpu_set_ccr_Z (cpu, src1 == 0);
+ cpu_set_ccr_N (cpu, src1 & 0x8000);
+ cpu_set_ccr_V (cpu, src1 >= 32768 || src1 < -32768);
+ }
+ }
+ break;
+
+ case M6812_EDIV:
+ {
+ uint32 src1 = (uint32) cpu_get_x (cpu);
+ uint32 src2 = (uint32) (cpu_get_y (cpu) << 16)
+ | (uint32) (cpu_get_d (cpu));
+
+ if (src1 == 0)
+ {
+ cpu_set_ccr_C (cpu, 1);
+ }
+ else
+ {
+ cpu_set_ccr_C (cpu, 0);
+ cpu_set_d (cpu, src2 % src1);
+ src2 = src2 / src1;
+ cpu_set_y (cpu, src2);
+ cpu_set_ccr_Z (cpu, src2 == 0);
+ cpu_set_ccr_N (cpu, (src2 & 0x8000) != 0);
+ cpu_set_ccr_V (cpu, (src2 & 0xffff0000) != 0);
+ }
+ }
+ break;
+
+ case M6812_EDIVS:
+ {
+ int32 src1 = (int16) cpu_get_x (cpu);
+ int32 src2 = (uint32) (cpu_get_y (cpu) << 16)
+ | (uint32) (cpu_get_d (cpu));
+
+ if (src1 == 0)
+ {
+ cpu_set_ccr_C (cpu, 1);
+ }
+ else
+ {
+ cpu_set_ccr_C (cpu, 0);
+ cpu_set_d (cpu, src2 % src1);
+ src2 = src2 / src1;
+ cpu_set_y (cpu, src2);
+ cpu_set_ccr_Z (cpu, src2 == 0);
+ cpu_set_ccr_N (cpu, (src2 & 0x8000) != 0);
+ cpu_set_ccr_V (cpu, src2 > 32767 || src2 < -32768);
+ }
+ }
+ break;
+
+ case M6812_EMULS:
+ {
+ int32 src1, src2;
+
+ src1 = (int16) cpu_get_d (cpu);
+ src2 = (int16) cpu_get_y (cpu);
+ src1 = src1 * src2;
+ cpu_set_d (cpu, src1 & 0x0ffff);
+ cpu_set_y (cpu, src1 >> 16);
+ cpu_set_ccr_Z (cpu, src1 == 0);
+ cpu_set_ccr_N (cpu, (src1 & 0x80000000) != 0);
+ cpu_set_ccr_C (cpu, (src1 & 0x00008000) != 0);
+ }
+ break;
+
+ case M6812_EMACS:
+ {
+ int32 src1, src2;
+ uint16 addr;
+
+ addr = cpu_fetch16 (cpu);
+ src1 = (int16) memory_read16 (cpu, cpu_get_x (cpu));
+ src2 = (int16) memory_read16 (cpu, cpu_get_y (cpu));
+ src1 = src1 * src2;
+ src2 = (((uint32) memory_read16 (cpu, addr)) << 16)
+ | (uint32) memory_read16 (cpu, addr + 2);
+
+ memory_write16 (cpu, addr, (src1 + src2) >> 16);
+ memory_write16 (cpu, addr + 2, (src1 + src2));
+
+
+ }
+ break;
+
+ case M6812_CALL:
+ {
+ uint8 page;
+ uint16 addr;
+
+ addr = cpu_fetch16 (cpu);
+ page = cpu_fetch8 (cpu);
+
+ cpu_m68hc12_push_uint16 (cpu, cpu_get_pc (cpu));
+ cpu_m68hc12_push_uint8 (cpu, cpu_get_page (cpu));
+
+ cpu_set_page (cpu, page);
+ cpu_set_pc (cpu, addr);
+ }
+ break;
+
+ case M6812_CALL_INDIRECT:
+ {
+ uint8 code;
+ uint16 addr;
+ uint8 page;
+
+ code = memory_read8 (cpu, cpu_get_pc (cpu));
+ /* Indirect addressing call has the page specified in the
+ memory location pointed to by the address. */
+ if ((code & 0xE3) == 0xE3)
+ {
+ addr = cpu_get_indexed_operand_addr (cpu, 0);
+ page = memory_read8 (cpu, addr + 2);
+ addr = memory_read16 (cpu, addr);
+ }
+ else
+ {
+ /* Otherwise, page is in the opcode. */
+ addr = cpu_get_indexed_operand16 (cpu, 0);
+ page = cpu_fetch8 (cpu);
+ }
+ cpu_m68hc12_push_uint16 (cpu, cpu_get_pc (cpu));
+ cpu_m68hc12_push_uint8 (cpu, cpu_get_page (cpu));
+ cpu_set_page (cpu, page);
+ cpu_set_pc (cpu, addr);
+ }
+ break;
+
+ case M6812_RTC:
+ {
+ uint8 page = cpu_m68hc12_pop_uint8 (cpu);
+ uint16 addr = cpu_m68hc12_pop_uint16 (cpu);
+
+ cpu_set_page (cpu, page);
+ cpu_set_pc (cpu, addr);
+ }
+ break;
+
+ case M6812_ETBL:
+ default:
+ sim_engine_halt (CPU_STATE (cpu), cpu, NULL,
+ cpu_get_pc (cpu), sim_stopped,
+ SIM_SIGILL);
+ break;