home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / EMULATOR / UNIX / Z80PACK / Z80SIM / SIM1.C < prev    next >
C/C++ Source or Header  |  2000-06-30  |  70KB  |  3,784 lines

  1. /*
  2.  * Z80SIM  -  a    Z80-CPU    simulator
  3.  *
  4.  * Copyright (C) 1987-92 by Udo Munk
  5.  *
  6.  * This module of the Z80-CPU simulator must not be modified by a user,
  7.  * see license agreement!
  8.  *
  9.  * History:
  10.  * 28-SEP-87 Development on TARGON/35 with AT&T Unix System V.3
  11.  * 11-JAN-89 Release 1.1
  12.  * 08-FEB-89 Release 1.2
  13.  * 13-MAR-89 Release 1.3
  14.  * 09-FEB-90 Release 1.4 Ported to TARGON/31 M10/30
  15.  * 20-DEC-90 Release 1.5 Ported to COHERENT 3.0
  16.  * 10-JUN-92 Release 1.6 long casting problem solved with COHERENT 3.2
  17.  *             and some optimization
  18.  * 25-JUN-92 Release 1.7 comments in english
  19.  */
  20.  
  21. #include "sim.h"
  22. #include "simglb.h"
  23.  
  24. /*
  25.  *    This function builds the Z80 central processing unit.
  26.  *    The opcode where PC points to is fetched from the memory
  27.  *    and PC incremented by one. The opcode is used as an
  28.  *    index to an array with function pointers, to execute a
  29.  *    function which emulates this Z80 opcode.
  30.  */
  31. cpu()
  32. {
  33.     long op_notimpl();
  34.     long op_nop(), op_halt(), op_scf(), op_ccf(), op_cpl(),    op_daa();
  35.     long op_ei(), op_di();
  36.     long op_in(), op_out();
  37.     long op_ldan(),    op_ldbn(), op_ldcn(), op_lddn(), op_lden();
  38.     long op_ldhn(),    op_ldln();
  39.     long op_ldabc(), op_ldade(), op_ldann();
  40.     long op_ldbca(), op_lddea(), op_ldnna();
  41.     long op_ldhla(), op_ldhlb(), op_ldhlc(), op_ldhld();
  42.     long op_ldhle(), op_ldhlh(), op_ldhll(), op_ldhl1();
  43.     long op_ldaa(),    op_ldab(), op_ldac(), op_ldad(), op_ldae();
  44.     long op_ldah(),    op_ldal(), op_ldahl();
  45.     long op_ldba(),    op_ldbb(), op_ldbc(), op_ldbd(), op_ldbe();
  46.     long op_ldbh(),    op_ldbl(), op_ldbhl();
  47.     long op_ldca(),    op_ldcb(), op_ldcc(), op_ldcd(), op_ldce();
  48.     long op_ldch(),    op_ldcl(), op_ldchl();
  49.     long op_ldda(),    op_lddb(), op_lddc(), op_lddd(), op_ldde();
  50.     long op_lddh(),    op_lddl(), op_lddhl();
  51.     long op_ldea(),    op_ldeb(), op_ldec(), op_lded(), op_ldee();
  52.     long op_ldeh(),    op_ldel(), op_ldehl();
  53.     long op_ldha(),    op_ldhb(), op_ldhc(), op_ldhd(), op_ldhe();
  54.     long op_ldhh(),    op_ldhl(), op_ldhhl();
  55.     long op_ldla(),    op_ldlb(), op_ldlc(), op_ldld(), op_ldle();
  56.     long op_ldlh(),    op_ldll(), op_ldlhl();
  57.     long op_ldbcnn(), op_lddenn(), op_ldhlnn(), op_ldspnn(), op_ldsphl();
  58.     long op_ldhlin(), op_ldinhl();
  59.     long op_incbc(), op_incde(), op_inchl(), op_incsp();
  60.     long op_decbc(), op_decde(), op_dechl(), op_decsp();
  61.     long op_adhlbc(), op_adhlde(), op_adhlhl(), op_adhlsp();
  62.     long op_anda(),    op_andb(), op_andc(), op_andd(), op_ande();
  63.     long op_andh(),    op_andl(), op_andhl(), op_andn();
  64.     long op_ora(), op_orb(), op_orc(), op_ord(), op_ore();
  65.     long op_orh(), op_orl(), op_orhl(), op_orn();
  66.     long op_xora(),    op_xorb(), op_xorc(), op_xord(), op_xore();
  67.     long op_xorh(),    op_xorl(), op_xorhl(), op_xorn();
  68.     long op_adda(),    op_addb(), op_addc(), op_addd(), op_adde();
  69.     long op_addh(),    op_addl(), op_addhl(), op_addn();
  70.     long op_adca(),    op_adcb(), op_adcc(), op_adcd(), op_adce();
  71.     long op_adch(),    op_adcl(), op_adchl(), op_adcn();
  72.     long op_suba(),    op_subb(), op_subc(), op_subd(), op_sube();
  73.     long op_subh(),    op_subl(), op_subhl(), op_subn();
  74.     long op_sbca(),    op_sbcb(), op_sbcc(), op_sbcd(), op_sbce();
  75.     long op_sbch(),    op_sbcl(), op_sbchl(), op_sbcn();
  76.     long op_cpa(), op_cpb(), op_cpc(), op_cpd(), op_cpe();
  77.     long op_cph(), op_cplr(), op_cphl(), op_cpn();
  78.     long op_inca(),    op_incb(), op_incc(), op_incd(), op_ince();
  79.     long op_inch(),    op_incl(), op_incihl();
  80.     long op_deca(),    op_decb(), op_decc(), op_decd(), op_dece();
  81.     long op_dech(),    op_decl(), op_decihl();
  82.     long op_rlca(),    op_rrca(),op_rla(),op_rra();
  83.     long op_exdehl(), op_exafaf(), op_exx(), op_exsphl();
  84.     long op_pushaf(), op_pushbc(), op_pushde(), op_pushhl();
  85.     long op_popaf(), op_popbc(), op_popde(), op_pophl();
  86.     long op_jp(), op_jphl(), op_jr(), op_djnz(), op_call(),    op_ret();
  87.     long op_jpz(), op_jpnz(), op_jpc(), op_jpnc();
  88.     long op_jppe(),    op_jppo(), op_jpm(), op_jpp();
  89.     long op_calz(),    op_calnz(), op_calc(), op_calnc();
  90.     long op_calpe(), op_calpo(), op_calm(),    op_calp();
  91.     long op_retz(),    op_retnz(), op_retc(), op_retnc();
  92.     long op_retpe(), op_retpo(), op_retm(),    op_retp();
  93.     long op_jrz(), op_jrnz(), op_jrc(), op_jrnc();
  94.     long op_rst00(), op_rst08(), op_rst10(), op_rst18();
  95.     long op_rst20(), op_rst28(), op_rst30(), op_rst38();
  96.     extern long op_cb_handel(), op_dd_handel(), op_ed_handel(),
  97.            op_fd_handel();
  98.  
  99.     static long (*op_sim[256]) () =    {
  100.         op_nop,                /* 0x00    */
  101.         op_ldbcnn,            /* 0x01    */
  102.         op_ldbca,            /* 0x02    */
  103.         op_incbc,            /* 0x03    */
  104.         op_incb,            /* 0x04    */
  105.         op_decb,            /* 0x05    */
  106.         op_ldbn,            /* 0x06    */
  107.         op_rlca,            /* 0x07    */
  108.         op_exafaf,            /* 0x08    */
  109.         op_adhlbc,            /* 0x09    */
  110.         op_ldabc,            /* 0x0a    */
  111.         op_decbc,            /* 0x0b    */
  112.         op_incc,            /* 0x0c    */
  113.         op_decc,            /* 0x0d    */
  114.         op_ldcn,            /* 0x0e    */
  115.         op_rrca,            /* 0x0f    */
  116.         op_djnz,            /* 0x10    */
  117.         op_lddenn,            /* 0x11    */
  118.         op_lddea,            /* 0x12    */
  119.         op_incde,            /* 0x13    */
  120.         op_incd,            /* 0x14    */
  121.         op_decd,            /* 0x15    */
  122.         op_lddn,            /* 0x16    */
  123.         op_rla,                /* 0x17    */
  124.         op_jr,                /* 0x18    */
  125.         op_adhlde,            /* 0x19    */
  126.         op_ldade,            /* 0x1a    */
  127.         op_decde,            /* 0x1b    */
  128.         op_ince,            /* 0x1c    */
  129.         op_dece,            /* 0x1d    */
  130.         op_lden,            /* 0x1e    */
  131.         op_rra,                /* 0x1f    */
  132.         op_jrnz,            /* 0x20    */
  133.         op_ldhlnn,            /* 0x21    */
  134.         op_ldinhl,            /* 0x22    */
  135.         op_inchl,            /* 0x23    */
  136.         op_inch,            /* 0x24    */
  137.         op_dech,            /* 0x25    */
  138.         op_ldhn,            /* 0x26    */
  139.         op_daa,                /* 0x27    */
  140.         op_jrz,                /* 0x28    */
  141.         op_adhlhl,            /* 0x29    */
  142.         op_ldhlin,            /* 0x2a    */
  143.         op_dechl,            /* 0x2b    */
  144.         op_incl,            /* 0x2c    */
  145.         op_decl,            /* 0x2d    */
  146.         op_ldln,            /* 0x2e    */
  147.         op_cpl,                /* 0x2f    */
  148.         op_jrnc,            /* 0x30    */
  149.         op_ldspnn,            /* 0x31    */
  150.         op_ldnna,            /* 0x32    */
  151.         op_incsp,            /* 0x33    */
  152.         op_incihl,            /* 0x34    */
  153.         op_decihl,            /* 0x35    */
  154.         op_ldhl1,            /* 0x36    */
  155.         op_scf,                /* 0x37    */
  156.         op_jrc,                /* 0x38    */
  157.         op_adhlsp,            /* 0x39    */
  158.         op_ldann,            /* 0x3a    */
  159.         op_decsp,            /* 0x3b    */
  160.         op_inca,            /* 0x3c    */
  161.         op_deca,            /* 0x3d    */
  162.         op_ldan,            /* 0x3e    */
  163.         op_ccf,                /* 0x3f    */
  164.         op_ldbb,            /* 0x40    */
  165.         op_ldbc,            /* 0x41    */
  166.         op_ldbd,            /* 0x42    */
  167.         op_ldbe,            /* 0x43    */
  168.         op_ldbh,            /* 0x44    */
  169.         op_ldbl,            /* 0x45    */
  170.         op_ldbhl,            /* 0x46    */
  171.         op_ldba,            /* 0x47    */
  172.         op_ldcb,            /* 0x48    */
  173.         op_ldcc,            /* 0x49    */
  174.         op_ldcd,            /* 0x4a    */
  175.         op_ldce,            /* 0x4b    */
  176.         op_ldch,            /* 0x4c    */
  177.         op_ldcl,            /* 0x4d    */
  178.         op_ldchl,            /* 0x4e    */
  179.         op_ldca,            /* 0x4f    */
  180.         op_lddb,            /* 0x50    */
  181.         op_lddc,            /* 0x51    */
  182.         op_lddd,            /* 0x52    */
  183.         op_ldde,            /* 0x53    */
  184.         op_lddh,            /* 0x54    */
  185.         op_lddl,            /* 0x55    */
  186.         op_lddhl,            /* 0x56    */
  187.         op_ldda,            /* 0x57    */
  188.         op_ldeb,            /* 0x58    */
  189.         op_ldec,            /* 0x59    */
  190.         op_lded,            /* 0x5a    */
  191.         op_ldee,            /* 0x5b    */
  192.         op_ldeh,            /* 0x5c    */
  193.         op_ldel,            /* 0x5d    */
  194.         op_ldehl,            /* 0x5e    */
  195.         op_ldea,            /* 0x5f    */
  196.         op_ldhb,            /* 0x60    */
  197.         op_ldhc,            /* 0x61    */
  198.         op_ldhd,            /* 0x62    */
  199.         op_ldhe,            /* 0x63    */
  200.         op_ldhh,            /* 0x64    */
  201.         op_ldhl,            /* 0x65    */
  202.         op_ldhhl,            /* 0x66    */
  203.         op_ldha,            /* 0x67    */
  204.         op_ldlb,            /* 0x68    */
  205.         op_ldlc,            /* 0x69    */
  206.         op_ldld,            /* 0x6a    */
  207.         op_ldle,            /* 0x6b    */
  208.         op_ldlh,            /* 0x6c    */
  209.         op_ldll,            /* 0x6d    */
  210.         op_ldlhl,            /* 0x6e    */
  211.         op_ldla,            /* 0x6f    */
  212.         op_ldhlb,            /* 0x70    */
  213.         op_ldhlc,            /* 0x71    */
  214.         op_ldhld,            /* 0x72    */
  215.         op_ldhle,            /* 0x73    */
  216.         op_ldhlh,            /* 0x74    */
  217.         op_ldhll,            /* 0x75    */
  218.         op_halt,            /* 0x76    */
  219.         op_ldhla,            /* 0x77    */
  220.         op_ldab,            /* 0x78    */
  221.         op_ldac,            /* 0x79    */
  222.         op_ldad,            /* 0x7a    */
  223.         op_ldae,            /* 0x7b    */
  224.         op_ldah,            /* 0x7c    */
  225.         op_ldal,            /* 0x7d    */
  226.         op_ldahl,            /* 0x7e    */
  227.         op_ldaa,            /* 0x7f    */
  228.         op_addb,            /* 0x80    */
  229.         op_addc,            /* 0x81    */
  230.         op_addd,            /* 0x82    */
  231.         op_adde,            /* 0x83    */
  232.         op_addh,            /* 0x84    */
  233.         op_addl,            /* 0x85    */
  234.         op_addhl,            /* 0x86    */
  235.         op_adda,            /* 0x87    */
  236.         op_adcb,            /* 0x88    */
  237.         op_adcc,            /* 0x89    */
  238.         op_adcd,            /* 0x8a    */
  239.         op_adce,            /* 0x8b    */
  240.         op_adch,            /* 0x8c    */
  241.         op_adcl,            /* 0x8d    */
  242.         op_adchl,            /* 0x8e    */
  243.         op_adca,            /* 0x8f    */
  244.         op_subb,            /* 0x90    */
  245.         op_subc,            /* 0x91    */
  246.         op_subd,            /* 0x92    */
  247.         op_sube,            /* 0x93    */
  248.         op_subh,            /* 0x94    */
  249.         op_subl,            /* 0x95    */
  250.         op_subhl,            /* 0x96    */
  251.         op_suba,            /* 0x97    */
  252.         op_sbcb,            /* 0x98    */
  253.         op_sbcc,            /* 0x99    */
  254.         op_sbcd,            /* 0x9a    */
  255.         op_sbce,            /* 0x9b    */
  256.         op_sbch,            /* 0x9c    */
  257.         op_sbcl,            /* 0x9d    */
  258.         op_sbchl,            /* 0x9e    */
  259.         op_sbca,            /* 0x9f    */
  260.         op_andb,            /* 0xa0    */
  261.         op_andc,            /* 0xa1    */
  262.         op_andd,            /* 0xa2    */
  263.         op_ande,            /* 0xa3    */
  264.         op_andh,            /* 0xa4    */
  265.         op_andl,            /* 0xa5    */
  266.         op_andhl,            /* 0xa6    */
  267.         op_anda,            /* 0xa7    */
  268.         op_xorb,            /* 0xa8    */
  269.         op_xorc,            /* 0xa9    */
  270.         op_xord,            /* 0xaa    */
  271.         op_xore,            /* 0xab    */
  272.         op_xorh,            /* 0xac    */
  273.         op_xorl,            /* 0xad    */
  274.         op_xorhl,            /* 0xae    */
  275.         op_xora,            /* 0xaf    */
  276.         op_orb,                /* 0xb0    */
  277.         op_orc,                /* 0xb1    */
  278.         op_ord,                /* 0xb2    */
  279.         op_ore,                /* 0xb3    */
  280.         op_orh,                /* 0xb4    */
  281.         op_orl,                /* 0xb5    */
  282.         op_orhl,            /* 0xb6    */
  283.         op_ora,                /* 0xb7    */
  284.         op_cpb,                /* 0xb8    */
  285.         op_cpc,                /* 0xb9    */
  286.         op_cpd,                /* 0xba    */
  287.         op_cpe,                /* 0xbb    */
  288.         op_cph,                /* 0xbc    */
  289.         op_cplr,            /* 0xbd    */
  290.         op_cphl,            /* 0xbe    */
  291.         op_cpa,                /* 0xbf    */
  292.         op_retnz,            /* 0xc0    */
  293.         op_popbc,            /* 0xc1    */
  294.         op_jpnz,            /* 0xc2    */
  295.         op_jp,                /* 0xc3    */
  296.         op_calnz,            /* 0xc4    */
  297.         op_pushbc,            /* 0xc5    */
  298.         op_addn,            /* 0xc6    */
  299.         op_rst00,            /* 0xc7    */
  300.         op_retz,            /* 0xc8    */
  301.         op_ret,                /* 0xc9    */
  302.         op_jpz,                /* 0xca    */
  303.         op_cb_handel,            /* 0xcb    */
  304.         op_calz,            /* 0xcc    */
  305.         op_call,            /* 0xcd    */
  306.         op_adcn,            /* 0xce    */
  307.         op_rst08,            /* 0xcf    */
  308.         op_retnc,            /* 0xd0    */
  309.         op_popde,            /* 0xd1    */
  310.         op_jpnc,            /* 0xd2    */
  311.         op_out,                /* 0xd3    */
  312.         op_calnc,            /* 0xd4    */
  313.         op_pushde,            /* 0xd5    */
  314.         op_subn,            /* 0xd6    */
  315.         op_rst10,            /* 0xd7    */
  316.         op_retc,            /* 0xd8    */
  317.         op_exx,                /* 0xd9    */
  318.         op_jpc,                /* 0xda    */
  319.         op_in,                /* 0xdb    */
  320.         op_calc,            /* 0xdc    */
  321.         op_dd_handel,            /* 0xdd    */
  322.         op_sbcn,            /* 0xde    */
  323.         op_rst18,            /* 0xdf    */
  324.         op_retpo,            /* 0xe0    */
  325.         op_pophl,            /* 0xe1    */
  326.         op_jppo,            /* 0xe2    */
  327.         op_exsphl,            /* 0xe3    */
  328.         op_calpo,            /* 0xe4    */
  329.         op_pushhl,            /* 0xe5    */
  330.         op_andn,            /* 0xe6    */
  331.         op_rst20,            /* 0xe7    */
  332.         op_retpe,            /* 0xe8    */
  333.         op_jphl,            /* 0xe9    */
  334.         op_jppe,            /* 0xea    */
  335.         op_exdehl,            /* 0xeb    */
  336.         op_calpe,            /* 0xec    */
  337.         op_ed_handel,            /* 0xed    */
  338.         op_xorn,            /* 0xee    */
  339.         op_rst28,            /* 0xef    */
  340.         op_retp,            /* 0xf0    */
  341.         op_popaf,            /* 0xf1    */
  342.         op_jpp,                /* 0xf2    */
  343.         op_di,                /* 0xf3    */
  344.         op_calp,            /* 0xf4    */
  345.         op_pushaf,            /* 0xf5    */
  346.         op_orn,                /* 0xf6    */
  347.         op_rst30,            /* 0xf7    */
  348.         op_retm,            /* 0xf8    */
  349.         op_ldsphl,            /* 0xf9    */
  350.         op_jpm,                /* 0xfa    */
  351.         op_ei,                /* 0xfb    */
  352.         op_calm,            /* 0xfc    */
  353.         op_fd_handel,            /* 0xfd    */
  354.         op_cpn,                /* 0xfe    */
  355.         op_rst38            /* 0xff    */
  356.     };
  357.  
  358. #ifdef WANT_TIM
  359.     register long t;
  360. #endif
  361.  
  362.     do {
  363.  
  364. #ifdef HISIZE        /* write history */
  365.         his[h_next].h_adr = PC - ram;
  366.         his[h_next].h_af = (A << 8) + F;
  367.         his[h_next].h_bc = (B << 8) + C;
  368.         his[h_next].h_de = (D << 8) + E;
  369.         his[h_next].h_hl = (H << 8) + L;
  370.         his[h_next].h_ix = IX;
  371.         his[h_next].h_iy = IY;
  372.         his[h_next].h_sp = STACK - ram;
  373.         h_next++;
  374.         if (h_next == HISIZE) {
  375.             h_flag = 1;
  376.             h_next = 0;
  377.         }
  378. #endif
  379.  
  380. #ifdef WANT_TIM        /* check for start address of runtime measurement */
  381.         if (PC == t_start && !t_flag) {
  382.             t_flag = 1;    /* switch measurement on */
  383.             t_states = 0L;    /* initialize counted T-states */
  384.         }
  385. #endif
  386.  
  387. #ifdef WANT_INT        /* CPU interrupt handling */
  388.         if (int_type)
  389.             switch (int_type) {
  390.             case INT_NMI:    /* non maskable interrupt */
  391.                 break;
  392.             case INT_INT:    /* maskable interrupt */
  393.                 break;
  394.             }
  395. #endif
  396.  
  397. #ifdef WANT_TIM
  398.         t = (*op_sim[*PC++]) ();/* execute next opcode */
  399. #else
  400.         (*op_sim[*PC++]) ();
  401. #endif
  402.  
  403. #ifdef WANT_PCC
  404.         if (PC > ram + 65535)    /* check for PC overrun */
  405.             PC = ram;
  406. #endif
  407.  
  408.         R++;            /* increment refresh register */
  409.  
  410. #ifdef WANT_TIM                /* do runtime measurement */
  411.         if (t_flag) {
  412.             t_states += t;    /* add T-states for this opcode */
  413.             if (PC == t_end) /* check for end address */
  414.                 t_flag = 0; /* if reached, switch measurement off */
  415.         }
  416. #endif
  417.  
  418.     } while    (cpu_state);
  419. }
  420.  
  421. /*
  422.  *    Trap not implemented opcodes. This function may be usefull
  423.  *    later to trap some wanted opcodes.
  424.  */
  425. static long op_notimpl()
  426. {
  427.     cpu_error = OPTRAP1;
  428.     cpu_state = STOPPED;
  429. #ifdef WANT_TIM
  430.     return(0L);
  431. #endif
  432. }
  433.  
  434. static long op_nop()             /*    NOP */
  435. {
  436. #ifdef WANT_TIM
  437.     return(4L);
  438. #endif
  439. }
  440.  
  441. static long op_halt()             /*    HALT */
  442. {
  443.     if (break_flag)    {
  444.         cpu_error = OPHALT;
  445.         cpu_state = STOPPED;
  446.     } else
  447.         while (int_type    == 0)
  448.             R++;
  449. #ifdef WANT_TIM
  450.     return(0L);
  451. #endif
  452. }
  453.  
  454. static long op_scf()             /*    SCF */
  455. {
  456.     F |= C_FLAG;
  457.     F &= ~(N_FLAG |    H_FLAG);
  458. #ifdef WANT_TIM
  459.     return(4L);
  460. #endif
  461. }
  462.  
  463. static long op_ccf()             /*    CCF */
  464. {
  465.     if (F &    C_FLAG)    {
  466.         F |= H_FLAG;
  467.         F &= ~C_FLAG;
  468.     } else {
  469.         F &= ~H_FLAG;
  470.         F |= C_FLAG;
  471.     }
  472.     F &= ~N_FLAG;
  473. #ifdef WANT_TIM
  474.     return(4L);
  475. #endif
  476. }
  477.  
  478. static long op_cpl()             /*    CPL */
  479. {
  480.     A = ~A;
  481.     F |= H_FLAG | N_FLAG;
  482. #ifdef WANT_TIM
  483.     return(4L);
  484. #endif
  485. }
  486.  
  487. static long op_daa()             /*    DAA */
  488. {
  489.     register int old_a;
  490.  
  491.     old_a =    A;
  492.     if (F &    N_FLAG)    {        /* subtractions */
  493.         if (((A    & 0x0f)    > 9) ||    (F & H_FLAG)) {
  494.             (((old_a & 0x0f) - 6) <    0) ? (F    |= H_FLAG) : (F    &= ~H_FLAG);
  495.             A = old_a -= 6;
  496.         }
  497.         if (((A    & 0xf0)    > 0x90)    || (F &    C_FLAG)) {
  498.             A -= 0x60;
  499.             if (old_a - 0x60 < 0)
  500.                 F |= C_FLAG;
  501.         }
  502.     } else {            /* additions */
  503.         if (((A    & 0x0f)    > 9) ||    (F & H_FLAG)) {
  504.             (((old_a & 0x0f) + 6) >    0x0f) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  505.             A = old_a += 6;
  506.         }
  507.         if (((A    & 0xf0)    > 0x90)    || (F &    C_FLAG)) {
  508.             A += 0x60;
  509.             if (old_a + 0x60 > 255)
  510.                 F |= C_FLAG;
  511.         }
  512.     }
  513.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  514.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  515.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  516. #ifdef WANT_TIM
  517.     return(4L);
  518. #endif
  519. }
  520.  
  521. static long op_ei()             /*    EI */
  522. {
  523.     IFF = 2;
  524. #ifdef WANT_TIM
  525.     return(4L);
  526. #endif
  527. }
  528.  
  529. static long op_di()             /*    DI */
  530. {
  531.     IFF = 0;
  532. #ifdef WANT_TIM
  533.     return(4L);
  534. #endif
  535. }
  536.  
  537. static long op_in()             /*    IN A,(n) */
  538. {
  539.     BYTE io_in();
  540.  
  541.     A = io_in(*PC++);
  542. #ifdef WANT_TIM
  543.     return(11L);
  544. #endif
  545. }
  546.  
  547. static long op_out()             /*    OUT (n),A */
  548. {
  549.     BYTE io_out();
  550.  
  551.     io_out(*PC++, A);
  552. #ifdef WANT_TIM
  553.     return(11L);
  554. #endif
  555. }
  556.  
  557. static long op_ldan()             /*    LD A,n */
  558. {
  559.     A = *PC++;
  560. #ifdef WANT_TIM
  561.     return(7L);
  562. #endif
  563. }
  564.  
  565. static long op_ldbn()             /*    LD B,n */
  566. {
  567.     B = *PC++;
  568. #ifdef WANT_TIM
  569.     return(7L);
  570. #endif
  571. }
  572.  
  573. static long op_ldcn()             /*    LD C,n */
  574. {
  575.     C = *PC++;
  576. #ifdef WANT_TIM
  577.     return(7L);
  578. #endif
  579. }
  580.  
  581. static long op_lddn()             /*    LD D,n */
  582. {
  583.     D = *PC++;
  584. #ifdef WANT_TIM
  585.     return(7L);
  586. #endif
  587. }
  588.  
  589. static long op_lden()             /*    LD E,n */
  590. {
  591.     E = *PC++;
  592. #ifdef WANT_TIM
  593.     return(7L);
  594. #endif
  595. }
  596.  
  597. static long op_ldhn()             /*    LD H,n */
  598. {
  599.     H = *PC++;
  600. #ifdef WANT_TIM
  601.     return(7L);
  602. #endif
  603. }
  604.  
  605. static long op_ldln()             /*    LD L,n */
  606. {
  607.     L = *PC++;
  608. #ifdef WANT_TIM
  609.     return(7L);
  610. #endif
  611. }
  612.  
  613. static long op_ldabc()             /*    LD A,(BC) */
  614. {
  615.     A = *(ram + (B << 8) + C);
  616. #ifdef WANT_TIM
  617.     return(7L);
  618. #endif
  619. }
  620.  
  621. static long op_ldade()             /*    LD A,(DE) */
  622. {
  623.     A = *(ram + (D << 8) + E);
  624. #ifdef WANT_TIM
  625.     return(7L);
  626. #endif
  627. }
  628.  
  629. static long op_ldann()             /*    LD A,(nn) */
  630. {
  631.     register unsigned i;
  632.  
  633.     i = *PC++;
  634.     i += *PC++ << 8;
  635.     A = *(ram + i);
  636. #ifdef WANT_TIM
  637.     return(13L);
  638. #endif
  639. }
  640.  
  641. static long op_ldbca()             /*    LD (BC),A */
  642. {
  643.     *(ram +    (B << 8) + C) =    A;
  644. #ifdef WANT_TIM
  645.     return(7L);
  646. #endif
  647. }
  648.  
  649. static long op_lddea()             /*    LD (DE),A */
  650. {
  651.     *(ram +    (D << 8) + E) =    A;
  652. #ifdef WANT_TIM
  653.     return(7L);
  654. #endif
  655. }
  656.  
  657. static long op_ldnna()             /*    LD (nn),A */
  658. {
  659.     register unsigned i;
  660.  
  661.     i = *PC++;
  662.     i += *PC++ << 8;
  663.     *(ram +    i) = A;
  664. #ifdef WANT_TIM
  665.     return(13L);
  666. #endif
  667. }
  668.  
  669. static long op_ldhla()             /*    LD (HL),A */
  670. {
  671.     *(ram +    (H << 8) + L) =    A;
  672. #ifdef WANT_TIM
  673.     return(7L);
  674. #endif
  675. }
  676.  
  677. static long op_ldhlb()             /*    LD (HL),B */
  678. {
  679.     *(ram +    (H << 8) + L) =    B;
  680. #ifdef WANT_TIM
  681.     return(7L);
  682. #endif
  683. }
  684.  
  685. static long op_ldhlc()             /*    LD (HL),C */
  686. {
  687.     *(ram +    (H << 8) + L) =    C;
  688. #ifdef WANT_TIM
  689.     return(7L);
  690. #endif
  691. }
  692.  
  693. static long op_ldhld()             /*    LD (HL),D */
  694. {
  695.     *(ram +    (H << 8) + L) =    D;
  696. #ifdef WANT_TIM
  697.     return(7L);
  698. #endif
  699. }
  700.  
  701. static long op_ldhle()             /*    LD (HL),E */
  702. {
  703.     *(ram +    (H << 8) + L) =    E;
  704. #ifdef WANT_TIM
  705.     return(7L);
  706. #endif
  707. }
  708.  
  709. static long op_ldhlh()             /*    LD (HL),H */
  710. {
  711.     *(ram +    (H << 8) + L) =    H;
  712. #ifdef WANT_TIM
  713.     return(7L);
  714. #endif
  715. }
  716.  
  717. static long op_ldhll()             /*    LD (HL),L */
  718. {
  719.     *(ram +    (H << 8) + L) =    L;
  720. #ifdef WANT_TIM
  721.     return(7L);
  722. #endif
  723. }
  724.  
  725. static long op_ldhl1()             /*    LD (HL),n */
  726. {
  727.     *(ram +    (H << 8) + L) =    *PC++;
  728. #ifdef WANT_TIM
  729.     return(10L);
  730. #endif
  731. }
  732.  
  733. static long op_ldaa()             /*    LD A,A */
  734. {
  735. #ifdef WANT_TIM
  736.     return(4L);
  737. #endif
  738. }
  739.  
  740. static long op_ldab()             /*    LD A,B */
  741. {
  742.     A = B;
  743. #ifdef WANT_TIM
  744.     return(4L);
  745. #endif
  746. }
  747.  
  748. static long op_ldac()             /*    LD A,C */
  749. {
  750.     A = C;
  751. #ifdef WANT_TIM
  752.     return(4L);
  753. #endif
  754. }
  755.  
  756. static long op_ldad()             /*    LD A,D */
  757. {
  758.     A = D;
  759. #ifdef WANT_TIM
  760.     return(4L);
  761. #endif
  762. }
  763.  
  764. static long op_ldae()             /*    LD A,E */
  765. {
  766.     A = E;
  767. #ifdef WANT_TIM
  768.     return(4L);
  769. #endif
  770. }
  771.  
  772. static long op_ldah()             /*    LD A,H */
  773. {
  774.     A = H;
  775. #ifdef WANT_TIM
  776.     return(4L);
  777. #endif
  778. }
  779.  
  780. static long op_ldal()             /*    LD A,L */
  781. {
  782.     A = L;
  783. #ifdef WANT_TIM
  784.     return(4L);
  785. #endif
  786. }
  787.  
  788. static long op_ldahl()             /*    LD A,(HL) */
  789. {
  790.     A = *(ram + (H << 8) + L);
  791. #ifdef WANT_TIM
  792.     return(7L);
  793. #endif
  794. }
  795.  
  796. static long op_ldba()             /*    LD B,A */
  797. {
  798.     B = A;
  799. #ifdef WANT_TIM
  800.     return(4L);
  801. #endif
  802. }
  803.  
  804. static long op_ldbb()             /*    LD B,B */
  805. {
  806. #ifdef WANT_TIM
  807.     return(4L);
  808. #endif
  809. }
  810.  
  811. static long op_ldbc()             /*    LD B,C */
  812. {
  813.     B = C;
  814. #ifdef WANT_TIM
  815.     return(4L);
  816. #endif
  817. }
  818.  
  819. static long op_ldbd()             /*    LD B,D */
  820. {
  821.     B = D;
  822. #ifdef WANT_TIM
  823.     return(4L);
  824. #endif
  825. }
  826.  
  827. static long op_ldbe()             /*    LD B,E */
  828. {
  829.     B = E;
  830. #ifdef WANT_TIM
  831.     return(4L);
  832. #endif
  833. }
  834.  
  835. static long op_ldbh()             /*    LD B,H */
  836. {
  837.     B = H;
  838. #ifdef WANT_TIM
  839.     return(4L);
  840. #endif
  841. }
  842.  
  843. static long op_ldbl()             /*    LD B,L */
  844. {
  845.     B = L;
  846. #ifdef WANT_TIM
  847.     return(4L);
  848. #endif
  849. }
  850.  
  851. static long op_ldbhl()             /*    LD B,(HL) */
  852. {
  853.     B = *(ram + (H << 8) + L);
  854. #ifdef WANT_TIM
  855.     return(7L);
  856. #endif
  857. }
  858.  
  859. static long op_ldca()             /*    LD C,A */
  860. {
  861.     C = A;
  862. #ifdef WANT_TIM
  863.     return(4L);
  864. #endif
  865. }
  866.  
  867. static long op_ldcb()             /*    LD C,B */
  868. {
  869.     C = B;
  870. #ifdef WANT_TIM
  871.     return(4L);
  872. #endif
  873. }
  874.  
  875. static long op_ldcc()             /*    LD C,C */
  876. {
  877. #ifdef WANT_TIM
  878.     return(4L);
  879. #endif
  880. }
  881.  
  882. static long op_ldcd()             /*    LD C,D */
  883. {
  884.     C = D;
  885. #ifdef WANT_TIM
  886.     return(4L);
  887. #endif
  888. }
  889.  
  890. static long op_ldce()             /*    LD C,E */
  891. {
  892.     C = E;
  893. #ifdef WANT_TIM
  894.     return(4L);
  895. #endif
  896. }
  897.  
  898. static long op_ldch()             /*    LD C,H */
  899. {
  900.     C = H;
  901. #ifdef WANT_TIM
  902.     return(4L);
  903. #endif
  904. }
  905.  
  906. static long op_ldcl()             /*    LD C,L */
  907. {
  908.     C = L;
  909. #ifdef WANT_TIM
  910.     return(4L);
  911. #endif
  912. }
  913.  
  914. static long op_ldchl()             /*    LD C,(HL) */
  915. {
  916.     C = *(ram + (H << 8) + L);
  917. #ifdef WANT_TIM
  918.     return(7L);
  919. #endif
  920. }
  921.  
  922. static long op_ldda()             /*    LD D,A */
  923. {
  924.     D = A;
  925. #ifdef WANT_TIM
  926.     return(4L);
  927. #endif
  928. }
  929.  
  930. static long op_lddb()             /*    LD D,B */
  931. {
  932.     D = B;
  933. #ifdef WANT_TIM
  934.     return(4L);
  935. #endif
  936. }
  937.  
  938. static long op_lddc()             /*    LD D,C */
  939. {
  940.     D = C;
  941. #ifdef WANT_TIM
  942.     return(4L);
  943. #endif
  944. }
  945.  
  946. static long op_lddd()             /*    LD D,D */
  947. {
  948. #ifdef WANT_TIM
  949.     return(4L);
  950. #endif
  951. }
  952.  
  953. static long op_ldde()             /*    LD D,E */
  954. {
  955.     D = E;
  956. #ifdef WANT_TIM
  957.     return(4L);
  958. #endif
  959. }
  960.  
  961. static long op_lddh()             /*    LD D,H */
  962. {
  963.     D = H;
  964. #ifdef WANT_TIM
  965.     return(4L);
  966. #endif
  967. }
  968.  
  969. static long op_lddl()             /*    LD D,L */
  970. {
  971.     D = L;
  972. #ifdef WANT_TIM
  973.     return(4L);
  974. #endif
  975. }
  976.  
  977. static long op_lddhl()             /*    LD D,(HL) */
  978. {
  979.     D = *(ram + (H << 8) + L);
  980. #ifdef WANT_TIM
  981.     return(7L);
  982. #endif
  983. }
  984.  
  985. static long op_ldea()             /*    LD E,A */
  986. {
  987.     E = A;
  988. #ifdef WANT_TIM
  989.     return(4L);
  990. #endif
  991. }
  992.  
  993. static long op_ldeb()             /*    LD E,B */
  994. {
  995.     E = B;
  996. #ifdef WANT_TIM
  997.     return(4L);
  998. #endif
  999. }
  1000.  
  1001. static long op_ldec()             /*    LD E,C */
  1002. {
  1003.     E = C;
  1004. #ifdef WANT_TIM
  1005.     return(4L);
  1006. #endif
  1007. }
  1008.  
  1009. static long op_lded()             /*    LD E,D */
  1010. {
  1011.     E = D;
  1012. #ifdef WANT_TIM
  1013.     return(4L);
  1014. #endif
  1015. }
  1016.  
  1017. static long op_ldee()             /*    LD E,E */
  1018. {
  1019. #ifdef WANT_TIM
  1020.     return(4L);
  1021. #endif
  1022. }
  1023.  
  1024. static long op_ldeh()             /*    LD E,H */
  1025. {
  1026.     E = H;
  1027. #ifdef WANT_TIM
  1028.     return(4L);
  1029. #endif
  1030. }
  1031.  
  1032. static long op_ldel()             /*    LD E,L */
  1033. {
  1034.     E = L;
  1035. #ifdef WANT_TIM
  1036.     return(4L);
  1037. #endif
  1038. }
  1039.  
  1040. static long op_ldehl()             /*    LD E,(HL) */
  1041. {
  1042.     E = *(ram + (H << 8) + L);
  1043. #ifdef WANT_TIM
  1044.     return(7L);
  1045. #endif
  1046. }
  1047.  
  1048. static long op_ldha()             /*    LD H,A */
  1049. {
  1050.     H = A;
  1051. #ifdef WANT_TIM
  1052.     return(4L);
  1053. #endif
  1054. }
  1055.  
  1056. static long op_ldhb()             /*    LD H,B */
  1057. {
  1058.     H = B;
  1059. #ifdef WANT_TIM
  1060.     return(4L);
  1061. #endif
  1062. }
  1063.  
  1064. static long op_ldhc()             /*    LD H,C */
  1065. {
  1066.     H = C;
  1067. #ifdef WANT_TIM
  1068.     return(4L);
  1069. #endif
  1070. }
  1071.  
  1072. static long op_ldhd()             /*    LD H,D */
  1073. {
  1074.     H = D;
  1075. #ifdef WANT_TIM
  1076.     return(4L);
  1077. #endif
  1078. }
  1079.  
  1080. static long op_ldhe()             /*    LD H,E */
  1081. {
  1082.     H = E;
  1083. #ifdef WANT_TIM
  1084.     return(4L);
  1085. #endif
  1086. }
  1087.  
  1088. static long op_ldhh()             /*    LD H,H */
  1089. {
  1090. #ifdef WANT_TIM
  1091.     return(4L);
  1092. #endif
  1093. }
  1094.  
  1095. static long op_ldhl()             /*    LD H,L */
  1096. {
  1097.     H = L;
  1098. #ifdef WANT_TIM
  1099.     return(4L);
  1100. #endif
  1101. }
  1102.  
  1103. static long op_ldhhl()             /*    LD H,(HL) */
  1104. {
  1105.     H = *(ram + (H << 8) + L);
  1106. #ifdef WANT_TIM
  1107.     return(7L);
  1108. #endif
  1109. }
  1110.  
  1111. static long op_ldla()             /*    LD L,A */
  1112. {
  1113.     L = A;
  1114. #ifdef WANT_TIM
  1115.     return(4L);
  1116. #endif
  1117. }
  1118.  
  1119. static long op_ldlb()             /*    LD L,B */
  1120. {
  1121.     L = B;
  1122. #ifdef WANT_TIM
  1123.     return(4L);
  1124. #endif
  1125. }
  1126.  
  1127. static long op_ldlc()             /*    LD L,C */
  1128. {
  1129.     L = C;
  1130. #ifdef WANT_TIM
  1131.     return(4L);
  1132. #endif
  1133. }
  1134.  
  1135. static long op_ldld()             /*    LD L,D */
  1136. {
  1137.     L = D;
  1138. #ifdef WANT_TIM
  1139.     return(4L);
  1140. #endif
  1141. }
  1142.  
  1143. static long op_ldle()             /*    LD L,E */
  1144. {
  1145.     L = E;
  1146. #ifdef WANT_TIM
  1147.     return(4L);
  1148. #endif
  1149. }
  1150.  
  1151. static long op_ldlh()             /*    LD L,H */
  1152. {
  1153.     L = H;
  1154. #ifdef WANT_TIM
  1155.     return(4L);
  1156. #endif
  1157. }
  1158.  
  1159. static long op_ldll()             /*    LD L,L */
  1160. {
  1161. #ifdef WANT_TIM
  1162.     return(4L);
  1163. #endif
  1164. }
  1165.  
  1166. static long op_ldlhl()             /*    LD L,(HL) */
  1167. {
  1168.     L = *(ram + (H << 8) + L);
  1169. #ifdef WANT_TIM
  1170.     return(7L);
  1171. #endif
  1172. }
  1173.  
  1174. static long op_ldbcnn()             /*    LD BC,nn */
  1175. {
  1176.     C = *PC++;
  1177.     B = *PC++;
  1178. #ifdef WANT_TIM
  1179.     return(10L);
  1180. #endif
  1181. }
  1182.  
  1183. static long op_lddenn()             /*    LD DE,nn */
  1184. {
  1185.     E = *PC++;
  1186.     D = *PC++;
  1187. #ifdef WANT_TIM
  1188.     return(10L);
  1189. #endif
  1190. }
  1191.  
  1192. static long op_ldhlnn()             /*    LD HL,nn */
  1193. {
  1194.     L = *PC++;
  1195.     H = *PC++;
  1196. #ifdef WANT_TIM
  1197.     return(10L);
  1198. #endif
  1199. }
  1200.  
  1201. static long op_ldspnn()             /*    LD SP,nn */
  1202. {
  1203.     STACK =    ram + *PC++;
  1204.     STACK += *PC++ << 8;
  1205. #ifdef WANT_TIM
  1206.     return(10L);
  1207. #endif
  1208. }
  1209.  
  1210. static long op_ldsphl()             /*    LD SP,HL */
  1211. {
  1212.     STACK =    ram + (H << 8) + L;
  1213. #ifdef WANT_TIM
  1214.     return(6L);
  1215. #endif
  1216. }
  1217.  
  1218. static long op_ldhlin()             /*    LD HL,(nn) */
  1219. {
  1220.     register unsigned i;
  1221.  
  1222.     i = *PC++;
  1223.     i += *PC++ << 8;
  1224.     L = *(ram + i);
  1225.     H = *(ram + i +    1);
  1226. #ifdef WANT_TIM
  1227.     return(16L);
  1228. #endif
  1229. }
  1230.  
  1231. static long op_ldinhl()             /*    LD (nn),HL */
  1232. {
  1233.     register unsigned i;
  1234.  
  1235.     i = *PC++;
  1236.     i += *PC++ << 8;
  1237.     *(ram +    i) = L;
  1238.     *(ram +    i + 1) = H;
  1239. #ifdef WANT_TIM
  1240.     return(16L);
  1241. #endif
  1242. }
  1243.  
  1244. static long op_incbc()             /*    INC BC */
  1245. {
  1246.     C++;
  1247.     if (!C)
  1248.         B++;
  1249. #ifdef WANT_TIM
  1250.     return(6L);
  1251. #endif
  1252. }
  1253.  
  1254. static long op_incde()             /*    INC DE */
  1255. {
  1256.     E++;
  1257.     if (!E)
  1258.         D++;
  1259. #ifdef WANT_TIM
  1260.     return(6L);
  1261. #endif
  1262. }
  1263.  
  1264. static long op_inchl()             /*    INC HL */
  1265. {
  1266.     L++;
  1267.     if (!L)
  1268.         H++;
  1269. #ifdef WANT_TIM
  1270.     return(6L);
  1271. #endif
  1272. }
  1273.  
  1274. static long op_incsp()             /*    INC SP */
  1275. {
  1276.     STACK++;
  1277. #ifdef WANT_SPC
  1278.     if (STACK > ram    + 65535)
  1279.         STACK =    ram;
  1280. #endif
  1281. #ifdef WANT_TIM
  1282.     return(6L);
  1283. #endif
  1284. }
  1285.  
  1286. static long op_decbc()             /*    DEC BC */
  1287. {
  1288.     C--;
  1289.     if (C == 0xff)
  1290.         B--;
  1291. #ifdef WANT_TIM
  1292.     return(6L);
  1293. #endif
  1294. }
  1295.  
  1296. static long op_decde()             /*    DEC DE */
  1297. {
  1298.     E--;
  1299.     if (E == 0xff)
  1300.         D--;
  1301. #ifdef WANT_TIM
  1302.     return(6L);
  1303. #endif
  1304. }
  1305.  
  1306. static long op_dechl()             /*    DEC HL */
  1307. {
  1308.     L--;
  1309.     if (L == 0xff)
  1310.         H--;
  1311. #ifdef WANT_TIM
  1312.     return(6L);
  1313. #endif
  1314. }
  1315.  
  1316. static long op_decsp()             /*    DEC SP */
  1317. {
  1318.     STACK--;
  1319. #ifdef WANT_SPC
  1320.     if (STACK < ram)
  1321.         STACK =    ram + 65535;
  1322. #endif
  1323. #ifdef WANT_TIM
  1324.     return(6L);
  1325. #endif
  1326. }
  1327.  
  1328. static long op_adhlbc()             /*    ADD HL,BC */
  1329. {
  1330.     register long i;
  1331.  
  1332.     i = ((((long)H) << 8) + L + (((long)B) << 8) + C);
  1333.     H = i >> 8;
  1334.     L = i;
  1335.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1336.     F &= ~N_FLAG;
  1337. #ifdef WANT_TIM
  1338.     return(11L);
  1339. #endif
  1340. }
  1341.  
  1342. static long op_adhlde()             /*    ADD HL,DE */
  1343. {
  1344.     register long i;
  1345.  
  1346.     i = ((((long)H) << 8) + L + (((long)D) << 8) + E);
  1347.     H = i >> 8;
  1348.     L = i;
  1349.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1350.     F &= ~N_FLAG;
  1351. #ifdef WANT_TIM
  1352.     return(11L);
  1353. #endif
  1354. }
  1355.  
  1356. static long op_adhlhl()             /*    ADD HL,HL */
  1357. {
  1358.     register long i;
  1359.  
  1360.     i = (((((long)H) << 8) + L) << 1);
  1361.     H = i >> 8;
  1362.     L = i;
  1363.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1364.     F &= ~N_FLAG;
  1365. #ifdef WANT_TIM
  1366.     return(11L);
  1367. #endif
  1368. }
  1369.  
  1370. static long op_adhlsp()             /*    ADD HL,SP */
  1371. {
  1372.     register long i;
  1373.  
  1374.     i = ((((long)H) << 8) + L + STACK - ram);
  1375.     H = i >> 8;
  1376.     L = i;
  1377.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1378.     F &= ~N_FLAG;
  1379. #ifdef WANT_TIM
  1380.     return(11L);
  1381. #endif
  1382. }
  1383.  
  1384. static long op_anda()             /*    AND A */
  1385. {
  1386.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1387.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1388.     F |= H_FLAG;
  1389.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1390.     F &= ~(N_FLAG |    C_FLAG);
  1391. #ifdef WANT_TIM
  1392.     return(4L);
  1393. #endif
  1394. }
  1395.  
  1396. static long op_andb()             /*    AND B */
  1397. {
  1398.     A &= B;
  1399.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1400.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1401.     F |= H_FLAG;
  1402.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1403.     F &= ~(N_FLAG |    C_FLAG);
  1404. #ifdef WANT_TIM
  1405.     return(4L);
  1406. #endif
  1407. }
  1408.  
  1409. static long op_andc()             /*    AND C */
  1410. {
  1411.     A &= C;
  1412.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1413.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1414.     F |= H_FLAG;
  1415.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1416.     F &= ~(N_FLAG |    C_FLAG);
  1417. #ifdef WANT_TIM
  1418.     return(4L);
  1419. #endif
  1420. }
  1421.  
  1422. static long op_andd()             /*    AND D */
  1423. {
  1424.     A &= D;
  1425.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1426.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1427.     F |= H_FLAG;
  1428.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1429.     F &= ~(N_FLAG |    C_FLAG);
  1430. #ifdef WANT_TIM
  1431.     return(4L);
  1432. #endif
  1433. }
  1434.  
  1435. static long op_ande()             /*    AND E */
  1436. {
  1437.     A &= E;
  1438.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1439.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1440.     F |= H_FLAG;
  1441.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1442.     F &= ~(N_FLAG |    C_FLAG);
  1443. #ifdef WANT_TIM
  1444.     return(4L);
  1445. #endif
  1446. }
  1447.  
  1448. static long op_andh()             /*    AND H */
  1449. {
  1450.     A &= H;
  1451.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1452.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1453.     F |= H_FLAG;
  1454.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1455.     F &= ~(N_FLAG |    C_FLAG);
  1456. #ifdef WANT_TIM
  1457.     return(4L);
  1458. #endif
  1459. }
  1460.  
  1461. static long op_andl()             /*    AND L */
  1462. {
  1463.     A &= L;
  1464.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1465.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1466.     F |= H_FLAG;
  1467.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1468.     F &= ~(N_FLAG |    C_FLAG);
  1469. #ifdef WANT_TIM
  1470.     return(4L);
  1471. #endif
  1472. }
  1473.  
  1474. static long op_andhl()             /*    AND (HL) */
  1475. {
  1476.     A &= *(ram + (H    << 8) +    L);
  1477.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1478.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1479.     F |= H_FLAG;
  1480.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1481.     F &= ~(N_FLAG |    C_FLAG);
  1482. #ifdef WANT_TIM
  1483.     return(7L);
  1484. #endif
  1485. }
  1486.  
  1487. static long op_andn()             /*    AND n */
  1488. {
  1489.     A &= *PC++;
  1490.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1491.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1492.     F |= H_FLAG;
  1493.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1494.     F &= ~(N_FLAG |    C_FLAG);
  1495. #ifdef WANT_TIM
  1496.     return(7L);
  1497. #endif
  1498. }
  1499.  
  1500. static long op_ora()             /*    OR A */
  1501. {
  1502.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1503.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1504.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1505.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1506. #ifdef WANT_TIM
  1507.     return(4L);
  1508. #endif
  1509. }
  1510.  
  1511. static long op_orb()             /*    OR B */
  1512. {
  1513.     A |= B;
  1514.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1515.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1516.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1517.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1518. #ifdef WANT_TIM
  1519.     return(4L);
  1520. #endif
  1521. }
  1522.  
  1523. static long op_orc()             /*    OR C */
  1524. {
  1525.     A |= C;
  1526.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1527.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1528.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1529.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1530. #ifdef WANT_TIM
  1531.     return(4L);
  1532. #endif
  1533. }
  1534.  
  1535. static long op_ord()             /*    OR D */
  1536. {
  1537.     A |= D;
  1538.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1539.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1540.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1541.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1542. #ifdef WANT_TIM
  1543.     return(4L);
  1544. #endif
  1545. }
  1546.  
  1547. static long op_ore()             /*    OR E */
  1548. {
  1549.     A |= E;
  1550.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1551.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1552.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1553.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1554. #ifdef WANT_TIM
  1555.     return(4L);
  1556. #endif
  1557. }
  1558.  
  1559. static long op_orh()             /*    OR H */
  1560. {
  1561.     A |= H;
  1562.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1563.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1564.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1565.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1566. #ifdef WANT_TIM
  1567.     return(4L);
  1568. #endif
  1569. }
  1570.  
  1571. static long op_orl()             /*    OR L */
  1572. {
  1573.     A |= L;
  1574.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1575.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1576.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1577.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1578. #ifdef WANT_TIM
  1579.     return(4L);
  1580. #endif
  1581. }
  1582.  
  1583. static long op_orhl()             /*    OR (HL)    */
  1584. {
  1585.     A |= *(ram + (H    << 8) +    L);
  1586.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1587.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1588.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1589.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1590. #ifdef WANT_TIM
  1591.     return(7L);
  1592. #endif
  1593. }
  1594.  
  1595. static long op_orn()             /*    OR n */
  1596. {
  1597.     A |= *PC++;
  1598.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1599.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1600.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1601.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1602. #ifdef WANT_TIM
  1603.     return(7L);
  1604. #endif
  1605. }
  1606.  
  1607. static long op_xora()             /*    XOR A */
  1608. {
  1609.     A = 0;
  1610.     F &= ~(S_FLAG |    H_FLAG | N_FLAG    | C_FLAG);
  1611.     F |= Z_FLAG | P_FLAG;
  1612. #ifdef WANT_TIM
  1613.     return(4L);
  1614. #endif
  1615. }
  1616.  
  1617. static long op_xorb()             /*    XOR B */
  1618. {
  1619.     A ^= B;
  1620.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1621.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1622.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1623.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1624. #ifdef WANT_TIM
  1625.     return(4L);
  1626. #endif
  1627. }
  1628.  
  1629. static long op_xorc()             /*    XOR C */
  1630. {
  1631.     A ^= C;
  1632.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1633.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1634.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1635.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1636. #ifdef WANT_TIM
  1637.     return(4L);
  1638. #endif
  1639. }
  1640.  
  1641. static long op_xord()             /*    XOR D */
  1642. {
  1643.     A ^= D;
  1644.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1645.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1646.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1647.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1648. #ifdef WANT_TIM
  1649.     return(4L);
  1650. #endif
  1651. }
  1652.  
  1653. static long op_xore()             /*    XOR E */
  1654. {
  1655.     A ^= E;
  1656.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1657.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1658.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1659.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1660. #ifdef WANT_TIM
  1661.     return(4L);
  1662. #endif
  1663. }
  1664.  
  1665. static long op_xorh()             /*    XOR H */
  1666. {
  1667.     A ^= H;
  1668.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1669.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1670.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1671.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1672. #ifdef WANT_TIM
  1673.     return(4L);
  1674. #endif
  1675. }
  1676.  
  1677. static long op_xorl()             /*    XOR L */
  1678. {
  1679.     A ^= L;
  1680.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1681.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1682.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1683.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1684. #ifdef WANT_TIM
  1685.     return(4L);
  1686. #endif
  1687. }
  1688.  
  1689. static long op_xorhl()             /*    XOR (HL) */
  1690. {
  1691.     A ^= *(ram + (H    << 8) +    L);
  1692.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1693.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1694.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1695.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1696. #ifdef WANT_TIM
  1697.     return(7L);
  1698. #endif
  1699. }
  1700.  
  1701. static long op_xorn()             /*    XOR n */
  1702. {
  1703.     A ^= *PC++;
  1704.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1705.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1706.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1707.     F &= ~(H_FLAG |    N_FLAG | C_FLAG);
  1708. #ifdef WANT_TIM
  1709.     return(7L);
  1710. #endif
  1711. }
  1712.  
  1713. static long op_adda()             /*    ADD A,A    */
  1714. {
  1715.     register int i;
  1716.  
  1717.     ((A & 0xf) + (A    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1718.     ((A << 1) > 255) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  1719.     A = i =    ((char)    A) << 1;
  1720.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1721.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1722.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1723.     F &= ~N_FLAG;
  1724. #ifdef WANT_TIM
  1725.     return(4L);
  1726. #endif
  1727. }
  1728.  
  1729. static long op_addb()             /*    ADD A,B    */
  1730. {
  1731.     register int i;
  1732.  
  1733.     ((A & 0xf) + (B    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1734.     (A + B > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1735.     A = i =    (char) A + (char) B;
  1736.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1737.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1738.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1739.     F &= ~N_FLAG;
  1740. #ifdef WANT_TIM
  1741.     return(4L);
  1742. #endif
  1743. }
  1744.  
  1745. static long op_addc()             /*    ADD A,C    */
  1746. {
  1747.     register int i;
  1748.  
  1749.     ((A & 0xf) + (C    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1750.     (A + C > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1751.     A = i =    (char) A + (char) C;
  1752.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1753.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1754.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1755.     F &= ~N_FLAG;
  1756. #ifdef WANT_TIM
  1757.     return(4L);
  1758. #endif
  1759. }
  1760.  
  1761. static long op_addd()             /*    ADD A,D    */
  1762. {
  1763.     register int i;
  1764.  
  1765.     ((A & 0xf) + (D    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1766.     (A + D > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1767.     A = i =    (char) A + (char) D;
  1768.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1769.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1770.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1771.     F &= ~N_FLAG;
  1772. #ifdef WANT_TIM
  1773.     return(4L);
  1774. #endif
  1775. }
  1776.  
  1777. static long op_adde()             /*    ADD A,E    */
  1778. {
  1779.     register int i;
  1780.  
  1781.     ((A & 0xf) + (E    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1782.     (A + E > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1783.     A = i =    (char) A + (char) E;
  1784.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1785.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1786.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1787.     F &= ~N_FLAG;
  1788. #ifdef WANT_TIM
  1789.     return(4L);
  1790. #endif
  1791. }
  1792.  
  1793. static long op_addh()             /*    ADD A,H    */
  1794. {
  1795.     register int i;
  1796.  
  1797.     ((A & 0xf) + (H    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1798.     (A + H > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1799.     A = i =    (char) A + (char) H;
  1800.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1801.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1802.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1803.     F &= ~N_FLAG;
  1804. #ifdef WANT_TIM
  1805.     return(4L);
  1806. #endif
  1807. }
  1808.  
  1809. static long op_addl()             /*    ADD A,L    */
  1810. {
  1811.     register int i;
  1812.  
  1813.     ((A & 0xf) + (L    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1814.     (A + L > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1815.     A = i =    (char) A + (char) L;
  1816.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1817.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1818.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1819.     F &= ~N_FLAG;
  1820. #ifdef WANT_TIM
  1821.     return(4L);
  1822. #endif
  1823. }
  1824.  
  1825. static long op_addhl()             /*    ADD A,(HL) */
  1826. {
  1827.     register int i;
  1828.     register BYTE P;
  1829.  
  1830.     P = *(ram + (H << 8) + L);
  1831.     ((A & 0xf) + (P    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1832.     (A + P > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1833.     A = i =    (char) A + (char) P;
  1834.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1835.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1836.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1837.     F &= ~N_FLAG;
  1838. #ifdef WANT_TIM
  1839.     return(7L);
  1840. #endif
  1841. }
  1842.  
  1843. static long op_addn()             /*    ADD A,n    */
  1844. {
  1845.     register int i;
  1846.     register BYTE P;
  1847.  
  1848.     P = *PC++;
  1849.     ((A & 0xf) + (P    & 0xf) > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1850.     (A + P > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1851.     A = i =    (char) A + (char) P;
  1852.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1853.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1854.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1855.     F &= ~N_FLAG;
  1856. #ifdef WANT_TIM
  1857.     return(7L);
  1858. #endif
  1859. }
  1860.  
  1861. static long op_adca()             /*    ADC A,A    */
  1862. {
  1863.     register int i,    carry;
  1864.  
  1865.     carry =    (F & C_FLAG) ? 1 : 0;
  1866.     ((A & 0xf) + (A    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1867.     ((A << 1) + carry > 255) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  1868.     A = i =    (((char) A) << 1) + carry;
  1869.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1870.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1871.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1872.     F &= ~N_FLAG;
  1873. #ifdef WANT_TIM
  1874.     return(4L);
  1875. #endif
  1876. }
  1877.  
  1878. static long op_adcb()             /*    ADC A,B    */
  1879. {
  1880.     register int i,    carry;
  1881.  
  1882.     carry =    (F & C_FLAG) ? 1 : 0;
  1883.     ((A & 0xf) + (B    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1884.     (A + B + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1885.     A = i =    (char) A + (char) B + carry;
  1886.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1887.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1888.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1889.     F &= ~N_FLAG;
  1890. #ifdef WANT_TIM
  1891.     return(4L);
  1892. #endif
  1893. }
  1894.  
  1895. static long op_adcc()             /*    ADC A,C    */
  1896. {
  1897.     register int i,    carry;
  1898.  
  1899.     carry =    (F & C_FLAG) ? 1 : 0;
  1900.     ((A & 0xf) + (C    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1901.     (A + C + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1902.     A = i =    (char) A + (char) C + carry;
  1903.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1904.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1905.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1906.     F &= ~N_FLAG;
  1907. #ifdef WANT_TIM
  1908.     return(4L);
  1909. #endif
  1910. }
  1911.  
  1912. static long op_adcd()             /*    ADC A,D    */
  1913. {
  1914.     register int i,    carry;
  1915.  
  1916.     carry =    (F & C_FLAG) ? 1 : 0;
  1917.     ((A & 0xf) + (D    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1918.     (A + D + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1919.     A = i =    (char) A + (char) D + carry;
  1920.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1921.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1922.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1923.     F &= ~N_FLAG;
  1924. #ifdef WANT_TIM
  1925.     return(4L);
  1926. #endif
  1927. }
  1928.  
  1929. static long op_adce()             /*    ADC A,E    */
  1930. {
  1931.     register int i,    carry;
  1932.  
  1933.     carry =    (F & C_FLAG) ? 1 : 0;
  1934.     ((A & 0xf) + (E    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1935.     (A + E + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1936.     A = i =    (char) A + (char) E + carry;
  1937.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1938.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1939.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1940.     F &= ~N_FLAG;
  1941. #ifdef WANT_TIM
  1942.     return(4L);
  1943. #endif
  1944. }
  1945.  
  1946. static long op_adch()             /*    ADC A,H    */
  1947. {
  1948.     register int i,    carry;
  1949.  
  1950.     carry =    (F & C_FLAG) ? 1 : 0;
  1951.     ((A & 0xf) + (H    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1952.     (A + H + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1953.     A = i =    (char) A + (char) H + carry;
  1954.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1955.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1956.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1957.     F &= ~N_FLAG;
  1958. #ifdef WANT_TIM
  1959.     return(4L);
  1960. #endif
  1961. }
  1962.  
  1963. static long op_adcl()             /*    ADC A,L    */
  1964. {
  1965.     register int i,    carry;
  1966.  
  1967.     carry =    (F & C_FLAG) ? 1 : 0;
  1968.     ((A & 0xf) + (L    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1969.     (A + L + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1970.     A = i =    (char) A + (char) L + carry;
  1971.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1972.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1973.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1974.     F &= ~N_FLAG;
  1975. #ifdef WANT_TIM
  1976.     return(4L);
  1977. #endif
  1978. }
  1979.  
  1980. static long op_adchl()             /*    ADC A,(HL) */
  1981. {
  1982.     register int i,    carry;
  1983.     register BYTE P;
  1984.  
  1985.     P = *(ram + (H << 8) + L);
  1986.     carry =    (F & C_FLAG) ? 1 : 0;
  1987.     ((A & 0xf) + (P    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  1988.     (A + P + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  1989.     A = i =    (char) A + (char) P + carry;
  1990.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  1991.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1992.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1993.     F &= ~N_FLAG;
  1994. #ifdef WANT_TIM
  1995.     return(7L);
  1996. #endif
  1997. }
  1998.  
  1999. static long op_adcn()             /*    ADC A,n    */
  2000. {
  2001.     register int i,    carry;
  2002.     register BYTE P;
  2003.  
  2004.     carry =    (F & C_FLAG) ? 1 : 0;
  2005.     P = *PC++;
  2006.     ((A & 0xf) + (P    & 0xf) + carry > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2007.     (A + P + carry > 255) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  2008.     A = i =    (char) A + (char) P + carry;
  2009.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2010.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2011.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2012.     F &= ~N_FLAG;
  2013. #ifdef WANT_TIM
  2014.     return(7L);
  2015. #endif
  2016. }
  2017.  
  2018. static long op_suba()             /*    SUB A,A    */
  2019. {
  2020.     A = 0;
  2021.     F &= ~(S_FLAG |    H_FLAG | P_FLAG    | C_FLAG);
  2022.     F |= Z_FLAG | N_FLAG;
  2023. #ifdef WANT_TIM
  2024.     return(4L);
  2025. #endif
  2026. }
  2027.  
  2028. static long op_subb()             /*    SUB A,B    */
  2029. {
  2030.     register int i;
  2031.  
  2032.     ((B & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2033.     (B > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2034.     A = i =    (char) A - (char) B;
  2035.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2036.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2037.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2038.     F |= N_FLAG;
  2039. #ifdef WANT_TIM
  2040.     return(4L);
  2041. #endif
  2042. }
  2043.  
  2044. static long op_subc()             /*    SUB A,C    */
  2045. {
  2046.     register int i;
  2047.  
  2048.     ((C & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2049.     (C > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2050.     A = i =    (char) A - (char) C;
  2051.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2052.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2053.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2054.     F |= N_FLAG;
  2055. #ifdef WANT_TIM
  2056.     return(4L);
  2057. #endif
  2058. }
  2059.  
  2060. static long op_subd()             /*    SUB A,D    */
  2061. {
  2062.     register int i;
  2063.  
  2064.     ((D & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2065.     (D > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2066.     A = i =    (char) A - (char) D;
  2067.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2068.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2069.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2070.     F |= N_FLAG;
  2071. #ifdef WANT_TIM
  2072.     return(4L);
  2073. #endif
  2074. }
  2075.  
  2076. static long op_sube()             /*    SUB A,E    */
  2077. {
  2078.     register int i;
  2079.  
  2080.     ((E & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2081.     (E > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2082.     A = i =    (char) A - (char) E;
  2083.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2084.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2085.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2086.     F |= N_FLAG;
  2087. #ifdef WANT_TIM
  2088.     return(4L);
  2089. #endif
  2090. }
  2091.  
  2092. static long op_subh()             /*    SUB A,H    */
  2093. {
  2094.     register int i;
  2095.  
  2096.     ((H & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2097.     (H > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2098.     A = i =    (char) A - (char) H;
  2099.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2100.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2101.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2102.     F |= N_FLAG;
  2103. #ifdef WANT_TIM
  2104.     return(4L);
  2105. #endif
  2106. }
  2107.  
  2108. static long op_subl()             /*    SUB A,L    */
  2109. {
  2110.     register int i;
  2111.  
  2112.     ((L & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2113.     (L > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2114.     A = i =    (char) A - (char) L;
  2115.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2116.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2117.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2118.     F |= N_FLAG;
  2119. #ifdef WANT_TIM
  2120.     return(4L);
  2121. #endif
  2122. }
  2123.  
  2124. static long op_subhl()             /*    SUB A,(HL) */
  2125. {
  2126.     register int i;
  2127.     register BYTE P;
  2128.  
  2129.     P = *(ram + (H << 8) + L);
  2130.     ((P & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2131.     (P > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2132.     A = i =    (char) A - (char) P;
  2133.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2134.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2135.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2136.     F |= N_FLAG;
  2137. #ifdef WANT_TIM
  2138.     return(7L);
  2139. #endif
  2140. }
  2141.  
  2142. static long op_subn()             /*    SUB A,n    */
  2143. {
  2144.     register int i;
  2145.     register BYTE P;
  2146.  
  2147.     P = *PC++;
  2148.     ((P & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2149.     (P > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2150.     A = i =    (char) A - (char) P;
  2151.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2152.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2153.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2154.     F |= N_FLAG;
  2155. #ifdef WANT_TIM
  2156.     return(7L);
  2157. #endif
  2158. }
  2159.  
  2160. static long op_sbca()             /*    SBC A,A    */
  2161. {
  2162.     if (F &    C_FLAG)    {
  2163.         F |= S_FLAG | H_FLAG | N_FLAG |    C_FLAG;
  2164.         F &= ~(Z_FLAG |    P_FLAG);
  2165.         A = 255;
  2166.     } else {
  2167.         F |= Z_FLAG | N_FLAG;
  2168.         F &= ~(S_FLAG |    H_FLAG | P_FLAG    | C_FLAG);
  2169.         A = 0;
  2170.     }
  2171. #ifdef WANT_TIM
  2172.     return(4L);
  2173. #endif
  2174. }
  2175.  
  2176. static long op_sbcb()             /*    SBC A,B    */
  2177. {
  2178.     register int i,    carry;
  2179.  
  2180.     carry =    (F & C_FLAG) ? 1 : 0;
  2181.     ((B & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2182.     (B + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2183.     A = i =    (char) A - (char) B - carry;
  2184.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2185.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2186.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2187.     F |= N_FLAG;
  2188. #ifdef WANT_TIM
  2189.     return(4L);
  2190. #endif
  2191. }
  2192.  
  2193. static long op_sbcc()             /*    SBC A,C    */
  2194. {
  2195.     register int i,    carry;
  2196.  
  2197.     carry =    (F & C_FLAG) ? 1 : 0;
  2198.     ((C & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2199.     (C + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2200.     A = i =    (char) A - (char) C - carry;
  2201.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2202.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2203.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2204.     F |= N_FLAG;
  2205. #ifdef WANT_TIM
  2206.     return(4L);
  2207. #endif
  2208. }
  2209.  
  2210. static long op_sbcd()             /*    SBC A,D    */
  2211. {
  2212.     register int i,    carry;
  2213.  
  2214.     carry =    (F & C_FLAG) ? 1 : 0;
  2215.     ((D & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2216.     (D + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2217.     A = i =    (char) A - (char) D - carry;
  2218.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2219.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2220.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2221.     F |= N_FLAG;
  2222. #ifdef WANT_TIM
  2223.     return(4L);
  2224. #endif
  2225. }
  2226.  
  2227. static long op_sbce()             /*    SBC A,E    */
  2228. {
  2229.     register int i,    carry;
  2230.  
  2231.     carry =    (F & C_FLAG) ? 1 : 0;
  2232.     ((E & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2233.     (E + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2234.     A = i =    (char) A - (char) E - carry;
  2235.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2236.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2237.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2238.     F |= N_FLAG;
  2239. #ifdef WANT_TIM
  2240.     return(4L);
  2241. #endif
  2242. }
  2243.  
  2244. static long op_sbch()             /*    SBC A,H    */
  2245. {
  2246.     register int i,    carry;
  2247.  
  2248.     carry =    (F & C_FLAG) ? 1 : 0;
  2249.     ((H & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2250.     (H + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2251.     A = i =    (char) A - (char) H - carry;
  2252.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2253.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2254.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2255.     F |= N_FLAG;
  2256. #ifdef WANT_TIM
  2257.     return(4L);
  2258. #endif
  2259. }
  2260.  
  2261. static long op_sbcl()             /*    SBC A,L    */
  2262. {
  2263.     register int i,    carry;
  2264.  
  2265.     carry =    (F & C_FLAG) ? 1 : 0;
  2266.     ((L & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2267.     (L + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2268.     A = i =    (char) A - (char) L - carry;
  2269.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2270.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2271.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2272.     F |= N_FLAG;
  2273. #ifdef WANT_TIM
  2274.     return(4L);
  2275. #endif
  2276. }
  2277.  
  2278. static long op_sbchl()             /*    SBC A,(HL) */
  2279. {
  2280.     register int i,    carry;
  2281.     register BYTE P;
  2282.  
  2283.     P = *(ram + (H << 8) + L);
  2284.     carry =    (F & C_FLAG) ? 1 : 0;
  2285.     ((P & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2286.     (P + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2287.     A = i =    (char) A - (char) P - carry;
  2288.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2289.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2290.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2291.     F |= N_FLAG;
  2292. #ifdef WANT_TIM
  2293.     return(7L);
  2294. #endif
  2295. }
  2296.  
  2297. static long op_sbcn()             /*    SBC A,n    */
  2298. {
  2299.     register int i,    carry;
  2300.     register BYTE P;
  2301.  
  2302.     P = *PC++;
  2303.     carry =    (F & C_FLAG) ? 1 : 0;
  2304.     ((P & 0xf) + carry > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2305.     (P + carry > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2306.     A = i =    (char) A - (char) P - carry;
  2307.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2308.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2309.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2310.     F |= N_FLAG;
  2311. #ifdef WANT_TIM
  2312.     return(7L);
  2313. #endif
  2314. }
  2315.  
  2316. static long op_cpa()             /*    CP A */
  2317. {
  2318.     F &= ~(S_FLAG |    H_FLAG | P_FLAG    | C_FLAG);
  2319.     F |= Z_FLAG | N_FLAG;
  2320. #ifdef WANT_TIM
  2321.     return(4L);
  2322. #endif
  2323. }
  2324.  
  2325. static long op_cpb()             /*    CP B */
  2326. {
  2327.     register int i;
  2328.  
  2329.     ((B & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2330.     (B > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2331.     i = (char) A - (char) B;
  2332.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2333.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2334.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2335.     F |= N_FLAG;
  2336. #ifdef WANT_TIM
  2337.     return(4L);
  2338. #endif
  2339. }
  2340.  
  2341. static long op_cpc()             /*    CP C */
  2342. {
  2343.     register int i;
  2344.  
  2345.     ((C & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2346.     (C > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2347.     i = (char) A - (char) C;
  2348.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2349.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2350.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2351.     F |= N_FLAG;
  2352. #ifdef WANT_TIM
  2353.     return(4L);
  2354. #endif
  2355. }
  2356.  
  2357. static long op_cpd()             /*    CP D */
  2358. {
  2359.     register int i;
  2360.  
  2361.     ((D & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2362.     (D > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2363.     i = (char) A - (char) D;
  2364.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2365.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2366.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2367.     F |= N_FLAG;
  2368. #ifdef WANT_TIM
  2369.     return(4L);
  2370. #endif
  2371. }
  2372.  
  2373. static long op_cpe()             /*    CP E */
  2374. {
  2375.     register int i;
  2376.  
  2377.     ((E & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2378.     (E > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2379.     i = (char) A - (char) E;
  2380.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2381.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2382.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2383.     F |= N_FLAG;
  2384. #ifdef WANT_TIM
  2385.     return(4L);
  2386. #endif
  2387. }
  2388.  
  2389. static long op_cph()             /*    CP H */
  2390. {
  2391.     register int i;
  2392.  
  2393.     ((H & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2394.     (H > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2395.     i = (char) A - (char) H;
  2396.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2397.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2398.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2399.     F |= N_FLAG;
  2400. #ifdef WANT_TIM
  2401.     return(4L);
  2402. #endif
  2403. }
  2404.  
  2405. static long op_cplr()             /*    CP L */
  2406. {
  2407.     register int i;
  2408.  
  2409.     ((L & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2410.     (L > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2411.     i = (char) A - (char) L;
  2412.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2413.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2414.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2415.     F |= N_FLAG;
  2416. #ifdef WANT_TIM
  2417.     return(4L);
  2418. #endif
  2419. }
  2420.  
  2421. static long op_cphl()             /*    CP (HL)    */
  2422. {
  2423.     register int i;
  2424.     register BYTE P;
  2425.  
  2426.     P = *(ram + (H << 8) + L);
  2427.     ((P & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2428.     (P > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2429.     i = (char) A - (char) P;
  2430.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2431.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2432.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2433.     F |= N_FLAG;
  2434. #ifdef WANT_TIM
  2435.     return(7L);
  2436. #endif
  2437. }
  2438.  
  2439. static long op_cpn()             /*    CP n */
  2440. {
  2441.     register int i;
  2442.     register BYTE P;
  2443.  
  2444.     P = *PC++;
  2445.     ((P & 0xf) > (A    & 0xf))    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2446.     (P > A)    ? (F |=    C_FLAG)    : (F &=    ~C_FLAG);
  2447.     i = (char) A - (char) P;
  2448.     (i < -128 || i > 127) ?    (F |= P_FLAG) :    (F &= ~P_FLAG);
  2449.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2450.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2451.     F |= N_FLAG;
  2452. #ifdef WANT_TIM
  2453.     return(7L);
  2454. #endif
  2455. }
  2456.  
  2457. static long op_inca()             /*    INC A */
  2458. {
  2459.     ((A & 0xf) + 1 > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2460.     A++;
  2461.     (A == 128) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2462.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2463.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2464.     F &= ~N_FLAG;
  2465. #ifdef WANT_TIM
  2466.     return(4L);
  2467. #endif
  2468. }
  2469.  
  2470. static long op_incb()             /*    INC B */
  2471. {
  2472.     ((B & 0xf) + 1 > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2473.     B++;
  2474.     (B == 128) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2475.     (B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2476.     (B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2477.     F &= ~N_FLAG;
  2478. #ifdef WANT_TIM
  2479.     return(4L);
  2480. #endif
  2481. }
  2482.  
  2483. static long op_incc()             /*    INC C */
  2484. {
  2485.     ((C & 0xf) + 1 > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2486.     C++;
  2487.     (C == 128) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2488.     (C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2489.     (C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2490.     F &= ~N_FLAG;
  2491. #ifdef WANT_TIM
  2492.     return(4L);
  2493. #endif
  2494. }
  2495.  
  2496. static long op_incd()             /*    INC D */
  2497. {
  2498.     ((D & 0xf) + 1 > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2499.     D++;
  2500.     (D == 128) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2501.     (D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2502.     (D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2503.     F &= ~N_FLAG;
  2504. #ifdef WANT_TIM
  2505.     return(4L);
  2506. #endif
  2507. }
  2508.  
  2509. static long op_ince()             /*    INC E */
  2510. {
  2511.     ((E & 0xf) + 1 > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2512.     E++;
  2513.     (E == 128) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2514.     (E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2515.     (E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2516.     F &= ~N_FLAG;
  2517. #ifdef WANT_TIM
  2518.     return(4L);
  2519. #endif
  2520. }
  2521.  
  2522. static long op_inch()             /*    INC H */
  2523. {
  2524.     ((H & 0xf) + 1 > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2525.     H++;
  2526.     (H == 128) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2527.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2528.     (H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2529.     F &= ~N_FLAG;
  2530. #ifdef WANT_TIM
  2531.     return(4L);
  2532. #endif
  2533. }
  2534.  
  2535. static long op_incl()             /*    INC L */
  2536. {
  2537.     ((L & 0xf) + 1 > 0xf) ?    (F |= H_FLAG) :    (F &= ~H_FLAG);
  2538.     L++;
  2539.     (L == 128) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2540.     (L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2541.     (L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2542.     F &= ~N_FLAG;
  2543. #ifdef WANT_TIM
  2544.     return(4L);
  2545. #endif
  2546. }
  2547.  
  2548. static long op_incihl()             /*    INC (HL) */
  2549. {
  2550.     register BYTE *p;
  2551.  
  2552.     p = ram    + (H <<    8) + L;
  2553.     ((*p & 0xf) + 1    > 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2554.     (*p)++;
  2555.     (*p == 128) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  2556.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  2557.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  2558.     F &= ~N_FLAG;
  2559. #ifdef WANT_TIM
  2560.     return(11L);
  2561. #endif
  2562. }
  2563.  
  2564. static long op_deca()             /*    DEC A */
  2565. {
  2566.     ((A - 1    & 0xf) == 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2567.     A--;
  2568.     (A == 127) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2569.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2570.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2571.     F |= N_FLAG;
  2572. #ifdef WANT_TIM
  2573.     return(4L);
  2574. #endif
  2575. }
  2576.  
  2577. static long op_decb()             /*    DEC B */
  2578. {
  2579.     ((B - 1    & 0xf) == 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2580.     B--;
  2581.     (B == 127) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2582.     (B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2583.     (B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2584.     F |= N_FLAG;
  2585. #ifdef WANT_TIM
  2586.     return(4L);
  2587. #endif
  2588. }
  2589.  
  2590. static long op_decc()             /*    DEC C */
  2591. {
  2592.     ((C - 1    & 0xf) == 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2593.     C--;
  2594.     (C == 127) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2595.     (C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2596.     (C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2597.     F |= N_FLAG;
  2598. #ifdef WANT_TIM
  2599.     return(4L);
  2600. #endif
  2601. }
  2602.  
  2603. static long op_decd()             /*    DEC D */
  2604. {
  2605.     ((D - 1    & 0xf) == 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2606.     D--;
  2607.     (D == 127) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2608.     (D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2609.     (D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2610.     F |= N_FLAG;
  2611. #ifdef WANT_TIM
  2612.     return(4L);
  2613. #endif
  2614. }
  2615.  
  2616. static long op_dece()             /*    DEC E */
  2617. {
  2618.     ((E - 1    & 0xf) == 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2619.     E--;
  2620.     (E == 127) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2621.     (E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2622.     (E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2623.     F |= N_FLAG;
  2624. #ifdef WANT_TIM
  2625.     return(4L);
  2626. #endif
  2627. }
  2628.  
  2629. static long op_dech()             /*    DEC H */
  2630. {
  2631.     ((H - 1    & 0xf) == 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2632.     H--;
  2633.     (H == 127) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2634.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2635.     (H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2636.     F |= N_FLAG;
  2637. #ifdef WANT_TIM
  2638.     return(4L);
  2639. #endif
  2640. }
  2641.  
  2642. static long op_decl()             /*    DEC L */
  2643. {
  2644.     ((L - 1    & 0xf) == 0xf) ? (F |= H_FLAG) : (F &= ~H_FLAG);
  2645.     L--;
  2646.     (L == 127) ? (F    |= P_FLAG) : (F    &= ~P_FLAG);
  2647.     (L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  2648.     (L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  2649.     F |= N_FLAG;
  2650. #ifdef WANT_TIM
  2651.     return(4L);
  2652. #endif
  2653. }
  2654.  
  2655. static long op_decihl()             /*    DEC (HL) */
  2656. {
  2657.     register BYTE *p;
  2658.  
  2659.     p = ram    + (H <<    8) + L;
  2660.     ((*p - 1 & 0xf)    == 0xf)    ? (F |=    H_FLAG)    : (F &=    ~H_FLAG);
  2661.     (*p)--;
  2662.     (*p == 127) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  2663.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  2664.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  2665.     F |= N_FLAG;
  2666. #ifdef WANT_TIM
  2667.     return(11L);
  2668. #endif
  2669. }
  2670.  
  2671. static long op_rlca()             /*    RLCA */
  2672. {
  2673.     register int i;
  2674.  
  2675.     i = (A & 128) ?    1 : 0;
  2676.     (i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  2677.     F &= ~(H_FLAG |    N_FLAG);
  2678.     A <<= 1;
  2679.     A |= i;
  2680. #ifdef WANT_TIM
  2681.     return(4L);
  2682. #endif
  2683. }
  2684.  
  2685. static long op_rrca()             /*    RRCA */
  2686. {
  2687.     register int i;
  2688.  
  2689.     i = A &    1;
  2690.     (i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  2691.     F &= ~(H_FLAG |    N_FLAG);
  2692.     A >>= 1;
  2693.     if (i) A |= 128;
  2694. #ifdef WANT_TIM
  2695.     return(4L);
  2696. #endif
  2697. }
  2698.  
  2699. static long op_rla()             /*    RLA */
  2700. {
  2701.     register int old_c_flag;
  2702.  
  2703.     old_c_flag = F & C_FLAG;
  2704.     (A & 128) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  2705.     F &= ~(H_FLAG |    N_FLAG);
  2706.     A <<= 1;
  2707.     if (old_c_flag)    A |= 1;
  2708. #ifdef WANT_TIM
  2709.     return(4L);
  2710. #endif
  2711. }
  2712.  
  2713. static long op_rra()             /*    RRA */
  2714. {
  2715.     register int i,    old_c_flag;
  2716.  
  2717.     old_c_flag = F & C_FLAG;
  2718.     i = A &    1;
  2719.     (i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  2720.     F &= ~(H_FLAG |    N_FLAG);
  2721.     A >>= 1;
  2722.     if (old_c_flag)    A |= 128;
  2723. #ifdef WANT_TIM
  2724.     return(4L);
  2725. #endif
  2726. }
  2727.  
  2728. static long op_exdehl()             /*    EX DE,HL */
  2729. {
  2730.     register unsigned i;
  2731.  
  2732.     i = D;
  2733.     D = H;
  2734.     H = i;
  2735.     i = E;
  2736.     E = L;
  2737.     L = i;
  2738. #ifdef WANT_TIM
  2739.     return(4L);
  2740. #endif
  2741. }
  2742.  
  2743. static long op_exafaf()             /*    EX AF,AF' */
  2744. {
  2745.     register unsigned i;
  2746.  
  2747.     i = A;
  2748.     A = A_;
  2749.     A_ = i;
  2750.     i = F;
  2751.     F = F_;
  2752.     F_ = i;
  2753. #ifdef WANT_TIM
  2754.     return(4L);
  2755. #endif
  2756. }
  2757.  
  2758. static long op_exx()             /*    EXX */
  2759. {
  2760.     register unsigned i;
  2761.  
  2762.     i = B;
  2763.     B = B_;
  2764.     B_ = i;
  2765.     i = C;
  2766.     C = C_;
  2767.     C_ = i;
  2768.     i = D;
  2769.     D = D_;
  2770.     D_ = i;
  2771.     i = E;
  2772.     E = E_;
  2773.     E_ = i;
  2774.     i = H;
  2775.     H = H_;
  2776.     H_ = i;
  2777.     i = L;
  2778.     L = L_;
  2779.     L_ = i;
  2780. #ifdef WANT_TIM
  2781.     return(4L);
  2782. #endif
  2783. }
  2784.  
  2785. static long op_exsphl()             /*    EX (SP),HL */
  2786. {
  2787.     register int i;
  2788.  
  2789.     i = *STACK;
  2790.     *STACK = L;
  2791.     L = i;
  2792.     i = *(STACK + 1);
  2793.     *(STACK    + 1) = H;
  2794.     H = i;
  2795. #ifdef WANT_TIM
  2796.     return(19L);
  2797. #endif
  2798. }
  2799.  
  2800. static long op_pushaf()             /*    PUSH AF    */
  2801. {
  2802. #ifdef WANT_SPC
  2803.     if (STACK <= ram)
  2804.         STACK =    ram + 65536L;
  2805. #endif
  2806.     *--STACK = A;
  2807. #ifdef WANT_SPC
  2808.     if (STACK <= ram)
  2809.         STACK =    ram + 65536L;
  2810. #endif
  2811.     *--STACK = F;
  2812. #ifdef WANT_TIM
  2813.     return(11L);
  2814. #endif
  2815. }
  2816.  
  2817. static long op_pushbc()             /*    PUSH BC    */
  2818. {
  2819. #ifdef WANT_SPC
  2820.     if (STACK <= ram)
  2821.         STACK =    ram + 65536L;
  2822. #endif
  2823.     *--STACK = B;
  2824. #ifdef WANT_SPC
  2825.     if (STACK <= ram)
  2826.         STACK =    ram + 65536L;
  2827. #endif
  2828.     *--STACK = C;
  2829. #ifdef WANT_TIM
  2830.     return(11L);
  2831. #endif
  2832. }
  2833.  
  2834. static long op_pushde()             /*    PUSH DE    */
  2835. {
  2836. #ifdef WANT_SPC
  2837.     if (STACK <= ram)
  2838.         STACK =    ram + 65536L;
  2839. #endif
  2840.     *--STACK = D;
  2841. #ifdef WANT_SPC
  2842.     if (STACK <= ram)
  2843.         STACK =    ram + 65536L;
  2844. #endif
  2845.     *--STACK = E;
  2846. #ifdef WANT_TIM
  2847.     return(11L);
  2848. #endif
  2849. }
  2850.  
  2851. static long op_pushhl()             /*    PUSH HL    */
  2852. {
  2853. #ifdef WANT_SPC
  2854.     if (STACK <= ram)
  2855.         STACK =    ram + 65536L;
  2856. #endif
  2857.     *--STACK = H;
  2858. #ifdef WANT_SPC
  2859.     if (STACK <= ram)
  2860.         STACK =    ram + 65536L;
  2861. #endif
  2862.     *--STACK = L;
  2863. #ifdef WANT_TIM
  2864.     return(11L);
  2865. #endif
  2866. }
  2867.  
  2868. static long op_popaf()             /*    POP AF */
  2869. {
  2870.     F = *STACK++;
  2871. #ifdef WANT_SPC
  2872.     if (STACK >= ram + 65536L)
  2873.         STACK =    ram;
  2874. #endif
  2875.     A = *STACK++;
  2876. #ifdef WANT_SPC
  2877.     if (STACK >= ram + 65536L)
  2878.         STACK =    ram;
  2879. #endif
  2880. #ifdef WANT_TIM
  2881.     return(10L);
  2882. #endif
  2883. }
  2884.  
  2885. static long op_popbc()             /*    POP BC */
  2886. {
  2887.     C = *STACK++;
  2888. #ifdef WANT_SPC
  2889.     if (STACK >= ram + 65536L)
  2890.         STACK =    ram;
  2891. #endif
  2892.     B = *STACK++;
  2893. #ifdef WANT_SPC
  2894.     if (STACK >= ram + 65536L)
  2895.         STACK =    ram;
  2896. #endif
  2897. #ifdef WANT_TIM
  2898.     return(10L);
  2899. #endif
  2900. }
  2901.  
  2902. static long op_popde()             /*    POP DE */
  2903. {
  2904.     E = *STACK++;
  2905. #ifdef WANT_SPC
  2906.     if (STACK >= ram + 65536L)
  2907.         STACK =    ram;
  2908. #endif
  2909.     D = *STACK++;
  2910. #ifdef WANT_SPC
  2911.     if (STACK >= ram + 65536L)
  2912.         STACK =    ram;
  2913. #endif
  2914. #ifdef WANT_TIM
  2915.     return(10L);
  2916. #endif
  2917. }
  2918.  
  2919. static long op_pophl()             /*    POP HL */
  2920. {
  2921.     L = *STACK++;
  2922. #ifdef WANT_SPC
  2923.     if (STACK >= ram + 65536L)
  2924.         STACK =    ram;
  2925. #endif
  2926.     H = *STACK++;
  2927. #ifdef WANT_SPC
  2928.     if (STACK >= ram + 65536L)
  2929.         STACK =    ram;
  2930. #endif
  2931. #ifdef WANT_TIM
  2932.     return(10L);
  2933. #endif
  2934. }
  2935.  
  2936. static long op_jp()             /*    JP */
  2937. {
  2938.     register unsigned i;
  2939.  
  2940.     i = *PC++;
  2941.     i += *PC << 8;
  2942.     PC = ram + i;
  2943. #ifdef WANT_TIM
  2944.     return(10L);
  2945. #endif
  2946. }
  2947.  
  2948. static long op_jphl()             /*    JP (HL)    */
  2949. {
  2950.     PC = ram + (H << 8) + L;
  2951. #ifdef WANT_TIM
  2952.     return(4L);
  2953. #endif
  2954. }
  2955.  
  2956. static long op_jr()             /*    JR */
  2957. {
  2958.     PC += (char) *PC + 1;
  2959. #ifdef WANT_TIM
  2960.     return(12L);
  2961. #endif
  2962. }
  2963.  
  2964. static long op_djnz()             /*    DJNZ */
  2965. {
  2966.     if (--B) {
  2967.         PC += (char) *PC + 1;
  2968. #ifdef WANT_TIM
  2969.         return(13L);
  2970. #endif
  2971.     } else {
  2972.         PC++;
  2973. #ifdef WANT_TIM
  2974.         return(8L);
  2975. #endif
  2976.     }
  2977. }
  2978.  
  2979. static long op_call()             /*    CALL */
  2980. {
  2981.     register unsigned i;
  2982.  
  2983.     i = *PC++;
  2984.     i += *PC++ << 8;
  2985. #ifdef WANT_SPC
  2986.     if (STACK <= ram)
  2987.         STACK =    ram + 65536L;
  2988. #endif
  2989.     *--STACK = (PC - ram) >> 8;
  2990. #ifdef WANT_SPC
  2991.     if (STACK <= ram)
  2992.         STACK =    ram + 65536L;
  2993. #endif
  2994.     *--STACK = (PC - ram);
  2995.     PC = ram + i;
  2996. #ifdef WANT_TIM
  2997.     return(17L);
  2998. #endif
  2999. }
  3000.  
  3001. static long op_ret()             /*    RET */
  3002. {
  3003.     register unsigned i;
  3004.  
  3005.     i = *STACK++;
  3006. #ifdef WANT_SPC
  3007.     if (STACK >= ram + 65536L)
  3008.         STACK =    ram;
  3009. #endif
  3010.     i += *STACK++ << 8;
  3011. #ifdef WANT_SPC
  3012.     if (STACK >= ram + 65536L)
  3013.         STACK =    ram;
  3014. #endif
  3015.     PC = ram + i;
  3016. #ifdef WANT_TIM
  3017.     return(10L);
  3018. #endif
  3019. }
  3020.  
  3021. static long op_jpz()             /*    JP Z,nn    */
  3022. {
  3023.     register unsigned i;
  3024.  
  3025.     if (F &    Z_FLAG)    {
  3026.         i = *PC++;
  3027.         i += *PC++ << 8;
  3028.         PC = ram + i;
  3029.     } else
  3030.         PC += 2;
  3031. #ifdef WANT_TIM
  3032.     return(10L);
  3033. #endif
  3034. }
  3035.  
  3036. static long op_jpnz()             /*    JP NZ,nn */
  3037. {
  3038.     register unsigned i;
  3039.  
  3040.     if (!(F    & Z_FLAG)) {
  3041.         i = *PC++;
  3042.         i += *PC++ << 8;
  3043.         PC = ram + i;
  3044.     } else
  3045.         PC += 2;
  3046. #ifdef WANT_TIM
  3047.     return(10L);
  3048. #endif
  3049. }
  3050.  
  3051. static long op_jpc()             /*    JP C,nn    */
  3052. {
  3053.     register unsigned i;
  3054.  
  3055.     if (F &    C_FLAG)    {
  3056.         i = *PC++;
  3057.         i += *PC++ << 8;
  3058.         PC = ram + i;
  3059.     } else
  3060.         PC += 2;
  3061. #ifdef WANT_TIM
  3062.     return(10L);
  3063. #endif
  3064. }
  3065.  
  3066. static long op_jpnc()             /*    JP NC,nn */
  3067. {
  3068.     register unsigned i;
  3069.  
  3070.     if (!(F    & C_FLAG)) {
  3071.         i = *PC++;
  3072.         i += *PC++ << 8;
  3073.         PC = ram + i;
  3074.     } else
  3075.         PC += 2;
  3076. #ifdef WANT_TIM
  3077.     return(10L);
  3078. #endif
  3079. }
  3080.  
  3081. static long op_jppe()             /*    JP PE,nn */
  3082. {
  3083.     register unsigned i;
  3084.  
  3085.     if (F &    P_FLAG)    {
  3086.         i = *PC++;
  3087.         i += *PC++ << 8;
  3088.         PC = ram + i;
  3089.     } else
  3090.         PC += 2;
  3091. #ifdef WANT_TIM
  3092.     return(10L);
  3093. #endif
  3094. }
  3095.  
  3096. static long op_jppo()             /*    JP PO,nn */
  3097. {
  3098.     register unsigned i;
  3099.  
  3100.     if (!(F    & P_FLAG)) {
  3101.         i = *PC++;
  3102.         i += *PC++ << 8;
  3103.         PC = ram + i;
  3104.     } else
  3105.         PC += 2;
  3106. #ifdef WANT_TIM
  3107.     return(10L);
  3108. #endif
  3109. }
  3110.  
  3111. static long op_jpm()             /*    JP M,nn    */
  3112. {
  3113.     register unsigned i;
  3114.  
  3115.     if (F &    S_FLAG)    {
  3116.         i = *PC++;
  3117.         i += *PC++ << 8;
  3118.         PC = ram + i;
  3119.     } else
  3120.         PC += 2;
  3121. #ifdef WANT_TIM
  3122.     return(10L);
  3123. #endif
  3124. }
  3125.  
  3126. static long op_jpp()             /*    JP P,nn    */
  3127. {
  3128.     register unsigned i;
  3129.  
  3130.     if (!(F    & S_FLAG)) {
  3131.         i = *PC++;
  3132.         i += *PC++ << 8;
  3133.         PC = ram + i;
  3134.     } else
  3135.         PC += 2;
  3136. #ifdef WANT_TIM
  3137.     return(10L);
  3138. #endif
  3139. }
  3140.  
  3141. static long op_calz()             /*    CALL Z,nn */
  3142. {
  3143.     register unsigned i;
  3144.  
  3145.     if (F &    Z_FLAG)    {
  3146.         i = *PC++;
  3147.         i += *PC++ << 8;
  3148. #ifdef WANT_SPC
  3149.         if (STACK <= ram)
  3150.             STACK =    ram + 65536L;
  3151. #endif
  3152.         *--STACK = (PC - ram) >> 8;
  3153. #ifdef WANT_SPC
  3154.         if (STACK <= ram)
  3155.             STACK =    ram + 65536L;
  3156. #endif
  3157.         *--STACK = (PC - ram);
  3158.         PC = ram + i;
  3159. #ifdef WANT_TIM
  3160.         return(17L);
  3161. #endif
  3162.     } else {
  3163.         PC += 2;
  3164. #ifdef WANT_TIM
  3165.         return(10L);
  3166. #endif
  3167.     }
  3168. }
  3169.  
  3170. static long op_calnz()             /*    CALL NZ,nn */
  3171. {
  3172.     register unsigned i;
  3173.  
  3174.     if (!(F    & Z_FLAG)) {
  3175.         i = *PC++;
  3176.         i += *PC++ << 8;
  3177. #ifdef WANT_SPC
  3178.         if (STACK <= ram)
  3179.             STACK =    ram + 65536L;
  3180. #endif
  3181.         *--STACK = (PC - ram) >> 8;
  3182. #ifdef WANT_SPC
  3183.         if (STACK <= ram)
  3184.             STACK =    ram + 65536L;
  3185. #endif
  3186.         *--STACK = (PC - ram);
  3187.         PC = ram + i;
  3188. #ifdef WANT_TIM
  3189.         return(17L);
  3190. #endif
  3191.     } else {
  3192.         PC += 2;
  3193. #ifdef WANT_TIM
  3194.         return(10L);
  3195. #endif
  3196.     }
  3197. }
  3198.  
  3199. static long op_calc()             /*    CALL C,nn */
  3200. {
  3201.     register unsigned i;
  3202.  
  3203.     if (F &    C_FLAG)    {
  3204.         i = *PC++;
  3205.         i += *PC++ << 8;
  3206. #ifdef WANT_SPC
  3207.         if (STACK <= ram)
  3208.             STACK =    ram + 65536L;
  3209. #endif
  3210.         *--STACK = (PC - ram) >> 8;
  3211. #ifdef WANT_SPC
  3212.         if (STACK <= ram)
  3213.             STACK =    ram + 65536L;
  3214. #endif
  3215.         *--STACK = (PC - ram);
  3216.         PC = ram + i;
  3217. #ifdef WANT_TIM
  3218.         return(17L);
  3219. #endif
  3220.     } else {
  3221.         PC += 2;
  3222. #ifdef WANT_TIM
  3223.         return(10L);
  3224. #endif
  3225.     }
  3226. }
  3227.  
  3228. static long op_calnc()             /*    CALL NC,nn */
  3229. {
  3230.     register unsigned i;
  3231.  
  3232.     if (!(F    & C_FLAG)) {
  3233.         i = *PC++;
  3234.         i += *PC++ << 8;
  3235. #ifdef WANT_SPC
  3236.         if (STACK <= ram)
  3237.             STACK =    ram + 65536L;
  3238. #endif
  3239.         *--STACK = (PC - ram) >> 8;
  3240. #ifdef WANT_SPC
  3241.         if (STACK <= ram)
  3242.             STACK =    ram + 65536L;
  3243. #endif
  3244.         *--STACK = (PC - ram);
  3245.         PC = ram + i;
  3246. #ifdef WANT_TIM
  3247.         return(17L);
  3248. #endif
  3249.     } else {
  3250.         PC += 2;
  3251. #ifdef WANT_TIM
  3252.         return(10L);
  3253. #endif
  3254.     }
  3255. }
  3256.  
  3257. static long op_calpe()             /*    CALL PE,nn */
  3258. {
  3259.     register unsigned i;
  3260.  
  3261.     if (F &    P_FLAG)    {
  3262.         i = *PC++;
  3263.         i += *PC++ << 8;
  3264. #ifdef WANT_SPC
  3265.         if (STACK <= ram)
  3266.             STACK =    ram + 65536L;
  3267. #endif
  3268.         *--STACK = (PC - ram) >> 8;
  3269. #ifdef WANT_SPC
  3270.         if (STACK <= ram)
  3271.             STACK =    ram + 65536L;
  3272. #endif
  3273.         *--STACK = (PC - ram);
  3274.         PC = ram + i;
  3275. #ifdef WANT_TIM
  3276.         return(17L);
  3277. #endif
  3278.     } else {
  3279.         PC += 2;
  3280. #ifdef WANT_TIM
  3281.         return(10L);
  3282. #endif
  3283.     }
  3284. }
  3285.  
  3286. static long op_calpo()             /*    CALL PO,nn */
  3287. {
  3288.     register unsigned i;
  3289.  
  3290.     if (!(F    & P_FLAG)) {
  3291.         i = *PC++;
  3292.         i += *PC++ << 8;
  3293. #ifdef WANT_SPC
  3294.         if (STACK <= ram)
  3295.             STACK =    ram + 65536L;
  3296. #endif
  3297.         *--STACK = (PC - ram) >> 8;
  3298. #ifdef WANT_SPC
  3299.         if (STACK <= ram)
  3300.             STACK =    ram + 65536L;
  3301. #endif
  3302.         *--STACK = (PC - ram);
  3303.         PC = ram + i;
  3304. #ifdef WANT_TIM
  3305.         return(17L);
  3306. #endif
  3307.     } else {
  3308.         PC += 2;
  3309. #ifdef WANT_TIM
  3310.         return(10L);
  3311. #endif
  3312.     }
  3313. }
  3314.  
  3315. static long op_calm()             /*    CALL M,nn */
  3316. {
  3317.     register unsigned i;
  3318.  
  3319.     if (F &    S_FLAG)    {
  3320.         i = *PC++;
  3321.         i += *PC++ << 8;
  3322. #ifdef WANT_SPC
  3323.         if (STACK <= ram)
  3324.             STACK =    ram + 65536L;
  3325. #endif
  3326.         *--STACK = (PC - ram) >> 8;
  3327. #ifdef WANT_SPC
  3328.         if (STACK <= ram)
  3329.             STACK =    ram + 65536L;
  3330. #endif
  3331.         *--STACK = (PC - ram);
  3332.         PC = ram + i;
  3333. #ifdef WANT_TIM
  3334.         return(17L);
  3335. #endif
  3336.     } else {
  3337.         PC += 2;
  3338. #ifdef WANT_TIM
  3339.         return(10L);
  3340. #endif
  3341.     }
  3342. }
  3343.  
  3344. static long op_calp()             /*    CALL P,nn */
  3345. {
  3346.     register unsigned i;
  3347.  
  3348.     if (!(F    & S_FLAG)) {
  3349.         i = *PC++;
  3350.         i += *PC++ << 8;
  3351. #ifdef WANT_SPC
  3352.         if (STACK <= ram)
  3353.             STACK =    ram + 65536L;
  3354. #endif
  3355.         *--STACK = (PC - ram) >> 8;
  3356. #ifdef WANT_SPC
  3357.         if (STACK <= ram)
  3358.             STACK =    ram + 65536L;
  3359. #endif
  3360.         *--STACK = (PC - ram);
  3361.         PC = ram + i;
  3362. #ifdef WANT_TIM
  3363.         return(17L);
  3364. #endif
  3365.     } else {
  3366.         PC += 2;
  3367. #ifdef WANT_TIM
  3368.         return(10L);
  3369. #endif
  3370.     }
  3371. }
  3372.  
  3373. static long op_retz()             /*    RET Z */
  3374. {
  3375.     register unsigned i;
  3376.  
  3377.     if (F &    Z_FLAG)    {
  3378.         i = *STACK++;
  3379. #ifdef WANT_SPC
  3380.         if (STACK >= ram + 65536L)
  3381.             STACK =    ram;
  3382. #endif
  3383.         i += *STACK++ << 8;
  3384. #ifdef WANT_SPC
  3385.         if (STACK >= ram + 65536L)
  3386.             STACK =    ram;
  3387. #endif
  3388.         PC = ram + i;
  3389. #ifdef WANT_TIM
  3390.         return(11L);
  3391. #endif
  3392.     } else {
  3393. #ifdef WANT_TIM
  3394.         return(5L);
  3395. #endif
  3396.     }
  3397. }
  3398.  
  3399. static long op_retnz()             /*    RET NZ */
  3400. {
  3401.     register unsigned i;
  3402.  
  3403.     if (!(F    & Z_FLAG)) {
  3404.         i = *STACK++;
  3405. #ifdef WANT_SPC
  3406.         if (STACK >= ram + 65536L)
  3407.             STACK =    ram;
  3408. #endif
  3409.         i += *STACK++ << 8;
  3410. #ifdef WANT_SPC
  3411.         if (STACK >= ram + 65536L)
  3412.             STACK =    ram;
  3413. #endif
  3414.         PC = ram + i;
  3415. #ifdef WANT_TIM
  3416.         return(11L);
  3417. #endif
  3418.     } else {
  3419. #ifdef WANT_TIM
  3420.         return(5L);
  3421. #endif
  3422.     }
  3423. }
  3424.  
  3425. static long op_retc()             /*    RET C */
  3426. {
  3427.     register unsigned i;
  3428.  
  3429.     if (F &    C_FLAG)    {
  3430.         i = *STACK++;
  3431. #ifdef WANT_SPC
  3432.         if (STACK >= ram + 65536L)
  3433.             STACK =    ram;
  3434. #endif
  3435.         i += *STACK++ << 8;
  3436. #ifdef WANT_SPC
  3437.         if (STACK >= ram + 65536L)
  3438.             STACK =    ram;
  3439. #endif
  3440.         PC = ram + i;
  3441. #ifdef WANT_TIM
  3442.         return(11L);
  3443. #endif
  3444.     } else {
  3445. #ifdef WANT_TIM
  3446.         return(5L);
  3447. #endif
  3448.     }
  3449. }
  3450.  
  3451. static long op_retnc()             /*    RET NC */
  3452. {
  3453.     register unsigned i;
  3454.  
  3455.     if (!(F    & C_FLAG)) {
  3456.         i = *STACK++;
  3457. #ifdef WANT_SPC
  3458.         if (STACK >= ram + 65536L)
  3459.             STACK =    ram;
  3460. #endif
  3461.         i += *STACK++ << 8;
  3462. #ifdef WANT_SPC
  3463.         if (STACK >= ram + 65536L)
  3464.             STACK =    ram;
  3465. #endif
  3466.         PC = ram + i;
  3467. #ifdef WANT_TIM
  3468.         return(11L);
  3469. #endif
  3470.     } else {
  3471. #ifdef WANT_TIM
  3472.         return(5L);
  3473. #endif
  3474.     }
  3475. }
  3476.  
  3477. static long op_retpe()             /*    RET PE */
  3478. {
  3479.     register unsigned i;
  3480.  
  3481.     if (F &    P_FLAG)    {
  3482.         i = *STACK++;
  3483. #ifdef WANT_SPC
  3484.         if (STACK >= ram + 65536L)
  3485.             STACK =    ram;
  3486. #endif
  3487.         i += *STACK++ << 8;
  3488. #ifdef WANT_SPC
  3489.         if (STACK >= ram + 65536L)
  3490.             STACK =    ram;
  3491. #endif
  3492.         PC = ram + i;
  3493. #ifdef WANT_TIM
  3494.         return(11L);
  3495. #endif
  3496.     } else {
  3497. #ifdef WANT_TIM
  3498.         return(5L);
  3499. #endif
  3500.     }
  3501. }
  3502.  
  3503. static long op_retpo()             /*    RET PO */
  3504. {
  3505.     register unsigned i;
  3506.  
  3507.     if (!(F    & P_FLAG)) {
  3508.         i = *STACK++;
  3509. #ifdef WANT_SPC
  3510.         if (STACK >= ram + 65536L)
  3511.             STACK =    ram;
  3512. #endif
  3513.         i += *STACK++ << 8;
  3514. #ifdef WANT_SPC
  3515.         if (STACK >= ram + 65536L)
  3516.             STACK =    ram;
  3517. #endif
  3518.         PC = ram + i;
  3519. #ifdef WANT_TIM
  3520.         return(11L);
  3521. #endif
  3522.     } else {
  3523. #ifdef WANT_TIM
  3524.         return(5L);
  3525. #endif
  3526.     }
  3527. }
  3528.  
  3529. static long op_retm()             /*    RET M */
  3530. {
  3531.     register unsigned i;
  3532.  
  3533.     if (F &    S_FLAG)    {
  3534.         i = *STACK++;
  3535. #ifdef WANT_SPC
  3536.         if (STACK >= ram + 65536L)
  3537.             STACK =    ram;
  3538. #endif
  3539.         i += *STACK++ << 8;
  3540. #ifdef WANT_SPC
  3541.         if (STACK >= ram + 65536L)
  3542.             STACK =    ram;
  3543. #endif
  3544.         PC = ram + i;
  3545. #ifdef WANT_TIM
  3546.         return(11L);
  3547. #endif
  3548.     } else {
  3549. #ifdef WANT_TIM
  3550.         return(5L);
  3551. #endif
  3552.     }
  3553. }
  3554.  
  3555. static long op_retp()             /*    RET P */
  3556. {
  3557.     register unsigned i;
  3558.  
  3559.     if (!(F    & S_FLAG)) {
  3560.         i = *STACK++;
  3561. #ifdef WANT_SPC
  3562.         if (STACK >= ram + 65536L)
  3563.             STACK =    ram;
  3564. #endif
  3565.         i += *STACK++ << 8;
  3566. #ifdef WANT_SPC
  3567.         if (STACK >= ram + 65536L)
  3568.             STACK =    ram;
  3569. #endif
  3570.         PC = ram + i;
  3571. #ifdef WANT_TIM
  3572.         return(11L);
  3573. #endif
  3574.     } else {
  3575. #ifdef WANT_TIM
  3576.         return(5L);
  3577. #endif
  3578.     }
  3579. }
  3580.  
  3581. static long op_jrz()             /*    JR Z,n */
  3582. {
  3583.     if (F &    Z_FLAG)    {
  3584.         PC += (char) *PC + 1;
  3585. #ifdef WANT_TIM
  3586.         return(12L);
  3587. #endif
  3588.     } else {
  3589.         PC++;
  3590. #ifdef WANT_TIM
  3591.         return(7L);
  3592. #endif
  3593.     }
  3594. }
  3595.  
  3596. static long op_jrnz()             /*    JR NZ,n    */
  3597. {
  3598.     if (!(F    & Z_FLAG)) {
  3599.         PC += (char) *PC + 1;
  3600. #ifdef WANT_TIM
  3601.         return(12L);
  3602. #endif
  3603.     } else {
  3604.         PC++;
  3605. #ifdef WANT_TIM
  3606.         return(7L);
  3607. #endif
  3608.     }
  3609. }
  3610.  
  3611. static long op_jrc()             /*    JR C,n */
  3612. {
  3613.     if (F &    C_FLAG)    {
  3614.         PC += (char) *PC + 1;
  3615. #ifdef WANT_TIM
  3616.         return(12L);
  3617. #endif
  3618.     } else {
  3619.         PC++;
  3620. #ifdef WANT_TIM
  3621.         return(7L);
  3622. #endif
  3623.     }
  3624. }
  3625.  
  3626. static long op_jrnc()             /*    JR NC,n    */
  3627. {
  3628.     if (!(F    & C_FLAG)) {
  3629.         PC += (char) *PC + 1;
  3630. #ifdef WANT_TIM
  3631.         return(12L);
  3632. #endif
  3633.     } else {
  3634.         PC++;
  3635. #ifdef WANT_TIM
  3636.         return(7L);
  3637. #endif
  3638.     }
  3639. }
  3640.  
  3641. static long op_rst00()             /*    RST 00 */
  3642. {
  3643. #ifdef WANT_SPC
  3644.     if (STACK <= ram)
  3645.         STACK =    ram + 65536L;
  3646. #endif
  3647.     *--STACK = (PC - ram) >> 8;
  3648. #ifdef WANT_SPC
  3649.     if (STACK <= ram)
  3650.         STACK =    ram + 65536L;
  3651. #endif
  3652.     *--STACK = (PC - ram);
  3653.     PC = ram;
  3654. #ifdef WANT_TIM
  3655.     return(11L);
  3656. #endif
  3657. }
  3658.  
  3659. static long op_rst08()             /*    RST 08 */
  3660. {
  3661. #ifdef WANT_SPC
  3662.     if (STACK <= ram)
  3663.         STACK =    ram + 65536L;
  3664. #endif
  3665.     *--STACK = (PC - ram) >> 8;
  3666. #ifdef WANT_SPC
  3667.     if (STACK <= ram)
  3668.         STACK =    ram + 65536L;
  3669. #endif
  3670.     *--STACK = (PC - ram);
  3671.     PC = ram + 0x08;
  3672. #ifdef WANT_TIM
  3673.     return(11L);
  3674. #endif
  3675. }
  3676.  
  3677. static long op_rst10()             /*    RST 10 */
  3678. {
  3679. #ifdef WANT_SPC
  3680.     if (STACK <= ram)
  3681.         STACK =    ram + 65536L;
  3682. #endif
  3683.     *--STACK = (PC - ram) >> 8;
  3684. #ifdef WANT_SPC
  3685.     if (STACK <= ram)
  3686.         STACK =    ram + 65536L;
  3687. #endif
  3688.     *--STACK = (PC - ram);
  3689.     PC = ram + 0x10;
  3690. #ifdef WANT_TIM
  3691.     return(11L);
  3692. #endif
  3693. }
  3694.  
  3695. static long op_rst18()             /*    RST 18 */
  3696. {
  3697. #ifdef WANT_SPC
  3698.     if (STACK <= ram)
  3699.         STACK =    ram + 65536L;
  3700. #endif
  3701.     *--STACK = (PC - ram) >> 8;
  3702. #ifdef WANT_SPC
  3703.     if (STACK <= ram)
  3704.         STACK =    ram + 65536L;
  3705. #endif
  3706.     *--STACK = (PC - ram);
  3707.     PC = ram + 0x18;
  3708. #ifdef WANT_TIM
  3709.     return(11L);
  3710. #endif
  3711. }
  3712.  
  3713. static long op_rst20()             /*    RST 20 */
  3714. {
  3715. #ifdef WANT_SPC
  3716.     if (STACK <= ram)
  3717.         STACK =    ram + 65536L;
  3718. #endif
  3719.     *--STACK = (PC - ram) >> 8;
  3720. #ifdef WANT_SPC
  3721.     if (STACK <= ram)
  3722.         STACK =    ram + 65536L;
  3723. #endif
  3724.     *--STACK = (PC - ram);
  3725.     PC = ram + 0x20;
  3726. #ifdef WANT_TIM
  3727.     return(11L);
  3728. #endif
  3729. }
  3730.  
  3731. static long op_rst28()             /*    RST 28 */
  3732. {
  3733. #ifdef WANT_SPC
  3734.     if (STACK <= ram)
  3735.         STACK =    ram + 65536L;
  3736. #endif
  3737.     *--STACK = (PC - ram) >> 8;
  3738. #ifdef WANT_SPC
  3739.     if (STACK <= ram)
  3740.         STACK =    ram + 65536L;
  3741. #endif
  3742.     *--STACK = (PC - ram);
  3743.     PC = ram + 0x28;
  3744. #ifdef WANT_TIM
  3745.     return(11L);
  3746. #endif
  3747. }
  3748.  
  3749. static long op_rst30()             /*    RST 30 */
  3750. {
  3751. #ifdef WANT_SPC
  3752.     if (STACK <= ram)
  3753.         STACK =    ram + 65536L;
  3754. #endif
  3755.     *--STACK = (PC - ram) >> 8;
  3756. #ifdef WANT_SPC
  3757.     if (STACK <= ram)
  3758.         STACK =    ram + 65536L;
  3759. #endif
  3760.     *--STACK = (PC - ram);
  3761.     PC = ram + 0x30;
  3762. #ifdef WANT_TIM
  3763.     return(11L);
  3764. #endif
  3765. }
  3766.  
  3767. static long op_rst38()             /*    RST 38 */
  3768. {
  3769. #ifdef WANT_SPC
  3770.     if (STACK <= ram)
  3771.         STACK =    ram + 65536L;
  3772. #endif
  3773.     *--STACK = (PC - ram) >> 8;
  3774. #ifdef WANT_SPC
  3775.     if (STACK <= ram)
  3776.         STACK =    ram + 65536L;
  3777. #endif
  3778.     *--STACK = (PC - ram);
  3779.     PC = ram + 0x38;
  3780. #ifdef WANT_TIM
  3781.     return(11L);
  3782. #endif
  3783. }
  3784.