2 * Simulator of microcontrollers (inst.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
10 /* This file is part of microcontroller simulator: ucsim.
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
36 cl_z80::inst_cb_rlc(t_mem code)
57 case 0x06: // RLC (HL)
72 cl_z80::inst_cb_rrc(t_mem code)
93 case 0x0E: // RRC (HL)
108 cl_z80::inst_cb_rl(t_mem code)
129 case 0x16: // RL (HL)
133 store1(regs.HL, tmp);
144 cl_z80::inst_cb_rr(t_mem code)
165 case 0x1E: // RR (HL)
169 store1(regs.HL, tmp);
180 cl_z80::inst_cb_sla(t_mem code)
201 case 0x26: // SLA (HL)
205 store1(regs.HL, tmp);
216 cl_z80::inst_cb_sra(t_mem code)
237 case 0x2E: // SRA (HL)
241 store1(regs.HL, tmp);
252 cl_z80::inst_cb_slia(t_mem code)
255 case 0x30: // SLIA B (Shift Left Inverted Arithmetic)
256 slia_byte(regs.bc.h);
258 case 0x31: // SLIA C like SLA, but shifts in a 1 bit
259 slia_byte(regs.bc.l);
262 slia_byte(regs.de.h);
265 slia_byte(regs.de.l);
268 slia_byte(regs.hl.h);
271 slia_byte(regs.hl.l);
273 case 0x36: // SLIA (HL)
277 store1(regs.HL, tmp);
288 cl_z80::inst_cb_srl(t_mem code)
309 case 0x3E: // SRL (HL)
313 store1(regs.HL, tmp);
325 cl_z80::inst_cb_bit(t_mem code)
327 #define bit_bitnum ((code >> 3) & 7)
331 bit_byte(regs.bc.h, bit_bitnum); break;
333 bit_byte(regs.bc.l, bit_bitnum); break;
335 bit_byte(regs.de.h, bit_bitnum); break;
337 bit_byte(regs.de.l, bit_bitnum); break;
339 bit_byte(regs.hl.h, bit_bitnum); break;
341 bit_byte(regs.hl.l, bit_bitnum); break;
342 case 0x6: // BIT x,(HL)
345 bit_byte(tmp, bit_bitnum);
346 store1(regs.HL, tmp);
350 bit_byte(regs.A, bit_bitnum); break;
357 cl_z80::inst_cb_res(t_mem code)
359 #define bit_bitnum ((code >> 3) & 7)
363 regs.bc.h &= ~(1 << bit_bitnum); break;
365 regs.bc.l &= ~(1 << bit_bitnum); break;
367 regs.de.h &= ~(1 << bit_bitnum); break;
369 regs.de.l &= ~(1 << bit_bitnum); break;
371 regs.hl.h &= ~(1 << bit_bitnum); break;
373 regs.hl.l &= ~(1 << bit_bitnum); break;
374 case 0x6: // RES x,(HL)
377 tmp &= ~(1 << bit_bitnum);
378 store1(regs.HL, tmp);
382 regs.A &= ~(bit_bitnum); break;
388 cl_z80::inst_cb_set(t_mem code)
390 #define bit_bitnum ((code >> 3) & 7)
394 regs.bc.h |= (1 << bit_bitnum); break;
396 regs.bc.l |= (1 << bit_bitnum); break;
398 regs.de.h |= (1 << bit_bitnum); break;
400 regs.de.l |= (1 << bit_bitnum); break;
402 regs.hl.h |= (1 << bit_bitnum); break;
404 regs.hl.h |= (1 << bit_bitnum); break;
405 case 0x6: // SET x,(HL)
408 tmp |= (1 << bit_bitnum);
409 store1(regs.HL, tmp);
413 regs.de.h |= (1 << bit_bitnum); break;
418 /******** start CB codes *****************/
420 cl_z80::inst_cb(void)
425 return(resBREAKPOINT);
435 case 0x06: // RLC (HL)
437 return (inst_cb_rlc(code));
444 case 0x0E: // RRC (HL)
446 return (inst_cb_rrc(code));
453 case 0x16: // RL (HL)
455 return (inst_cb_rl(code));
462 case 0x1E: // RR (HL)
464 return (inst_cb_rr(code));
471 case 0x26: // SLA (HL)
473 return (inst_cb_sla(code));
480 case 0x2E: // SRA (HL)
482 return (inst_cb_sra(code));
483 case 0x30: // SLIA B (Shift Left Inverted Arithmetic)
484 case 0x31: // SLIA C like SLA, but shifts in a 1 bit
489 case 0x36: // SLIA (HL)
491 return (inst_cb_slia(code));
498 case 0x3E: // SRL (HL)
500 return (inst_cb_srl(code));
501 case 0x40: // BIT 0,B
502 case 0x41: // BIT 0,C
503 case 0x42: // BIT 0,D
504 case 0x43: // BIT 0,E
505 case 0x44: // BIT 0,H
506 case 0x45: // BIT 0,L
507 case 0x46: // BIT 0,(HL)
508 case 0x47: // BIT 0,A
509 case 0x48: // BIT 1,B
510 case 0x49: // BIT 1,C
511 case 0x4A: // BIT 1,D
512 case 0x4B: // BIT 1,E
513 case 0x4C: // BIT 1,H
514 case 0x4D: // BIT 1,L
515 case 0x4E: // BIT 1,(HL)
516 case 0x4F: // BIT 1,A
517 case 0x50: // BIT 2,B
518 case 0x51: // BIT 2,C
519 case 0x52: // BIT 2,D
520 case 0x53: // BIT 2,E
521 case 0x54: // BIT 2,H
522 case 0x55: // BIT 2,L
523 case 0x56: // BIT 2,(HL)
524 case 0x57: // BIT 2,A
525 case 0x58: // BIT 3,B
526 case 0x59: // BIT 3,C
527 case 0x5A: // BIT 3,D
528 case 0x5B: // BIT 3,E
529 case 0x5C: // BIT 3,H
530 case 0x5D: // BIT 3,L
531 case 0x5E: // BIT 3,(HL)
532 case 0x5F: // BIT 3,A
533 case 0x60: // BIT 4,B
534 case 0x61: // BIT 4,C
535 case 0x62: // BIT 4,D
536 case 0x63: // BIT 4,E
537 case 0x64: // BIT 4,H
538 case 0x65: // BIT 4,L
539 case 0x66: // BIT 4,(HL)
540 case 0x67: // BIT 4,A
541 case 0x68: // BIT 5,B
542 case 0x69: // BIT 5,C
543 case 0x6A: // BIT 5,D
544 case 0x6B: // BIT 5,E
545 case 0x6C: // BIT 5,H
546 case 0x6D: // BIT 5,L
547 case 0x6E: // BIT 5,(HL)
548 case 0x6F: // BIT 5,A
549 case 0x70: // BIT 6,B
550 case 0x71: // BIT 6,C
551 case 0x72: // BIT 6,D
552 case 0x73: // BIT 6,E
553 case 0x74: // BIT 6,H
554 case 0x75: // BIT 6,L
555 case 0x76: // BIT 6,(HL)
556 case 0x77: // BIT 6,A
557 case 0x78: // BIT 7,B
558 case 0x79: // BIT 7,C
559 case 0x7A: // BIT 7,D
560 case 0x7B: // BIT 7,E
561 case 0x7C: // BIT 7,H
562 case 0x7D: // BIT 7,L
563 case 0x7E: // BIT 7,(HL)
564 case 0x7F: // BIT 7,A
565 return (inst_cb_bit(code));
566 case 0x80: // RES 0,B
567 case 0x81: // RES 0,C
568 case 0x82: // RES 0,D
569 case 0x83: // RES 0,E
570 case 0x84: // RES 0,H
571 case 0x85: // RES 0,L
572 case 0x86: // RES 0,(HL)
573 case 0x87: // RES 0,A
574 case 0x88: // RES 1,B
575 case 0x89: // RES 1,C
576 case 0x8A: // RES 1,D
577 case 0x8B: // RES 1,E
578 case 0x8C: // RES 1,H
579 case 0x8D: // RES 1,L
580 case 0x8E: // RES 1,(HL)
581 case 0x8F: // RES 1,A
582 case 0x90: // RES 2,B
583 case 0x91: // RES 2,C
584 case 0x92: // RES 2,D
585 case 0x93: // RES 2,E
586 case 0x94: // RES 2,H
587 case 0x95: // RES 2,L
588 case 0x96: // RES 2,(HL)
589 case 0x97: // RES 2,A
590 case 0x98: // RES 3,B
591 case 0x99: // RES 3,C
592 case 0x9A: // RES 3,D
593 case 0x9B: // RES 3,E
594 case 0x9C: // RES 3,H
595 case 0x9D: // RES 3,L
596 case 0x9E: // RES 3,(HL)
597 case 0x9F: // RES 3,A
598 case 0xA0: // RES 4,B
599 case 0xA1: // RES 4,C
600 case 0xA2: // RES 4,D
601 case 0xA3: // RES 4,E
602 case 0xA4: // RES 4,H
603 case 0xA5: // RES 4,L
604 case 0xA6: // RES 4,(HL)
605 case 0xA7: // RES 4,A
606 case 0xA8: // RES 5,B
607 case 0xA9: // RES 5,C
608 case 0xAA: // RES 5,D
609 case 0xAB: // RES 5,E
610 case 0xAC: // RES 5,H
611 case 0xAD: // RES 5,L
612 case 0xAE: // RES 5,(HL)
613 case 0xAF: // RES 5,A
614 case 0xB0: // RES 6,B
615 case 0xB1: // RES 6,C
616 case 0xB2: // RES 6,D
617 case 0xB3: // RES 6,E
618 case 0xB4: // RES 6,H
619 case 0xB5: // RES 6,L
620 case 0xB6: // RES 6,(HL)
621 case 0xB7: // RES 6,A
622 case 0xB8: // RES 7,B
623 case 0xB9: // RES 7,C
624 case 0xBA: // RES 7,D
625 case 0xBB: // RES 7,E
626 case 0xBC: // RES 7,H
627 case 0xBD: // RES 7,L
628 case 0xBE: // RES 7,(HL)
629 case 0xBF: // RES 7,A
630 return (inst_cb_res(code));
631 case 0xC0: // SET 0,B
632 case 0xC1: // SET 0,C
633 case 0xC2: // SET 0,D
634 case 0xC3: // SET 0,E
635 case 0xC4: // SET 0,H
636 case 0xC5: // SET 0,L
637 case 0xC6: // SET 0,(HL)
638 case 0xC7: // SET 0,A
639 case 0xC8: // SET 1,B
640 case 0xC9: // SET 1,C
641 case 0xCA: // SET 1,D
642 case 0xCB: // SET 1,E
643 case 0xCC: // SET 1,H
644 case 0xCD: // SET 1,L
645 case 0xCE: // SET 1,(HL)
646 case 0xCF: // SET 1,A
647 case 0xD0: // SET 2,B
648 case 0xD1: // SET 2,C
649 case 0xD2: // SET 2,D
650 case 0xD3: // SET 2,E
651 case 0xD4: // SET 2,H
652 case 0xD5: // SET 2,L
653 case 0xD6: // SET 2,(HL)
654 case 0xD7: // SET 2,A
655 case 0xD8: // SET 3,B
656 case 0xD9: // SET 3,C
657 case 0xDA: // SET 3,D
658 case 0xDB: // SET 3,E
659 case 0xDC: // SET 3,H
660 case 0xDD: // SET 3,L
661 case 0xDE: // SET 3,(HL)
662 case 0xDF: // SET 3,A
663 case 0xE0: // SET 4,B
664 case 0xE1: // SET 4,C
665 case 0xE2: // SET 4,D
666 case 0xE3: // SET 4,E
667 case 0xE4: // SET 4,H
668 case 0xE5: // SET 4,L
669 case 0xE6: // SET 4,(HL)
670 case 0xE7: // SET 4,A
671 case 0xE8: // SET 5,B
672 case 0xE9: // SET 5,C
673 case 0xEA: // SET 5,D
674 case 0xEB: // SET 5,E
675 case 0xEC: // SET 5,H
676 case 0xED: // SET 5,L
677 case 0xEE: // SET 5,(HL)
678 case 0xEF: // SET 5,A
679 case 0xF0: // SET 6,B
680 case 0xF1: // SET 6,C
681 case 0xF2: // SET 6,D
682 case 0xF3: // SET 6,E
683 case 0xF4: // SET 6,H
684 case 0xF5: // SET 6,L
685 case 0xF6: // SET 6,(HL)
686 case 0xF7: // SET 6,A
687 case 0xF8: // SET 7,B
688 case 0xF9: // SET 7,C
689 case 0xFA: // SET 7,D
690 case 0xFB: // SET 7,E
691 case 0xFC: // SET 7,H
692 case 0xFD: // SET 7,L
693 case 0xFE: // SET 7,(HL)
694 case 0xFF: // SET 7,A
695 return (inst_cb_set(code));
700 PC= get_mem_size(MEM_ROM_ID)-1;*/
701 PC= rom->inc_address(PC, -1);
705 /* End of z80.src/inst_cb.cc */