1 #include "rockmacros.h"
12 void *dynapointer
,*branchp
[10];
17 #define DWRITEB(a) *((unsigned char *) dynapointer)=(a); dynapointer+=1
18 #define DWRITEW(a) *((unsigned short *) dynapointer)=(a); dynapointer+=2
19 #define DWRITEL(a) *((unsigned long *) dynapointer)=(a); dynapointer+=4
20 #define FETCH (readb(PC++))
28 #define GETUPPER(src,dest) \
29 DYNA_MOVE_l_i_to_r(0xFF00,(dest)); \
30 DYNA_AND_l_r_to_r((src),(dest)); \
31 DYNA_ASHIFT_l(0,(dest),0,0)
39 #define PUTUPPER(src,dest) \
40 DYNA_AND_l_i_to_r(0xFF,(dest)); \
41 DYNA_AND_l_i_to_r(0xFF,(src)); \
42 DYNA_ASHIFT_l(0,(src),1,0); \
43 DYNA_OR_l_r_to_r((src),(dest))
46 * movem.l d1-d7/a0-a1 , (%a3)
49 * movem.l (%a3), d1-d7/a0-a1
51 #define CALL_NATIVE(n) \
52 DYNA_MOVEA_l_i_to_r(&cpu.a,3); \
53 DYNA_MOVEM(3,0x3FE,0); \
55 DYNA_MOVEA_l_i_to_r(&cpu.a,3); \
56 DYNA_MOVEM(3,0x3FE,1);
59 * SUBQ 2, %a0 decrease gb sp
62 * call_native writew(SP, (n))
66 DYNA_SUBQ_l_i_to_r(2,0,1); \
69 CALL_NATIVE(&writew); \
70 DYNA_ADDQ_l_i_to_r(0,7,1);
74 * call_native readw(SP);
82 CALL_NATIVE(&readw); \
83 DYNA_ADDQ_l_i_to_r(4,7,1); \
84 DYNA_ADDQ_l_i_to_r(2,0,1); \
85 DYNA_MOVEA_w_r_to_r(0,(n),0);
88 DYNA_MOVEQ_l_i_to_r(0x0,7); \
89 DYNA_MOVE_l_r_to_r(1,0,0); \
90 DYNA_ADD_l_r_to_r((n),1); \
91 DYNA_XOR_l_r_to_r(1,0); \
92 DYNA_XOR_l_r_to_r((n),0); \
93 DYNA_LSHIFT_l(1,0,1,0); \
94 DYNA_AND_l_i_to_r(0x20,0); \
95 DYNA_OR_l_r_to_r(0,7); \
97 DYNA_SET_b_r(0,0x7); \
98 DYNA_AND_l_i_to_r(0x80,0); \
99 DYNA_OR_l_r_to_r(0,7); \
100 DYNA_MOVE_l_r_to_r(1,0,0); \
101 DYNA_LSHIFT_l(4,0,0,0); \
102 DYNA_ANDI_l_i_to_r(0x10,0); \
103 DYNA_OR_l_r_to_r(0,7); \
104 DYNA_AND_l_i_to_r(0xFF,1);
106 #define SUBTRACT(n) \
107 DYNA_MOVEQ_l_i_to_r(0x40,7); \
108 DYNA_MOVE_l_r_to_r(1,0,0); \
109 DYNA_SUB_l_r_to_r((n),1,0); \
110 DYNA_XOR_l_r_to_r(1,0); \
111 DYNA_XOR_l_r_to_r((n),0); \
112 DYNA_LSHIFT_l(1,0,1,0); \
113 DYNA_AND_l_i_to_r(0x20,0); \
114 DYNA_OR_l_r_to_r(0,7); \
116 DYNA_SET_b_r(0,0x7); \
117 DYNA_AND_l_i_to_r(0x80,0); \
118 DYNA_OR_l_r_to_r(0,7); \
119 DYNA_MOVE_l_r_to_r(1,0,0); \
120 DYNA_LSHIFT_l(4,0,0,0); \
121 DYNA_AND_l_i_to_r(0x10,0); \
122 DYNA_OR_l_r_to_r(0,7);
125 DYNA_MOVEA_l_r_to_r(1,3,0); \
127 DYNA_MOVE_l_r_to_r(3,1,1);
131 DYNA_ANDI_l_i_to_r(0xFF,1);
134 void DYNA_MOVE_b_r_to_r(un8 src
,un8 dest
)
136 DWRITEW(0x1000|(src
&0x7)|(dest
&0x7)<<9);
139 void DYNA_ASHIFT_l(un8 src
, un8 dest
, int left
, int src_is_reg
)
141 unsigned short opcode
;
142 opcode
=(0xE080)|((src
&0x7)<<9)|(dest
&0x7);
150 void DYNA_LSHIFT_l(un8 src
, un8 dest
, int left
, int src_is_reg
)
152 unsigned short opcode
=0xE088|((src
&0x7)<<9)|(dest
&0x7);
160 void DYNA_MOVE_l_i_to_r(un32 imm
, un8 dest
)
162 DWRITEW(0x203C|(dest
&0x7)<<9);
163 DWRITEL(imm
); /* endianness? */
166 void DYNA_MOVE_l_i_to_m(un32 imm
, un8 dest_a
)
168 DWRITEW(0x20FC|((dest_a
&0x7)<<9));
172 void DYNA_MOVE_l_r_to_m(un8 src
,un8 dest_a
)
174 DWRITEW(0x2080|(dest_a
&0x7)<<9|(src
&0x7));
177 void DYNA_MOVE_l_r_to_r(un8 src
, un8 dest
, int src_is_areg
)
179 unsigned short opcode
=0x2000|((dest
&0x7)<<9)|(src
&0x7);
185 void DYNA_MOVE_w_r_to_r(un8 src
, un8 dest
, int src_is_areg
)
187 unsigned short opcode
=0x3000|((dest
&0x7)<<9)|(src
&0x7);
193 void DYNA_MOVEQ_l_i_to_r(un8 imm
, un8 dest
)
195 DWRITEW(0x7000|((dest
&0x7)<<9)|imm
);
198 void DYNA_PEA_w_i(un16 imm
)
204 void DYNA_PUSH_l_r(un8 reg
,int src_is_areg
)
206 unsigned short value
= 0x2F00|(reg
&0x7);
212 void DYNA_MOVEA_l_i_to_r(un32 imm
, un8 dest
)
214 DWRITEW(0x207C|(dest
&0x7)<<9);
218 void DYNA_MOVEA_w_r_to_r(un8 src
, un8 dest
, int src_is_areg
)
220 unsigned short value
=0x3040|((dest
&0x7)<<9)|(src
&0x7);
226 void DYNA_MOVEA_l_r_to_r(un8 src
, un8 dest
, int src_is_areg
)
228 unsigned short value
=0x2040|((dest
&0x7)<<9)|(src
&0x7);
240 void DYNA_AND_l_i_to_r(un32 imm
, un8 dest
)
242 DWRITEW(0x0280|(dest
&0x7));
246 void DYNA_AND_l_r_to_r(un8 src
,un8 dest
)
248 DWRITEW(0xC080|((dest
&0x7)<<9)|(src
&0x7));
251 void DYNA_OR_l_r_to_r(un8 src
,un8 dest
)
253 DWRITEW(0x8080|((dest
&0x7)<<9)|(src
&0x7));
256 void DYNA_OR_l_i_to_r(un32 imm
,un8 dest
)
258 DWRITEW(0x0080|(dest
&0x7));
262 void DYNA_CLR_l_m(un32 addr
)
268 void DYNA_CLR_l_r(un8 reg
)
270 DWRITEW(0x4280|(reg
&0x7));
273 void DYNA_CLR_w_r(un8 reg
)
275 DWRITEW(0x42C0|(reg
&0x7));
279 void DYNA_CLR_b_r(un8 reg
)
281 DWRITEW(0x4200|(reg
&0x7));
285 void DYNA_ADDQ_l_i_to_r(un8 imm
, un8 reg
, int dest_is_a
)
287 unsigned short value
=0x5080|(imm
&0x7)<<9|(reg
&0x7);
293 void DYNA_ADD_l_r_to_r(un8 src
, un8 dest
, int src_is_areg
)
295 unsigned short value
=0xD080|((dest
&0x7)<<9)|(src
&0x7);
301 void DYNA_JSR(void *addr
)
307 void DYNA_MOVEM(un8 areg
,un16 mask
, int frommem
)
309 unsigned short value
=0x48D0|(areg
&0x7);
316 void DYNA_SUBQ_l_i_to_r(un8 imm
, un8 reg
, int addr_reg
)
318 unsigned short value
=0x5180|(reg
&0x7)|((imm
&0x7)<<9);
324 void DYNA_SUB_l_r_to_r(un8 src
, un8 dest
, int is_areg
)
326 unsigned short value
=0x9080|((dest
&0x7)<<9)|(src
&0x7);
332 void DYNA_EXT_l(un8 reg
)
334 DWRITEW(0x48C0|(reg
&0x7));
337 void DYNA_BCC_c(un8 cond
, int size
,int i
)
339 un32 displace
=dynapointer
-branchp
[i
];
342 die("Dynarec error! BCC trying to write branch without dummy");
345 if((size
==2&&displace
>0x7f) || (size
==4 && displace
>0x7FFF))
346 die("Dynarec error! BCC invalid displacement");
347 else if(displace
>0&&displace
<0x7F)
348 *( (unsigned short *) branchp
[i
])=0x6000|((cond
&0xF)<<8)|(displace
&0xFF);
349 else if(displace
>0x7F&&displace
<0x7FFF)
351 *( (unsigned short *) branchp
[i
])=0x6000|((cond
&0xF)<<8);
353 *( (unsigned short *) branchp
[i
])=displace
;
356 die("Dynarec error! BCC invalid displacement");
361 void DYNA_DUMMYBRANCH(int size
,int i
)
363 branchp
[i
]=dynapointer
;
367 void DYNA_TST_l_r(un8 reg
,int is_areg
)
369 unsigned short opcode
=0x4A80|(reg
&0x7);
375 void DYNA_TST_b_r(un8 reg
,int is_areg
)
377 unsigned short opcode
=0x4A00|(reg
&0x7);
384 void DYNA_BTST_l_r(un8 bit
, un8 reg
)
386 DWRITEW(0x0800|(reg
&0x7));
390 void DYNA_NEG_l(un8 reg
)
392 DWRITEW(0x4480|(reg
&0x7));
395 void DYNA_XOR_l_r_to_r(un8 src
, un8 dest
)
397 DWRITEW(0xB180|((dest
&0x7)<<9)|(src
&0x7));
400 void DYNA_SET_b_r(un8 src
, un8 cond
)
402 DWRITEW(0x50C0|((cond
)&0xF)<<8|(src
&0x7));
405 void DYNA_INC_l_r(un8 dest
,int is_areg
)
407 DYNA_ADDQ_l_i_to_r(1,dest
,is_areg
);
410 void DYNA_DEC_l_r(un8 dest
,int is_areg
)
412 DYNA_SUBQ_l_i_to_r(1,dest
,is_areg
);
416 void dynamic_recompile (struct dynarec_block
*newblock
)
418 int done
=0,writepc
=1,fd
;
420 unsigned int oldpc
=PC
;
422 unsigned int tclen
=0,clen
;
424 dynapointer
=malloc(512);
425 newblock
->block
=dynapointer
;
427 snprintf(meow
,499,"/dyna_0x%x_asm.rb",PC
);
428 fd
=open(meow
,O_WRONLY
|O_CREAT
|O_TRUNC
, 0666);
431 die("couldn't open dyna debug file");
435 snprintf(meow
,499,"Recompiling 0x%x",oldpc
);
436 rb
->splash(HZ
*1,meow
);
440 fdprintf(fd
,"0x%x: ",PC
);
443 clen
= cycles_table
[op
];
448 case 0x01: /* LD BC,imm */
449 /* warning (do we have endianness right?) */
451 fdprintf(fd
,"LD BC,#0x%x\n",readw(xPC
));
454 DYNA_MOVEQ_l_i_to_r((temp
&0xFF00)>>8,2);
455 DYNA_MOVEQ_l_i_to_r(temp
&0xFF,3);
458 case 0x02: /* LD (BC),A */
460 fdprintf(fd
, "LD (BC),A\n");
462 break; /* FIXME: Implement */
463 case 0x03: /* INC BC */
465 fdprintf(fd
, "INC BC\n");
467 break; /* FIXME: Implement */
468 case 0x04: /* INC B */
470 fdprintf(fd
, "INC B\n");
472 DYNA_INC_l_r(2,0); /* Is this right? */
474 case 0x05: /* DEC B */
476 fdprintf(fd
, "DEC B\n");
478 DYNA_DEC_l_r(2,0); /* Is this right? */
480 case 0x06: /* LD B,imm */
482 fdprintf(fd
,"LD B,#0x%x\n",readb(xPC
));
484 DYNA_MOVEQ_l_i_to_r(FETCH
,2);
486 case 0x07: /* RLCA */
488 fdprintf(fd
, "RLCA\n");
490 break; /* FIXME: Implement */
491 case 0x08: /* LD imm,SP */
493 fdprintf(fd
, "LD imm,SP\n");
495 break; /* FIXME: Implement */
496 case 0x09: /* ADD HL,BC */
498 fdprintf(fd
, "ADD HL,BC\n");
500 break; /* FIXME: Implement */
501 case 0x0A: /* LD A,(BC) */
503 fdprintf(fd
, "LD A,(BC)\n");
505 break; /* FIXME: Implement */
506 case 0x0B: /* DEC BC */
508 fdprintf(fd
,"DEC BC\n");
510 DYNA_TST_b_r(3,0); /* test C */
511 DYNA_DUMMYBRANCH(2,0);
512 DYNA_DEC_l_r(2,0); /* dec B */
513 DYNA_BCC_c(0x6,2,0); /* jump here if not zero */
514 DYNA_DEC_l_r(3,0); /* dec C */
516 case 0x0C: /* INC C */
518 fdprintf(fd
, "INC C\n");
520 DYNA_INC_l_r(3,0); /* Is this right? */
522 case 0x0D: /* DEC C */
524 fdprintf(fd
, "DEC C\n");
526 DYNA_DEC_l_r(3,0); /* Is this right? */
528 case 0x0E: /* LD C,imm */
530 fdprintf(fd
,"LD C,#0x%x\n",readb(xPC
));
532 DYNA_MOVEQ_l_i_to_r(FETCH
,3);
534 case 0x0F: /* RRCA */
536 fdprintf(fd
, "RRCA\n");
538 break; /* FIXME: Implement */
539 case 0x10: /* STOP */
541 fdprintf(fd
, "STOP\n");
543 break; /* FIXME: Implement */
544 case 0x11: /* LD DE,imm */
546 fdprintf(fd
,"LD DE,#0x%x\n",readw(xPC
));
549 DYNA_MOVEQ_l_i_to_r((temp
&0xFF00)>>8,4);
550 DYNA_MOVEQ_l_i_to_r(temp
&0xFF,5);
553 case 0x12: /* LD (DE),A */
555 fdprintf(fd
, "LD (DE),A\n");
557 break; /* FIXME: Implement */
558 case 0x13: /* INC DE */
560 fdprintf(fd
, "INC DE\n");
562 break; /* FIXME: Implement */
563 case 0x14: /* INC D */
565 fdprintf(fd
, "INC D\n");
567 DYNA_INC_l_r(4,0); /* Is this right? */
569 case 0x15: /* DEC D */
571 fdprintf(fd
, "DEC D\n");
573 DYNA_DEC_l_r(4,0); /* Is this right? */
575 case 0x16: /* LD D,imm */
577 fdprintf(fd
,"LD D,#0x%x\n",readb(xPC
));
579 DYNA_MOVEQ_l_i_to_r(FETCH
,4);
583 fdprintf(fd
, "RLA\n");
585 break; /* FIXME: Implement */
588 fdprintf(fd
, "JR\n");
590 break; /* FIXME: Implement */
591 case 0x19: /* ADD HL,DE */
593 fdprintf(fd
, "ADD HL,DE\n");
595 break; /* FIXME: Implement */
596 case 0x1A: /* LD A,(DE) */
598 fdprintf(fd
, "LD A,(DE)\n");
600 break; /* FIXME: Implement */
601 case 0x1B: /* DEC DE */
603 fdprintf(fd
,"DEC DE\n");
605 DYNA_TST_b_r(5,0); /* test E */
606 DYNA_DUMMYBRANCH(4,0);
607 DYNA_DEC_l_r(4,0); /* dec D */
608 DYNA_BCC_c(0x6,4,0); /* jump here if not zero */
609 DYNA_DEC_l_r(5,0); /* dec E */
611 case 0x1C: /* INC E */
613 fdprintf(fd
, "INC E\n");
615 DYNA_INC_l_r(5,0); /* Is this right? */
617 case 0x1D: /* DEC E */
619 fdprintf(fd
, "DEC E\n");
621 DYNA_DEC_l_r(5,0); /* Is this right? */
623 case 0x1E: /* LD E,imm */
625 fdprintf(fd
,"LD E,#0x%x\n",readb(xPC
));
627 DYNA_MOVEQ_l_i_to_r(FETCH
,5);
631 fdprintf(fd
, "RRA\n");
633 break; /* FIXME: Implement */
634 case 0x20: /* JR NZ */
636 fdprintf(fd
,"JR NZ\n");
638 DYNA_BTST_l_r(8,7); /* btst #8,d7 */
639 DYNA_DUMMYBRANCH(2,0);
640 DYNA_MOVEA_l_i_to_r(&blockclen
,3);
641 DYNA_MOVE_l_i_to_m(tclen
,3);
642 DYNA_MOVEA_l_i_to_r(PC
+1+(signed char)readb(PC
),1);
644 DYNA_BCC_c(0x6,2,0); /* jump here if bit is not zero */
648 case 0x21: /* LD HL,imm */
650 fdprintf(fd
,"LD HL,#0x%x\n",readw(xPC
));
652 DYNA_MOVE_l_i_to_r(readw(xPC
),6);
655 case 0x22: /* LDI (HL), A */
657 fdprintf(fd
,"LDI (HL),A\n");
659 /* DYNA_PUSH_l_r(1,0);
661 CALL_NATIVE(&writeb);
662 DYNA_ADDQ_l_i_to_r(0,7,1);
665 case 0x23: /* INC HL */
667 fdprintf(fd
, "INC HL\n");
669 break; /* FIXME: Implement */
670 case 0x24: /* INC H */
672 fdprintf(fd
, "INC H\n");
674 break; /* FIXME: Implement */
675 case 0x25: /* DEC H */
677 fdprintf(fd
, "DEC H\n");
679 break; /* FIXME: Implement */
680 case 0x26: /* LD H,imm */
682 fdprintf(fd
,"LD H,#0x%x\n",readb(xPC
));
684 DYNA_AND_l_i_to_r(0xFF,6);
685 DYNA_OR_l_i_to_r(FETCH
<<8,6);
689 fdprintf(fd
, "DAA\n");
691 break; /* FIXME: Implement */
692 case 0x28: /* JR Z */
694 fdprintf(fd
, "JR Z\n");
696 break; /* FIXME: Implement */
697 case 0x29: /* ADD HL, HL */
699 fdprintf(fd
, "ADD HL,HL\n");
701 break; /* FIXME: Implement */
702 case 0x2A: /* LD A,(HLI) */
704 fdprintf(fd
, "LD A,(HLI)\n");
706 break; /* FIXME: Implement */
707 case 0x2B: /* DEC HL */
709 fdprintf(fd
, "DEC HL\n");
711 break; /* FIXME: Implement */
712 case 0x2C: /* INC L */
714 fdprintf(fd
, "INC L\n");
716 break; /* FIXME: Implement */
717 case 0x2D: /* DEC L */
719 fdprintf(fd
, "DEC L\n");
721 break; /* FIXME: Implement */
722 case 0x2E: /* LD L,imm */
724 fdprintf(fd
,"LD L,#0x%x\n",readb(xPC
));
726 DYNA_AND_l_i_to_r(0xFF00,6);
727 DYNA_OR_l_i_to_r(FETCH
,6);
731 fdprintf(fd
, "CPL\n");
733 break; /* FIXME: Implement */
734 case 0x30: /* JR NC */
736 fdprintf(fd
, "JR NC\n");
738 break; /* FIXME: Implement */
739 case 0x31: /* LD SP,imm */
741 fdprintf(fd
,"LD SP,#0x%x\n",readw(xPC
));
743 DYNA_MOVEA_l_i_to_r(readw(xPC
),0);
746 case 0x32: /* LD (HLD),A */
748 fdprintf(fd
, "LD (HLD),A\n");
750 break; /* FIXME: Implement */
751 case 0x33: /* INC SP */
753 fdprintf(fd
, "INC SP\n");
755 break; /* FIXME: Implement */
756 case 0x34: /* INC (HL) */
758 fdprintf(fd
, "INC (HL)\n");
760 break; /* FIXME: Implement */
761 case 0x35: /* DEC (HL) */
763 fdprintf(fd
, "DEC (HL)\n");
765 break; /* FIXME: Implement */
766 case 0x36: /* LD (HD),imm */
768 fdprintf(fd
, "LD (HD),imm\n");
770 break; /* FIXME: Implement */
773 fdprintf(fd
, "SCF\n");
775 break; /* FIXME: Implement */
776 case 0x38: /* JR C */
778 fdprintf(fd
, "JR C\n");
780 break; /* FIXME: Implement */
781 case 0x39: /* ADD HL,SP */
783 fdprintf(fd
, "ADD HL,SP\n");
785 break; /* FIXME: Implement */
786 case 0x3A: /* LD A,(HLD) */
788 fdprintf(fd
, "LD A,(HLD)\n");
790 break; /* FIXME: Implement */
791 case 0x3B: /* DEC SP */
793 fdprintf(fd
, "DEC SP\n");
795 break; /* FIXME: Implement */
796 case 0x3C: /* INC A */
798 fdprintf(fd
, "INC A");
800 DYNA_INC_l_r(1,0); /* Is this right? */
802 case 0x3D: /* DEC A */
804 fdprintf(fd
, "DEC A");
806 DYNA_DEC_l_r(1,0); /* Is this right? */
808 case 0x3E: /* LD A,imm */
810 fdprintf(fd
,"LD A,#0x%x\n",readb(xPC
));
812 DYNA_MOVEQ_l_i_to_r(FETCH
,1);
816 fdprintf(fd
, "CCF\n");
818 break; /* FIXME: Implement */
819 case 0x40: /* LD B,B */
821 fdprintf(fd
, "LD B,B\n");
824 case 0x41: /* LD B,C */
826 fdprintf(fd
,"LD B,C\n");
828 DYNA_MOVE_b_r_to_r(3,2);
830 case 0x42: /* LD B,D */
832 fdprintf(fd
,"LD B,D\n");
834 DYNA_MOVE_b_r_to_r(4,2);
836 case 0x43: /* LD B,E */
838 fdprintf(fd
,"LD B,E\n");
840 DYNA_MOVE_b_r_to_r(5,2);
842 case 0x44: /* LD B,H */
844 fdprintf(fd
,"LD B,H\n");
847 DYNA_MOVE_b_r_to_r(0,2);
849 case 0x45: /* LD B,L */
851 fdprintf(fd
,"LD B,L\n");
853 DYNA_MOVE_b_r_to_r(6,2);
855 case 0x46: /* LD B,(HL) */
857 fdprintf(fd
, "LD B,(HL)\n");
859 break; /* FIXME: Implement */
860 case 0x47: /* LD B,A */
862 fdprintf(fd
,"LD B,A\n");
864 DYNA_MOVE_b_r_to_r(1,2);
866 case 0x48: /* LD C,B */
868 fdprintf(fd
,"LD C,B\n");
870 DYNA_MOVE_b_r_to_r(2,3);
872 case 0x49: /* LD C,C */
874 case 0x4A: /* LD C,D */
876 fdprintf(fd
,"LD C,D\n");
878 DYNA_MOVE_b_r_to_r(4,3);
880 case 0x4B: /* LD C,E */
882 fdprintf(fd
,"LD C,E\n");
884 DYNA_MOVE_b_r_to_r(5,3);
886 case 0x4C: /* LD C,H */
888 fdprintf(fd
,"LD C,H\n");
891 DYNA_MOVE_b_r_to_r(0,3);
893 case 0x4D: /* LD C,L */
895 fdprintf(fd
,"LD C,L\n");
897 DYNA_MOVE_b_r_to_r(6,3);
899 case 0x4E: /* LD C,(HL) */
901 fdprintf(fd
, "LD C,(HL)\n");
903 break; /* FIXME: Implement */
904 case 0x4F: /* LD C,A */
906 fdprintf(fd
,"LD C,A\n");
908 DYNA_MOVE_b_r_to_r(1,3);
910 case 0x50: /* LD D,B */
912 fdprintf(fd
,"LD D,B\n");
914 DYNA_MOVE_b_r_to_r(2,4);
916 case 0x51: /* LD D,C */
918 fdprintf(fd
,"LD D,C\n");
920 DYNA_MOVE_b_r_to_r(3,4);
922 case 0x52: /* LD D,D */
924 case 0x53: /* LD D,E */
926 fdprintf(fd
,"LD D,E\n");
928 DYNA_MOVE_b_r_to_r(5,4);
930 case 0x54: /* LD D,H */
932 fdprintf(fd
,"LD D,H\n");
935 DYNA_MOVE_b_r_to_r(0,4);
937 case 0x55: /* LD D,L */
939 fdprintf(fd
,"LD D,L\n");
941 DYNA_MOVE_b_r_to_r(6,4);
943 case 0x56: /* LD D,(HL) */
945 fdprintf(fd
, "LD D,(HL)\n");
947 break; /* FIXME: Implement */
948 case 0x57: /* LD D,A */
950 fdprintf(fd
,"LD D,A\n");
952 DYNA_MOVE_b_r_to_r(1,4);
954 case 0x58: /* LD E,B */
956 fdprintf(fd
,"LD E,B\n");
958 DYNA_MOVE_b_r_to_r(2,5);
960 case 0x59: /* LD E,C */
962 fdprintf(fd
,"LD E,C\n");
964 DYNA_MOVE_b_r_to_r(3,5);
966 case 0x5A: /* LD E,D */
968 fdprintf(fd
,"LD E,D\n");
970 DYNA_MOVE_b_r_to_r(4,5);
972 case 0x5B: /* LD E,E */
974 case 0x5C: /* LD E,H */
976 fdprintf(fd
,"LD E,H\n");
979 DYNA_MOVE_b_r_to_r(0,5);
981 case 0x5D: /* LD E,L */
983 fdprintf(fd
,"LD E,L\n");
985 DYNA_MOVE_b_r_to_r(6,5);
987 case 0x5E: /* LD E,(HL) */
989 fdprintf(fd
, "LD E,(HL)\n");
991 break; /* FIXME: Implement */
992 case 0x5F: /* LD E,A */
994 fdprintf(fd
,"LD E,A\n");
996 DYNA_MOVE_b_r_to_r(1,5);
998 case 0x60: /* LD H,B */
1000 fdprintf(fd
,"LD H,B\n");
1002 DYNA_MOVE_b_r_to_r(2,0);
1005 case 0x61: /* LD H,C */
1007 fdprintf(fd
,"LD H,C\n");
1009 DYNA_MOVE_b_r_to_r(3,0);
1012 case 0x62: /* LD H,D */
1014 fdprintf(fd
,"LD H,D\n");
1016 DYNA_MOVE_b_r_to_r(4,0);
1019 case 0x63: /* LD H,E */
1021 fdprintf(fd
,"LD H,E\n");
1023 DYNA_MOVE_b_r_to_r(5,0);
1026 case 0x64: /* LD H,H */
1028 case 0x65: /* LD H,L */
1030 fdprintf(fd
,"LD H,L\n");
1032 DYNA_MOVE_b_r_to_r(6,0);
1035 case 0x66: /* LD H,(HL) */
1037 fdprintf(fd
, "LD H,(HL)\n");
1039 break; /* FIXME: Implement */
1040 case 0x67: /* LD H,A */
1042 fdprintf(fd
,"LD H,A\n");
1044 DYNA_MOVE_b_r_to_r(1,0);
1047 case 0x68: /* LD L,B */
1049 fdprintf(fd
,"LD L,B\n");
1051 DYNA_MOVE_b_r_to_r(2,6);
1053 case 0x69: /* LD L,C */
1055 fdprintf(fd
,"LD L,C\n");
1057 DYNA_MOVE_b_r_to_r(3,6);
1059 case 0x6A: /* LD L,D */
1061 fdprintf(fd
,"LD L,D\n");
1063 DYNA_MOVE_b_r_to_r(4,6);
1065 case 0x6B: /* LD L,E */
1067 fdprintf(fd
,"LD L,E\n");
1069 DYNA_MOVE_b_r_to_r(5,6);
1071 case 0x6C: /* LD L,H */
1073 fdprintf(fd
,"LD L,H\n");
1076 DYNA_MOVE_b_r_to_r(0,6);
1078 case 0x6D: /* LD L,L */
1080 case 0x6E: /* LD L,(HL) */
1082 fdprintf(fd
, "LD L,(HL)\n");
1084 break; /* FIXME: Implement */
1085 case 0x6F: /* LD L,A */
1087 fdprintf(fd
, "LD L,A\n");
1089 break; /* FIXME: Implement */
1090 case 0x70: /* LD (HL),B */
1092 fdprintf(fd
, "LD (HL),B\n");
1094 break; /* FIXME: Implement */
1095 case 0x71: /* LD (HL),C */
1097 fdprintf(fd
, "LD (HL),C\n");
1099 break; /* FIXME: Implement */
1100 case 0x72: /* LD (HL),D */
1102 fdprintf(fd
, "LD (HL),D\n");
1104 break; /* FIXME: Implement */
1105 case 0x73: /* LD (HL),E */
1107 fdprintf(fd
, "LD (HL),E\n");
1109 break; /* FIXME: Implement */
1110 case 0x74: /* LD (HL),H */
1112 fdprintf(fd
, "LD (HL),H\n");
1114 break; /* FIXME: Implement */
1115 case 0x75: /* LD (HL),L */
1117 fdprintf(fd
, "LD (HL),L\n");
1119 break; /* FIXME: Implement */
1120 case 0x76: /* HALT */
1122 fdprintf(fd
, "HALT\n");
1124 break; /* FIXME: Implement */
1125 case 0x77: /* LD (HL),A */
1127 fdprintf(fd
, "LD (HL),A\n");
1129 break; /* FIXME: Implement */
1130 case 0x78: /* LD A,B */
1132 fdprintf(fd
,"LD A,B\n");
1134 DYNA_MOVE_b_r_to_r(2,1);
1136 case 0x79: /* LD A,C */
1138 fdprintf(fd
,"LD A,C\n");
1140 DYNA_MOVE_b_r_to_r(3,1);
1142 case 0x7A: /* LD A,D */
1144 fdprintf(fd
,"LD A,D\n");
1146 DYNA_MOVE_b_r_to_r(4,1);
1148 case 0x7B: /* LD A,E */
1150 fdprintf(fd
,"LD A,E\n");
1152 DYNA_MOVE_b_r_to_r(5,1);
1154 case 0x7C: /* LD A,H */
1156 fdprintf(fd
,"LD A,H\n");
1159 DYNA_MOVE_b_r_to_r(0,1);
1161 case 0x7D: /* LD A,L */
1163 fdprintf(fd
,"LD A,L\n");
1165 DYNA_MOVE_b_r_to_r(5,1);
1167 case 0x7E: /* LD A,HL */
1169 fdprintf(fd
, "LD A,HL\n");
1171 break; /* FIXME: Implement */
1172 case 0x7F: /* LD A,A */
1174 case 0x80: /* ADD A,B */
1176 fdprintf(fd
, "ADD A,B\n");
1178 break; /* FIXME: Implement */
1179 case 0x81: /* ADD A,C */
1181 fdprintf(fd
, "ADD A,C\n");
1183 break; /* FIXME: Implement */
1184 case 0x82: /* ADD A,D */
1186 fdprintf(fd
, "ADD A,D\n");
1188 break; /* FIXME: Implement */
1189 case 0x83: /* ADD A,E */
1191 fdprintf(fd
, "ADD A,E\n");
1193 break; /* FIXME: Implement */
1194 case 0x84: /* ADD A,H */
1196 fdprintf(fd
, "ADD A,H\n");
1198 break; /* FIXME: Implement */
1199 case 0x85: /* ADD A,L */
1201 fdprintf(fd
, "ADD A,L\n");
1203 break; /* FIXME: Implement */
1204 case 0x86: /* ADD A,(HL) */
1206 fdprintf(fd
, "ADD A,(HL)\n");
1208 break; /* FIXME: Implement */
1209 case 0x87: /* ADD A,A */
1211 fdprintf(fd
,"ADD A,A\n");
1213 /* code taken from gcc -O3 output by compiling;
1215 * a=(c) ? 0 : 0x80 | zero flag
1216 * (0x20 & (c) << 1) | halfcarry
1217 * ((2*b)&0x100)>>4; carry
1219 DYNA_MOVE_l_r_to_r(1,0,0); /* move.l d1, d0 */
1220 DYNA_ADD_l_r_to_r(0,0,0); /* add.l d0, d0 */
1221 DYNA_AND_l_i_to_r(510,0); /* and.l #510, d0 */
1222 DYNA_MOVEA_l_r_to_r(0,3,0); /* movea.l d0,a3 */
1223 DYNA_CLR_b_r(7); /* clr.b d7 */
1224 DYNA_TST_b_r(0,0); /* tst.b d0 */
1225 DYNA_DUMMYBRANCH(2,0);
1226 DYNA_MOVE_l_r_to_r(1,0,0); /* move.l d1,d0 */
1227 DYNA_LSHIFT_l(3,0,0,0); /* lsr.l #3, d0 */
1228 DYNA_MOVEQ_l_i_to_r(16,1); /* moveq #16,d1 */
1229 DYNA_AND_l_r_to_r(1,0); /* and.l d1 d0 */
1230 DYNA_MOVEQ_l_i_to_r(0x80,7); /* moveq #0x80,d7 */
1231 DYNA_OR_l_r_to_r(0,7); /* or.l d0, d7 */
1232 DYNA_BCC_c(0x6,2,0); /* branch not equal, here */
1233 DYNA_MOVE_l_r_to_r(3,1,1); /* move.l a3,d1 */
1234 DYNA_AND_l_i_to_r(0xFE,1); /* and.l #0xFE,d1 */
1235 DYNA_AND_l_i_to_r(0xB0,7); /* and.l #0xB0,d7 */
1237 case 0x88: /* ADC A,B */
1239 fdprintf(fd
, "ADC A,B\n");
1241 break; /* FIXME: Implement */
1242 case 0x89: /* ADC A,C */
1244 fdprintf(fd
, "ADC A,C\n");
1246 break; /* FIXME: Implement */
1247 case 0x8A: /* ADC A,D */
1249 fdprintf(fd
, "ADC A,D\n");
1251 break; /* FIXME: Implement */
1252 case 0x8B: /* ADC A,E */
1254 fdprintf(fd
, "ADC A,E\n");
1256 break; /* FIXME: Implement */
1257 case 0x8C: /* ADC A,H */
1259 fdprintf(fd
, "ADC A,H\n");
1261 break; /* FIXME: Implement */
1262 case 0x8D: /* ADC A,L */
1264 fdprintf(fd
, "ADC A,L\n");
1266 break; /* FIXME: Implement */
1267 case 0x8E: /* ADC A,(HL) */
1269 fdprintf(fd
, "ADC A,(HL)\n");
1271 break; /* FIXME: Implement */
1272 case 0x8F: /* ADC A */
1274 fdprintf(fd
, "ADC A\n");
1276 break; /* FIXME: Implement */
1277 case 0x90: /* SUB B */
1279 fdprintf(fd
, "SUB B\n");
1281 break; /* FIXME: Implement */
1282 case 0x91: /* SUB C */
1284 fdprintf(fd
, "SUB C\n");
1286 break; /* FIXME: Implement */
1287 case 0x92: /* SUB D */
1289 fdprintf(fd
, "SUB D\n");
1291 break; /* FIXME: Implement */
1292 case 0x93: /* SUB E */
1294 fdprintf(fd
, "SUB E\n");
1296 break; /* FIXME: Implement */
1297 case 0x94: /* SUB H */
1299 fdprintf(fd
, "SUB H\n");
1301 break; /* FIXME: Implement */
1302 case 0x95: /* SUB L */
1304 fdprintf(fd
, "SUB L\n");
1306 break; /* FIXME: Implement */
1307 case 0x96: /* SUB (HL) */
1309 fdprintf(fd
, "SUB (HL)\n");
1311 break; /* FIXME: Implement */
1312 case 0x97: /* SUB A (halfcarry ?) */
1314 fdprintf(fd
,"SUB A\n");
1317 DYNA_MOVEQ_l_i_to_r(0xC0,7);
1319 case 0x98: /* SBC A,B */
1321 fdprintf(fd
, "SBC A,B\n");
1323 break; /* FIXME: Implement */
1324 case 0x99: /* SBC A,C */
1326 fdprintf(fd
, "SBC A,C\n");
1328 break; /* FIXME: Implement */
1329 case 0x9A: /* SBC A,D */
1331 fdprintf(fd
, "SBC A,D\n");
1333 break; /* FIXME: Implement */
1334 case 0x9B: /* SBC A,E */
1336 fdprintf(fd
, "SBC A,E\n");
1338 break; /* FIXME: Implement */
1339 case 0x9C: /* SBC A,H */
1341 fdprintf(fd
, "SBC A,H\n");
1343 break; /* FIXME: Implement */
1344 case 0x9D: /* SBC A,L */
1346 fdprintf(fd
, "SBC A,L\n");
1348 break; /* FIXME: Implement */
1349 case 0x9E: /* SBC A,(HL) */
1351 fdprintf(fd
, "SBC A,(HL)\n");
1353 break; /* FIXME: Implement */
1354 case 0x9F: /* SBC A,A */
1356 fdprintf(fd
, "SBC A,A\n");
1358 break; /* FIXME: Implement */
1359 case 0xA0: /* AND B */
1361 fdprintf(fd
, "AND B\n");
1363 break; /* FIXME: Implement */
1364 case 0xA1: /* AND C */
1366 fdprintf(fd
, "AND C\n");
1368 break; /* FIXME: Implement */
1369 case 0xA2: /* AND D */
1371 fdprintf(fd
, "AND D\n");
1373 break; /* FIXME: Implement */
1374 case 0xA3: /* AND E */
1376 fdprintf(fd
, "AND E\n");
1378 break; /* FIXME: Implement */
1379 case 0xA4: /* AND H */
1381 fdprintf(fd
, "AND H\n");
1383 break; /* FIXME: Implement */
1384 case 0xA5: /* AND L */
1386 fdprintf(fd
, "AND L\n");
1388 break; /* FIXME: Implement */
1389 case 0xA6: /* AND (HL) */
1391 fdprintf(fd
, "AND (HL)\n");
1393 break; /* FIXME: Implement */
1394 case 0xA7: /* AND A */
1396 fdprintf(fd
, "AND A\n");
1398 break; /* FIXME: Implement */
1399 case 0xA8: /* XOR B */
1401 fdprintf(fd
, "XOR B\n");
1403 break; /* FIXME: Implement */
1404 case 0xA9: /* XOR C */
1406 fdprintf(fd
, "XOR C\n");
1408 break; /* FIXME: Implement */
1409 case 0xAA: /* XOR D */
1411 fdprintf(fd
, "XOR D\n");
1413 break; /* FIXME: Implement */
1414 case 0xAB: /* XOR E */
1416 fdprintf(fd
, "XOR E\n");
1418 break; /* FIXME: Implement */
1419 case 0xAC: /* XOR H */
1421 fdprintf(fd
, "XOR H\n");
1423 break; /* FIXME: Implement */
1424 case 0xAD: /* XOR L */
1426 fdprintf(fd
, "XOR L\n");
1428 break; /* FIXME: Implement */
1429 case 0xAE: /* XOR (HL) */
1431 fdprintf(fd
, "XOR (HL)\n");
1433 break; /* FIXME: Implement */
1434 case 0xAF: /* XOR A */
1436 fdprintf(fd
, "XOR A\n");
1438 break; /* FIXME: Implement */
1439 case 0xB0: /* OR B */
1441 fdprintf(fd
, "OR B\n");
1443 break; /* FIXME: Implement */
1444 case 0xB1: /* OR C */
1446 fdprintf(fd
, "OR C\n");
1448 break; /* FIXME: Implement */
1449 case 0xB2: /* OR D */
1451 fdprintf(fd
, "OR D\n");
1453 break; /* FIXME: Implement */
1454 case 0xB3: /* OR E */
1456 fdprintf(fd
, "OR E\n");
1458 break; /* FIXME: Implement */
1459 case 0xB4: /* OR H */
1461 fdprintf(fd
, "OR H\n");
1463 break; /* FIXME: Implement */
1464 case 0xB5: /* OR L */
1466 fdprintf(fd
, "OR L\n");
1468 break; /* FIXME: Implement */
1469 case 0xB6: /* OR (HL) */
1471 fdprintf(fd
, "OR (HL)\n");
1473 break; /* FIXME: Implement */
1474 case 0xB7: /* OR A */
1476 fdprintf(fd
, "OR A\n");
1478 break; /* FIXME: Implement */
1479 case 0xB8: /* CP B */
1481 fdprintf(fd
, "CP B\n");
1483 break; /* FIXME: Implement */
1484 case 0xB9: /* CP C */
1486 fdprintf(fd
, "CP C\n");
1488 break; /* FIXME: Implement */
1489 case 0xBA: /* CP D */
1491 fdprintf(fd
, "CP D\n");
1493 break; /* FIXME: Implement */
1494 case 0xBB: /* CP E */
1496 fdprintf(fd
, "CP E\n");
1498 break; /* FIXME: Implement */
1499 case 0xBC: /* CP H */
1501 fdprintf(fd
, "CP H\n");
1503 break; /* FIXME: Implement */
1504 case 0xBD: /* CP L */
1506 fdprintf(fd
, "CP L\n");
1508 break; /* FIXME: Implement */
1509 case 0xBE: /* CP (HL) */
1511 fdprintf(fd
, "CP (HL)\n");
1513 break; /* FIXME: Implement */
1514 case 0xBF: /* CP A */
1516 fdprintf(fd
, "CP A\n");
1518 break; /* FIXME: Implement */
1519 case 0xC0: /* RET NZ */
1521 fdprintf(fd
, "RET NZ\n");
1523 break; /* FIXME: Implement */
1524 case 0xC1: /* POP BC */
1526 fdprintf(fd
, "POP BC\n");
1529 case 0xC2: /* JP NZ */
1531 fdprintf(fd
,"JP NZ\n");
1533 DYNA_BTST_l_r(8,7); /* btst #8,d7 */
1534 DYNA_DUMMYBRANCH(2,0);
1535 DYNA_MOVEA_l_i_to_r(&blockclen
,3);
1536 DYNA_MOVE_l_i_to_m(tclen
,3);
1537 DYNA_MOVEA_l_i_to_r(readw(PC
),1);
1539 DYNA_BCC_c(0x6,2,0); /* jump here if bit is not zero */
1543 case 0xC3: /* JP (imm) PC = readw(PC) */
1545 fdprintf(fd
,"JP (0x%x)\n",readw(xPC
));
1550 case 0xC4: /* CALL NZ */
1552 fdprintf(fd
, "CALL NZ\n");
1554 break; /* FIXME: Implement */
1555 case 0xC5: /* PUSH BC */
1557 fdprintf(fd
, "PUSH BC\n");
1559 break; /* FIXME: Implement */
1560 case 0xC6: /* ADD A,imm */
1562 fdprintf(fd
, "ADD A,imm\n");
1564 break; /* FIXME: Implement */
1565 case 0xC7: /* RST 0h */
1567 fdprintf(fd
, "RST 0h\n");
1569 break; /* FIXME: Implement */
1570 case 0xC8: /* RET Z */
1572 fdprintf(fd
, "RET Z\n");
1574 break; /* FIXME: Implement */
1575 case 0xC9: /* RET */
1577 fdprintf(fd
,"RET\n");
1583 case 0xCA: /* JP Z */
1584 break; /* FIXME: Implement */
1585 case 0xCB: /* NULL */
1587 fdprintf(fd
,"NULL\n");
1590 case 0xCC: /* CALL Z */
1592 fdprintf(fd
, "CALL Z\n");
1594 break; /* FIXME: Implement */
1595 case 0xCD: /* CALL (imm) PUSH(PC+2) PC=readw(PC); */
1597 fdprintf(fd
,"CALL (0x%x)\n",readw(xPC
));
1603 case 0xCE: /* ADC A,imm */
1605 fdprintf(fd
, "ADC A,imm\n");
1607 break; /* FIXME: Implement */
1608 case 0xCF: /* RST 8h */
1610 fdprintf(fd
, "RST 8h\n");
1612 break; /* FIXME: Implement */
1613 case 0xD0: /* RET NC */
1615 fdprintf(fd
,"RET NC\n");
1617 DYNA_BTST_l_r(5,7); /* btst #5,d7 */
1618 DYNA_DUMMYBRANCH(2,0);
1619 POPA(1); /* POP %a1 */
1620 DYNA_MOVEA_l_i_to_r(&blockclen
,3);
1621 DYNA_MOVE_l_i_to_m(tclen
,3);
1623 DYNA_BCC_c(0x6,2,0); /* jump here if bit is not zero */
1626 case 0xD1: /* POP DE */
1628 fdprintf(fd
, "POP DE\n");
1630 break; /* FIXME: Implement */
1631 case 0xD2: /* JP NC */
1633 fdprintf(fd
, "JP NC\n");
1635 break; /* FIXME: Implement */
1636 case 0xD3: /* NULL */
1638 fdprintf(fd
,"NULL\n");
1641 case 0xD4: /* CALL NC */
1643 fdprintf(fd
, "CALL NC\n");
1645 break; /* FIXME: Implement */
1646 case 0xD5: /* PUSH DE */
1648 fdprintf(fd
, "PUSH DE\n");
1650 break; /* FIXME: Implement */
1651 case 0xD6: /* SUB imm */
1653 fdprintf(fd
, "SUB imm\n");
1655 break; /* FIXME: Implement */
1656 case 0xD7: /* RST 10h */
1658 fdprintf(fd
, "RST 10h\n");
1660 break; /* FIXME: Implement */
1661 case 0xD8: /* RET C */
1663 fdprintf(fd
, "RET C\n");
1665 break; /* FIXME: Implement */
1666 case 0xD9: /* RETI */
1668 fdprintf(fd
, "RETI\n");
1670 break; /* FIXME: Implement */
1671 case 0xDA: /* JP C */
1673 fdprintf(fd
, "JP C\n");
1675 break; /* FIXME: Implement */
1676 case 0xDB: /* NULL */
1678 fdprintf(fd
,"NULL\n");
1681 case 0xDC: /* CALL NC */
1683 fdprintf(fd
, "CALL NC\n");
1685 break; /* FIXME: Implement */
1686 case 0xDD: /* NULL */
1688 fdprintf(fd
,"NULL\n");
1691 case 0xDE: /* SBC A,imm */
1693 fdprintf(fd
, "SBC A,imm\n");
1695 break; /* FIXME: Implement */
1696 case 0xDF: /* RST 18h */
1698 fdprintf(fd
, "RST 18h\n");
1700 break; /* FIXME: Implement */
1701 case 0xE0: /* LDH (imm),A */
1703 fdprintf(fd
,"LD (0x%x),A\n",readb(xPC
));
1706 DYNA_PEA_w_i(FETCH
);
1707 CALL_NATIVE(&writehi
);
1708 DYNA_ADDQ_l_i_to_r(0,7,1);
1709 /*writehi(FETCH, A); */
1711 case 0xE1: /* POP HL */
1713 fdprintf(fd
, "POP HL\n");
1715 break; /* FIXME: Implement */
1716 case 0xE2: /* LDH (imm),A */
1718 fdprintf(fd
, "LDH (imm),A\n");
1720 break; /* FIXME: Implement */
1721 case 0xE3: /* NULL */
1723 fdprintf(fd
,"NULL\n");
1726 case 0xE4: /* NULL */
1729 fdprintf(fd
,"NULL\n");
1731 case 0xE5: /* PUSH HL */
1733 fdprintf(fd
, "PUSH HL\n");
1735 break; /* FIXME: Implement */
1736 case 0xE6: /* AND imm */
1738 fdprintf(fd
, "AND imm\n");
1740 break; /* FIXME: Implement */
1741 case 0xE7: /* RST 20h */
1743 fdprintf(fd
, "RST 20h\n");
1745 break; /* FIXME: Implement */
1746 case 0xE8: /* ADD SP */
1748 fdprintf(fd
, "ADD SP\n");
1750 break; /* FIXME: Implement */
1751 case 0xE9: /* JP HL */
1753 fdprintf(fd
, "JP HL\n");
1755 break; /* FIXME: Implement */
1756 case 0xEA: /* LD A */
1758 fdprintf(fd
, "LD A\n");
1760 break; /* FIXME: Implement */
1761 case 0xEB: /* NULL */
1763 fdprintf(fd
,"NULL\n");
1766 case 0xEC: /* NULL */
1768 fdprintf(fd
,"NULL\n");
1771 case 0xED: /* NULL */
1773 fdprintf(fd
,"NULL\n");
1776 case 0xEE: /* XOR imm */
1778 fdprintf(fd
, "XOR imm\n");
1780 break; /* FIXME: Implement */
1781 case 0xEF: /* RST 28h */
1783 fdprintf(fd
, "RST 28h\n");
1785 break; /* FIXME: Implement */
1786 case 0xF0: /* LDH A,(imm) */
1788 fdprintf(fd
,"LDH A,(0x%x)\n",readb(xPC
));
1790 DYNA_PEA_w_i(FETCH
);
1791 CALL_NATIVE(&readhi
);
1792 DYNA_ADDQ_l_i_to_r(4,7,1);
1793 DYNA_MOVE_b_r_to_r(0,1);
1794 /*A = readhi(FETCH)*/
1796 case 0xF1: /* POP AF */
1798 fdprintf(fd
, "POP AF\n");
1800 break; /* FIXME: Implement */
1801 case 0xF2: /* LDH A,(imm) */
1803 fdprintf(fd
, "LDH A,(imm)\n");
1805 break; /* FIXME: Implement */
1808 fdprintf(fd
,"DI\n");
1810 DYNA_CLR_l_m(&cpu
.ime
);
1811 DYNA_CLR_l_m(&cpu
.ima
);
1812 DYNA_CLR_l_m(&cpu
.halt
);
1813 /* cpu.halt = cpu.ima = cpu.ime = 0; */
1815 case 0xF4: /* NULL */
1817 fdprintf(fd
,"NULL\n");
1820 case 0xF5: /* PUSH AF */
1822 fdprintf(fd
, "PUSH AF\n");
1824 break; /* FIXME: Implement */
1825 case 0xF6: /* OR imm */
1827 fdprintf(fd
, "OR imm\n");
1829 break; /* FIXME: Implement */
1830 case 0xF7: /* RST 30h */
1832 fdprintf(fd
, "RST 30h\n");
1834 break; /* FIXME: Implement */
1835 case 0xF8: /* LD HL,SP */
1837 fdprintf(fd
, "LD HL,SP\n");
1839 break; /* FIXME: Implement */
1840 case 0xF9: /* LD SP,HL */
1842 fdprintf(fd
,"LD SP,HL\n");
1844 DYNA_MOVEA_w_r_to_r(6,0,0);
1846 case 0xFA: /* LD A, (imm) */
1848 fdprintf(fd
,"LD A,(0x%x)\n",readw(xPC
));
1850 /*DYNA_PEA_w_i(readw(xPC));
1852 CALL_NATIVE(&readb); \
1853 DYNA_ADDQ_l_i_to_r(4,7,1); \
1854 DYNA_MOVE_l_r_to_r(0,1,0);*/
1858 fdprintf(fd
,"EI\n");
1860 DYNA_MOVEQ_l_i_to_r(1,0);
1861 DYNA_MOVEA_l_i_to_r(&cpu
.ima
,3);
1862 DYNA_MOVE_l_r_to_m(0,3);
1865 case 0xFC: /* NULL */
1867 fdprintf(fd
,"NULL\n");
1870 case 0xFD: /* NULL */
1872 fdprintf(fd
,"NULL\n");
1875 case 0xFE: /* CMP #<imm> TODO: can be (much) more efficient.*/
1877 fdprintf(fd
,"CMP #0x%x\n",readb(xPC
));
1879 DYNA_MOVEA_l_r_to_r(2,3,0); /* movea.l %d2, %a3 */
1880 DYNA_MOVEQ_l_i_to_r(FETCH
,2); /* moveq.l #<FETCH>,%d2 */
1882 DYNA_MOVE_l_r_to_r(3,2,1); /* move.l %a3, %d2 */
1884 case 0xFF: /* RST 38h */
1886 fdprintf(fd
, "RST 38h\n");
1888 break; /* FIXME: Implement */
1890 snprintf(meow
,499,"unimplemented opcode %d / 0x%x",op
,op
);
1897 fdprintf(fd
,"(End of Block)\n");
1900 DYNA_MOVEA_l_i_to_r(&blockclen
,3);
1901 DYNA_MOVE_l_i_to_m(tclen
,3);
1903 DYNA_MOVEA_l_i_to_r(PC
,1);
1906 setmallocpos(dynapointer
);
1907 newblock
->length
=dynapointer
-newblock
->block
;
1908 IF_COP(rb
->cpucache_invalidate());
1909 snprintf(meow
,499,"/dyna_0x%x_code.rb",PC
);
1910 fd
=open(meow
,O_WRONLY
|O_CREAT
|O_TRUNC
, 0666);
1913 write(fd
,newblock
->block
,newblock
->length
);