BBC Basic in Z80 emulation on the mbed, USB serial terminal output only. LOAD and SAVE work on the local file system but there is no error signalling.
z80ops.h
00001 /* Emulations of the Z80 CPU instruction set - part of xz80. 00002 * Copyright (C) 1994 Ian Collier. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 00020 /* nop */ 00021 case 0: 00022 break; 00023 // ld BC,nn 00024 instr(0x01,10); 00025 c=fetch(pc),pc++; 00026 b=fetch(pc),pc++; 00027 endinstr; 00028 // ld (BC),A 00029 instr(0x02,7); 00030 store(bc,a); 00031 endinstr; 00032 // inc BC 00033 instr(0x03,6); 00034 if (!++c)b++; 00035 endinstr; 00036 // inc B 00037 instr(0x04,4); 00038 inc(b); 00039 endinstr; 00040 // dec B 00041 instr(0x05,4); 00042 dec(b); 00043 endinstr; 00044 // ld B,n 00045 instr(0x06,7); 00046 b=fetch(pc),pc++; 00047 endinstr; 00048 // rlca 00049 instr(0x07,4); 00050 a=(a<<1)|(a>>7); 00051 f=(f&0xc4)|(a&0x29); 00052 endinstr; 00053 // ex AF,AF' 00054 instr(0x08,4); 00055 swap(a,a1); 00056 swap(f,f1); 00057 endinstr; 00058 // add HL,BC 00059 instr(0x09,11); 00060 addhl(b,c); 00061 endinstr; 00062 // ld A,(BC) 00063 instr(0x0a,7); 00064 a=fetch(bc); 00065 endinstr; 00066 // dec BC 00067 instr(0x0b,6); 00068 if (!c--)b--; 00069 endinstr; 00070 // inc C 00071 instr(0x0c,4); 00072 inc(c); 00073 endinstr; 00074 // dec C 00075 instr(0x0d,4); 00076 dec(c); 00077 endinstr; 00078 // ld C,n 00079 instr(0x0e,4); 00080 c=fetch(pc),pc++; 00081 endinstr; 00082 // rrca 00083 instr(0x0f,4); 00084 f=(f&0xc4)|(a&1); 00085 a=(a>>1)|(a<<7); 00086 f|=a&0x28; 00087 endinstr; 00088 // djnz 00089 instr(0x10,8); 00090 if (!--b)pc++; 00091 else jr; 00092 endinstr; 00093 // ld DE,nn 00094 instr(0x11,10); 00095 e=fetch(pc),pc++; 00096 d=fetch(pc),pc++; 00097 endinstr; 00098 // ld (DE),A 00099 instr(0x12,7); 00100 store(de,a); 00101 endinstr; 00102 // inc DE 00103 instr(0x13,6); 00104 if (!++e)d++; 00105 endinstr; 00106 // inc D 00107 instr(0x14,4); 00108 inc(d); 00109 endinstr; 00110 // dec D 00111 instr(0x15,4); 00112 dec(d); 00113 endinstr; 00114 // ld D,n 00115 instr(0x16,7); 00116 d=fetch(pc),pc++; 00117 endinstr; 00118 // rla 00119 instr(0x17,4); 00120 { 00121 int t=a>>7; 00122 a=(a<<1)|(f&1); 00123 f=(f&0xc4)|(a&0x28)|t; 00124 } 00125 endinstr; 00126 // JR 00127 instr(0x18,7); 00128 jr; 00129 endinstr; 00130 // add HL,DE 00131 instr(0x19,11); 00132 addhl(d,e); 00133 endinstr; 00134 // ld A,(DE) 00135 instr(0x1a,7); 00136 a=fetch(de); 00137 endinstr; 00138 // dec DE 00139 instr(0x1b,6); 00140 if (!e--)d--; 00141 endinstr; 00142 // inc E 00143 instr(0x1c,4); 00144 inc(e); 00145 endinstr; 00146 // dec E 00147 instr(0x1d,4); 00148 dec(e); 00149 endinstr; 00150 // ld E,n 00151 instr(0x1e,4); 00152 e=fetch(pc),pc++; 00153 endinstr; 00154 // rra 00155 instr(0x1f,4); 00156 { 00157 int t=a&1; 00158 a=(a>>1)|(f<<7); 00159 f=(f&0xc4)|(a&0x28)|t; 00160 } 00161 endinstr; 00162 // jr NZ 00163 instr(0x20,7); 00164 if (f&0x40)pc++; 00165 else jr; 00166 endinstr; 00167 // ld HL,nn 00168 instr(0x21,10); 00169 if (!ixoriy) { 00170 l=fetch(pc),pc++; 00171 h=fetch(pc),pc++; 00172 } else { 00173 if (ixoriy==1) 00174 ix=fetch2(pc); 00175 else iy=fetch2(pc); 00176 pc+=2; 00177 } 00178 endinstr; 00179 // ld (nn),HL 00180 instr(0x22,16); 00181 { 00182 unsigned short addr=fetch2(pc); 00183 pc+=2; 00184 if (!ixoriy) store2b(addr,h,l); 00185 else if (ixoriy==1)store2(addr,ix); 00186 else store2(addr,iy); 00187 } 00188 endinstr; 00189 // inc HL 00190 instr(0x23,6); 00191 if (!ixoriy) { 00192 if (!++l)h++; 00193 } else if (ixoriy==1)ix++; 00194 else iy++; 00195 endinstr; 00196 // inc H 00197 instr(0x24,4); 00198 if (ixoriy==0)inc(h); 00199 else { 00200 unsigned char t; 00201 t=(ixoriy==1?ix:iy)>>8; 00202 inc(t); 00203 if (ixoriy==1)ix=(ix&0xff)|(t<<8); 00204 else iy=(iy&0xff)|(t<<8); 00205 } 00206 endinstr; 00207 // dec H 00208 instr(0x25,4); 00209 if (ixoriy==0)dec(h); 00210 else { 00211 unsigned char t; 00212 t=(ixoriy==1?ix:iy)>>8; 00213 dec(t); 00214 if (ixoriy==1)ix=(ix&0xff)|(t<<8); 00215 else iy=(iy&0xff)|(t<<8); 00216 } 00217 endinstr; 00218 // ld H,n 00219 instr(0x26,7); 00220 setxh(fetch(pc)); 00221 pc++; 00222 endinstr; 00223 // daa 00224 instr(0x27,4); 00225 { 00226 unsigned char incr=0, carry=cy; 00227 if ((f&0x10) || (a&0x0f)>9) incr=6; 00228 if ((f&1) || (a>>4)>9) incr|=0x60; 00229 if (f&2) suba(incr,0); 00230 00231 else { 00232 if (a>0x90 && (a&15)>9)incr|=0x60; 00233 adda(incr,0); 00234 } 00235 f=((f|carry)&0xfb)|parity(a); 00236 } 00237 endinstr; 00238 // jr Z 00239 instr(0x28,7); 00240 if (f&0x40)jr; 00241 else pc++; 00242 endinstr; 00243 // add HL,HL 00244 instr(0x29,11); 00245 if (!ixoriy)addhl(h,l); 00246 else if (ixoriy==1)addhl((ix>>8),(ix&0xff)); 00247 else addhl((iy>>8),(iy&0xff)); 00248 endinstr; 00249 // ld HL,(nn) 00250 instr(0x2a,16); 00251 { 00252 unsigned short addr=fetch2(pc); 00253 pc+=2; 00254 if (!ixoriy) { 00255 l=fetch(addr); 00256 h=fetch(addr+1); 00257 } else if (ixoriy==1)ix=fetch2(addr); 00258 else iy=fetch2(addr); 00259 } 00260 endinstr; 00261 // dec HL 00262 instr(0x2b,6); 00263 if (!ixoriy) { 00264 if (!l--)h--; 00265 } else if (ixoriy==1)ix--; 00266 else iy--; 00267 endinstr; 00268 // inc L 00269 instr(0x2c,4); 00270 if (!ixoriy)inc(l); 00271 else { 00272 unsigned char t; 00273 t=(ixoriy==1?ix:iy); 00274 inc(t); 00275 if (ixoriy==1)ix=(ix&0xff00)|t; 00276 else iy=(iy&0xff00)|t; 00277 } 00278 endinstr; 00279 // dec L 00280 instr(0x2d,4); 00281 if (!ixoriy)dec(l); 00282 else { 00283 unsigned char t; 00284 t=(ixoriy==1?ix:iy); 00285 dec(t); 00286 if (ixoriy==1)ix=(ix&0xff00)|t; 00287 else iy=(iy&0xff00)|t; 00288 } 00289 endinstr; 00290 // ld L,n 00291 instr(0x2e,4); 00292 setxl(fetch(pc)); 00293 pc++; 00294 endinstr; 00295 // cpl 00296 instr(0x2f,4); 00297 a=~a; 00298 f=(f&0xc5)|(a&0x28)|0x12; 00299 endinstr; 00300 // jr NC 00301 instr(0x30,7); 00302 if (f&1)pc++; 00303 else jr; 00304 endinstr; 00305 // ld SP,nn 00306 instr(0x31,10); 00307 sp=fetch2(pc); 00308 pc+=2; 00309 endinstr; 00310 // ld (nn),A 00311 instr(0x32,13); 00312 { 00313 unsigned short addr=fetch2(pc); 00314 pc+=2; 00315 store(addr,a); 00316 } 00317 endinstr; 00318 // inc SP 00319 instr(0x33,6); 00320 sp++; 00321 endinstr; 00322 // inc (HL) 00323 HLinstr(0x34); 00324 { 00325 unsigned char t=fetch(addr); 00326 inc(t); 00327 store(addr,t); 00328 } 00329 endinstr; 00330 // dec (HL) 00331 HLinstr(0x35); 00332 { 00333 unsigned char t=fetch(addr); 00334 dec(t); 00335 store(addr,t); 00336 } 00337 endinstr; 00338 // ld (HL),n 00339 HLinstr(0x36); 00340 store(addr,fetch(pc)); 00341 pc++; 00342 endinstr; 00343 // scf 00344 instr(0x37,4); 00345 f=(f&0xc4)|1|(a&0x28); 00346 endinstr; 00347 // jr C 00348 instr(0x38,7); 00349 if (f&1)jr; 00350 else pc++; 00351 endinstr; 00352 // add HL,SP 00353 instr(0x39,11); 00354 addhl((sp>>8),(sp&0xff)); 00355 endinstr; 00356 // ld A,(nn) 00357 instr(0x3a,13); 00358 { 00359 unsigned short addr=fetch2(pc); 00360 pc+=2; 00361 a=fetch(addr); 00362 } 00363 endinstr; 00364 // dec SP 00365 instr(0x3b,6); 00366 sp--; 00367 endinstr; 00368 // inc A 00369 instr(0x3c,4); 00370 inc(a); 00371 endinstr; 00372 // dec A 00373 instr(0x3d,4); 00374 dec(a); 00375 endinstr; 00376 // ld A,n 00377 instr(0x3e,4); 00378 a=fetch(pc),pc++; 00379 endinstr; 00380 // ccf 00381 instr(0x3f,4); 00382 f=(f&0xc4)|(cy^1)|(cy<<4)|(a&0x28); 00383 endinstr; 00384 // ld B,B 00385 instr(0x40,4); 00386 /* ld b,b */ 00387 endinstr; 00388 00389 instr(0x41,4); 00390 b=c; 00391 endinstr; 00392 00393 instr(0x42,4); 00394 b=d; 00395 endinstr; 00396 00397 instr(0x43,4); 00398 b=e; 00399 endinstr; 00400 00401 instr(0x44,4); 00402 b=xh; 00403 endinstr; 00404 00405 instr(0x45,4); 00406 b=xl; 00407 endinstr; 00408 00409 HLinstr(0x46); 00410 b=fetch(addr); 00411 endinstr; 00412 00413 instr(0x47,4); 00414 b=a; 00415 endinstr; 00416 00417 instr(0x48,4); 00418 c=b; 00419 endinstr; 00420 00421 instr(0x49,4); 00422 /* ld c,c */ 00423 endinstr; 00424 00425 instr(0x4a,4); 00426 c=d; 00427 endinstr; 00428 00429 instr(0x4b,4); 00430 c=e; 00431 endinstr; 00432 00433 instr(0x4c,4); 00434 c=xh; 00435 endinstr; 00436 00437 instr(0x4d,4); 00438 c=xl; 00439 endinstr; 00440 00441 HLinstr(0x4e); 00442 c=fetch(addr); 00443 endinstr; 00444 00445 instr(0x4f,4); 00446 c=a; 00447 endinstr; 00448 00449 instr(0x50,4); 00450 d=b; 00451 endinstr; 00452 00453 instr(0x51,4); 00454 d=c; 00455 endinstr; 00456 00457 instr(0x52,4); 00458 /* ld d,d */ 00459 endinstr; 00460 00461 instr(0x53,4); 00462 d=e; 00463 endinstr; 00464 00465 instr(0x54,4); 00466 d=xh; 00467 endinstr; 00468 00469 instr(0x55,4); 00470 d=xl; 00471 endinstr; 00472 00473 HLinstr(0x56); 00474 d=fetch(addr); 00475 endinstr; 00476 00477 instr(0x57,4); 00478 d=a; 00479 endinstr; 00480 00481 instr(0x58,4); 00482 e=b; 00483 endinstr; 00484 00485 instr(0x59,4); 00486 e=c; 00487 endinstr; 00488 00489 instr(0x5a,4); 00490 e=d; 00491 endinstr; 00492 00493 instr(0x5b,4); 00494 /* ld e,e */ 00495 endinstr; 00496 00497 instr(0x5c,4); 00498 e=xh; 00499 endinstr; 00500 00501 instr(0x5d,4); 00502 e=xl; 00503 endinstr; 00504 00505 HLinstr(0x5e); 00506 e=fetch(addr); 00507 endinstr; 00508 00509 instr(0x5f,4); 00510 e=a; 00511 endinstr; 00512 00513 instr(0x60,4); 00514 setxh(b); 00515 endinstr; 00516 00517 instr(0x61,4); 00518 setxh(c); 00519 endinstr; 00520 00521 instr(0x62,4); 00522 setxh(d); 00523 endinstr; 00524 00525 instr(0x63,4); 00526 setxh(e); 00527 endinstr; 00528 00529 instr(0x64,4); 00530 /* ld h,h */ 00531 endinstr; 00532 00533 instr(0x65,4); 00534 setxh(xl); 00535 endinstr; 00536 00537 HLinstr(0x66); 00538 h=fetch(addr); 00539 endinstr; 00540 00541 instr(0x67,4); 00542 setxh(a); 00543 endinstr; 00544 00545 instr(0x68,4); 00546 setxl(b); 00547 endinstr; 00548 00549 instr(0x69,4); 00550 setxl(c); 00551 endinstr; 00552 00553 instr(0x6a,4); 00554 setxl(d); 00555 endinstr; 00556 00557 instr(0x6b,4); 00558 setxl(e); 00559 endinstr; 00560 00561 instr(0x6c,4); 00562 setxl(xh); 00563 endinstr; 00564 00565 instr(0x6d,4); 00566 /* ld l,l */ 00567 endinstr; 00568 00569 HLinstr(0x6e); 00570 l=fetch(addr); 00571 endinstr; 00572 00573 instr(0x6f,4); 00574 setxl(a); 00575 endinstr; 00576 00577 HLinstr(0x70); 00578 store(addr,b); 00579 endinstr; 00580 00581 HLinstr(0x71); 00582 store(addr,c); 00583 endinstr; 00584 00585 HLinstr(0x72); 00586 store(addr,d); 00587 endinstr; 00588 00589 HLinstr(0x73); 00590 store(addr,e); 00591 endinstr; 00592 00593 HLinstr(0x74); 00594 store(addr,h); 00595 endinstr; 00596 00597 HLinstr(0x75); 00598 store(addr,l); 00599 endinstr; 00600 00601 // HALT 00602 instr(0x76,4); 00603 pc--; /* keep nopping until int */ 00604 endinstr; 00605 00606 HLinstr(0x77); 00607 store(addr,a); 00608 endinstr; 00609 00610 instr(0x78,4); 00611 a=b; 00612 endinstr; 00613 00614 instr(0x79,4); 00615 a=c; 00616 endinstr; 00617 00618 instr(0x7a,4); 00619 a=d; 00620 endinstr; 00621 00622 instr(0x7b,4); 00623 a=e; 00624 endinstr; 00625 00626 instr(0x7c,4); 00627 a=xh; 00628 endinstr; 00629 00630 instr(0x7d,4); 00631 a=xl; 00632 endinstr; 00633 00634 HLinstr(0x7e); 00635 a=fetch(addr); 00636 endinstr; 00637 00638 instr(0x7f,4); 00639 /* ld a,a */ 00640 endinstr; 00641 00642 instr(0x80,4); 00643 adda(b,0); 00644 endinstr; 00645 00646 instr(0x81,4); 00647 adda(c,0); 00648 endinstr; 00649 00650 instr(0x82,4); 00651 adda(d,0); 00652 endinstr; 00653 00654 instr(0x83,4); 00655 adda(e,0); 00656 endinstr; 00657 00658 instr(0x84,4); 00659 adda(xh,0); 00660 endinstr; 00661 00662 instr(0x85,4); 00663 adda(xl,0); 00664 endinstr; 00665 00666 HLinstr(0x86); 00667 adda(fetch(addr),0); 00668 endinstr; 00669 00670 instr(0x87,4); 00671 adda(a,0); 00672 endinstr; 00673 00674 instr(0x88,4); 00675 adda(b,cy); 00676 endinstr; 00677 00678 instr(0x89,4); 00679 adda(c,cy); 00680 endinstr; 00681 00682 instr(0x8a,4); 00683 adda(d,cy); 00684 endinstr; 00685 00686 instr(0x8b,4); 00687 adda(e,cy); 00688 endinstr; 00689 00690 instr(0x8c,4); 00691 adda(xh,cy); 00692 endinstr; 00693 00694 instr(0x8d,4); 00695 adda(xl,cy); 00696 endinstr; 00697 00698 HLinstr(0x8e); 00699 adda(fetch(addr),cy); 00700 endinstr; 00701 00702 instr(0x8f,4); 00703 adda(a,cy); 00704 endinstr; 00705 00706 instr(0x90,4); 00707 suba(b,0); 00708 endinstr; 00709 00710 instr(0x91,4); 00711 suba(c,0); 00712 endinstr; 00713 00714 instr(0x92,4); 00715 suba(d,0); 00716 endinstr; 00717 00718 instr(0x93,4); 00719 suba(e,0); 00720 endinstr; 00721 00722 instr(0x94,4); 00723 suba(xh,0); 00724 endinstr; 00725 00726 instr(0x95,4); 00727 suba(xl,0); 00728 endinstr; 00729 00730 HLinstr(0x96); 00731 suba(fetch(addr),0); 00732 endinstr; 00733 00734 instr(0x97,4); 00735 suba(a,0); 00736 endinstr; 00737 00738 instr(0x98,4); 00739 suba(b,cy); 00740 endinstr; 00741 00742 instr(0x99,4); 00743 suba(c,cy); 00744 endinstr; 00745 00746 instr(0x9a,4); 00747 suba(d,cy); 00748 endinstr; 00749 00750 instr(0x9b,4); 00751 suba(e,cy); 00752 endinstr; 00753 00754 instr(0x9c,4); 00755 suba(xh,cy); 00756 endinstr; 00757 00758 instr(0x9d,4); 00759 suba(xl,cy); 00760 endinstr; 00761 00762 HLinstr(0x9e); 00763 suba(fetch(addr),cy); 00764 endinstr; 00765 00766 instr(0x9f,4); 00767 suba(a,cy); 00768 endinstr; 00769 00770 instr(0xa0,4); 00771 anda(b); 00772 endinstr; 00773 00774 instr(0xa1,4); 00775 anda(c); 00776 endinstr; 00777 00778 instr(0xa2,4); 00779 anda(d); 00780 endinstr; 00781 00782 instr(0xa3,4); 00783 anda(e); 00784 endinstr; 00785 00786 instr(0xa4,4); 00787 anda(xh); 00788 endinstr; 00789 00790 instr(0xa5,4); 00791 anda(xl); 00792 endinstr; 00793 00794 HLinstr(0xa6); 00795 anda(fetch(addr)); 00796 endinstr; 00797 00798 instr(0xa7,4); 00799 anda(a); 00800 endinstr; 00801 00802 instr(0xa8,4); 00803 xora(b); 00804 endinstr; 00805 00806 instr(0xa9,4); 00807 xora(c); 00808 endinstr; 00809 00810 instr(0xaa,4); 00811 xora(d); 00812 endinstr; 00813 00814 instr(0xab,4); 00815 xora(e); 00816 endinstr; 00817 00818 instr(0xac,4); 00819 xora(xh); 00820 endinstr; 00821 00822 instr(0xad,4); 00823 xora(xl); 00824 endinstr; 00825 00826 HLinstr(0xae); 00827 xora(fetch(addr)); 00828 endinstr; 00829 00830 instr(0xaf,4); 00831 xora(a); 00832 endinstr; 00833 00834 instr(0xb0,4); 00835 ora(b); 00836 endinstr; 00837 00838 instr(0xb1,4); 00839 ora(c); 00840 endinstr; 00841 00842 instr(0xb2,4); 00843 ora(d); 00844 endinstr; 00845 00846 instr(0xb3,4); 00847 ora(e); 00848 endinstr; 00849 00850 instr(0xb4,4); 00851 ora(xh); 00852 endinstr; 00853 00854 instr(0xb5,4); 00855 ora(xl); 00856 endinstr; 00857 00858 HLinstr(0xb6); 00859 ora(fetch(addr)); 00860 endinstr; 00861 00862 instr(0xb7,4); 00863 ora(a); 00864 endinstr; 00865 00866 instr(0xb8,4); 00867 cpa(b); 00868 endinstr; 00869 00870 instr(0xb9,4); 00871 cpa(c); 00872 endinstr; 00873 00874 instr(0xba,4); 00875 cpa(d); 00876 endinstr; 00877 00878 instr(0xbb,4); 00879 cpa(e); 00880 endinstr; 00881 00882 instr(0xbc,4); 00883 cpa(xh); 00884 endinstr; 00885 00886 instr(0xbd,4); 00887 cpa(xl); 00888 endinstr; 00889 00890 HLinstr(0xbe); 00891 cpa(fetch(addr)); 00892 endinstr; 00893 00894 instr(0xbf,4); 00895 cpa(a); 00896 endinstr; 00897 00898 instr(0xc0,5); 00899 if (!(f&0x40))ret; 00900 endinstr; 00901 00902 instr(0xc1,10); 00903 pop1(b,c); 00904 endinstr; 00905 00906 instr(0xc2,10); 00907 if (!(f&0x40))jp; 00908 else pc+=2; 00909 endinstr; 00910 00911 instr(0xc3,10); 00912 jp; 00913 endinstr; 00914 00915 instr(0xc4,10); 00916 if (!(f&0x40))call; 00917 else pc+=2; 00918 endinstr; 00919 00920 instr(0xc5,11); 00921 push1(b,c); 00922 endinstr; 00923 00924 instr(0xc6,7); 00925 adda(fetch(pc),0); 00926 pc++; 00927 endinstr; 00928 00929 instr(0xc7,11); 00930 push2(pc); 00931 pc=0; 00932 endinstr; 00933 00934 instr(0xc8,5); 00935 if (f&0x40)ret; 00936 endinstr; 00937 00938 instr(0xc9,4); 00939 ret; 00940 endinstr; 00941 00942 instr(0xca,10); 00943 if (f&0x40)jp; 00944 else pc+=2; 00945 endinstr; 00946 00947 instr(0xcb,4); 00948 #include "cbops.h" 00949 endinstr; 00950 00951 instr(0xcc,10); 00952 if (f&0x40)call; 00953 else pc+=2; 00954 endinstr; 00955 00956 instr(0xcd,10); 00957 call; 00958 endinstr; 00959 00960 instr(0xce,7); 00961 adda(fetch(pc),cy); 00962 pc++; 00963 endinstr; 00964 00965 instr(0xcf,11); 00966 push2(pc); 00967 pc=8; 00968 endinstr; 00969 00970 instr(0xd0,5); 00971 if (!cy)ret; 00972 endinstr; 00973 00974 instr(0xd1,10); 00975 pop1(d,e); 00976 endinstr; 00977 00978 instr(0xd2,10); 00979 if (!cy)jp; 00980 else pc+=2; 00981 endinstr; 00982 00983 // OUT 00984 instr(0xd3,11); 00985 out(fetch(pc),a); 00986 pc++; 00987 endinstr; 00988 00989 instr(0xd4,10); 00990 if (!cy)call; 00991 else pc+=2; 00992 endinstr; 00993 00994 instr(0xd5,11); 00995 push1(d,e); 00996 endinstr; 00997 00998 instr(0xd6,7); 00999 suba(fetch(pc),0); 01000 pc++; 01001 endinstr; 01002 01003 instr(0xd7,11); 01004 push2(pc); 01005 pc=16; 01006 endinstr; 01007 01008 instr(0xd8,5); 01009 if (cy)ret; 01010 endinstr; 01011 01012 instr(0xd9,4); 01013 swap(b,b1); 01014 swap(c,c1); 01015 swap(d,d1); 01016 swap(e,e1); 01017 swap(h,h1); 01018 swap(l,l1); 01019 endinstr; 01020 01021 instr(0xda,10); 01022 if (cy)jp; 01023 else pc+=2; 01024 endinstr; 01025 01026 // IN 01027 instr(0xdb,11); 01028 { 01029 a=in(fetch(pc)); 01030 pc++; 01031 } 01032 endinstr; 01033 01034 instr(0xdc,10); 01035 if (cy)call; 01036 else pc+=2; 01037 endinstr; 01038 01039 instr(0xdd,4); 01040 new_ixoriy=1; 01041 endinstr; 01042 01043 instr(0xde,7); 01044 suba(fetch(pc),cy); 01045 pc++; 01046 endinstr; 01047 01048 // RST 18 01049 instr(0xdf,11); 01050 push2(pc); 01051 pc=0x0018; 01052 endinstr; 01053 01054 instr(0xe0,5); 01055 if (!(f&4))ret; 01056 endinstr; 01057 01058 instr(0xe1,10); 01059 if (!ixoriy)pop1(h,l); 01060 else if (ixoriy==1)pop2(ix); 01061 else pop2(iy); 01062 endinstr; 01063 01064 instr(0xe2,10); 01065 if (!(f&4))jp; 01066 else pc+=2; 01067 endinstr; 01068 01069 instr(0xe3,19); 01070 if (!ixoriy) { 01071 unsigned short t=fetch2(sp); 01072 store2b(sp,h,l); 01073 l=t; 01074 h=t>>8; 01075 } else if (ixoriy==1) { 01076 unsigned short t=fetch2(sp); 01077 store2(sp,ix); 01078 ix=t; 01079 } else { 01080 unsigned short t=fetch2(sp); 01081 store2(sp,iy); 01082 iy=t; 01083 } 01084 endinstr; 01085 01086 instr(0xe4,10); 01087 if (!(f&4))call; 01088 else pc+=2; 01089 endinstr; 01090 01091 instr(0xe5,11); 01092 if (!ixoriy)push1(h,l); 01093 else if (ixoriy==1)push2(ix); 01094 else push2(iy); 01095 endinstr; 01096 01097 instr(0xe6,7); 01098 anda(fetch(pc)); 01099 pc++; 01100 endinstr; 01101 01102 instr(0xe7,11); 01103 push2(pc); 01104 pc=32; 01105 endinstr; 01106 01107 instr(0xe8,5); 01108 if (f&4)ret; 01109 endinstr; 01110 01111 instr(0xe9,4); 01112 pc=!ixoriy?hl:ixoriy==1?ix:iy; 01113 endinstr; 01114 01115 instr(0xea,10); 01116 if (f&4)jp; 01117 else pc+=2; 01118 endinstr; 01119 01120 instr(0xeb,4); 01121 swap(h,d); 01122 swap(e,l); 01123 endinstr; 01124 01125 instr(0xec,10); 01126 if (f&4)call; 01127 else pc+=2; 01128 endinstr; 01129 01130 instr(0xed,4); 01131 #include"edops.h" 01132 endinstr; 01133 01134 instr(0xee,7); 01135 xora(fetch(pc)); 01136 pc++; 01137 endinstr; 01138 01139 instr(0xef,11); 01140 push2(pc); 01141 pc=40; 01142 endinstr; 01143 01144 instr(0xf0,5); 01145 if (!(f&0x80))ret; 01146 endinstr; 01147 01148 instr(0xf1,10); 01149 pop1(a,f); 01150 endinstr; 01151 01152 instr(0xf2,10); 01153 if (!(f&0x80))jp; 01154 else pc+=2; 01155 endinstr; 01156 01157 instr(0xf3,4); 01158 iff1=iff2=0; 01159 // __disable_irq(); 01160 endinstr; 01161 01162 instr(0xf4,10); 01163 if (!(f&0x80))call; 01164 else pc+=2; 01165 endinstr; 01166 01167 instr(0xf5,11); 01168 push1(a,f); 01169 endinstr; 01170 01171 instr(0xf6,7); 01172 ora(fetch(pc)); 01173 pc++; 01174 endinstr; 01175 01176 // rst 30 01177 instr(0xf7,11); 01178 push2(pc); 01179 pc=0x30; 01180 // printf("RST30\n\r"); 01181 endinstr; 01182 01183 instr(0xf8,5); 01184 if (f&0x80)ret; 01185 endinstr; 01186 01187 instr(0xf9,6); 01188 sp=!ixoriy?hl:ixoriy==1?ix:iy; 01189 endinstr; 01190 01191 instr(0xfa,10); 01192 if (f&0x80)jp; 01193 else pc+=2; 01194 endinstr; 01195 01196 instr(0xfb,4); 01197 iff1=iff2=1; 01198 endinstr; 01199 01200 instr(0xfc,10); 01201 if (f&0x80)call; 01202 else pc+=2; 01203 endinstr; 01204 01205 instr(0xfd,4); 01206 new_ixoriy=2; 01207 endinstr; 01208 01209 instr(0xfe,7); 01210 cpa(fetch(pc)); 01211 pc++; 01212 endinstr; 01213 01214 instr(0xff,11); 01215 push2(pc); 01216 pc=56; 01217 endinstr; 01218
Generated on Wed Jul 13 2022 16:07:28 by 1.7.2