home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / emulator / unix / z80pack / z80sim / sim4.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-11  |  23.2 KB  |  1,265 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. /*
  22.  *    Like the function "cpu()" this one emulates multi byte opcodes
  23.  *    starting with 0xed
  24.  */
  25.  
  26. #include "sim.h"
  27. #include "simglb.h"
  28.  
  29. long op_ed_handel()
  30. {
  31.     long trap_ed();
  32.     long op_im0(), op_im1(), op_im2();
  33.     long op_reti(),    op_retn();
  34.     long op_neg();
  35.     long op_inaic(), op_inbic(), op_incic(), op_indic(), op_ineic();
  36.     long op_inhic(), op_inlic();
  37.     long op_outca(), op_outcb(), op_outcc(), op_outcd(), op_outce();
  38.     long op_outch(), op_outcl();
  39.     long op_ini(), op_inir(), op_ind(), op_indr();
  40.     long op_outi(),    op_otir(), op_outd(), op_otdr();
  41.     long op_ldai(),    op_ldar(), op_ldia(), op_ldra();
  42.     long op_ldbcinn(), op_lddeinn(), op_ldspinn();
  43.     long op_ldinbc(), op_ldinde(), op_ldinsp();
  44.     long op_adchb(), op_adchd(), op_adchh(), op_adchs();
  45.     long op_sbchb(), op_sbchd(), op_sbchh(), op_sbchs();
  46.     long op_ldi(), op_ldir(), op_ldd(), op_lddr();
  47.     long op_cpi(), op_cpir(), op_cpdop(), op_cpdr();
  48.     long op_oprld(), op_oprrd();
  49.  
  50.     static long (*op_ed[256]) () = {
  51.         trap_ed,            /* 0x00    */
  52.         trap_ed,            /* 0x01    */
  53.         trap_ed,            /* 0x02    */
  54.         trap_ed,            /* 0x03    */
  55.         trap_ed,            /* 0x04    */
  56.         trap_ed,            /* 0x05    */
  57.         trap_ed,            /* 0x06    */
  58.         trap_ed,            /* 0x07    */
  59.         trap_ed,            /* 0x08    */
  60.         trap_ed,            /* 0x09    */
  61.         trap_ed,            /* 0x0a    */
  62.         trap_ed,            /* 0x0b    */
  63.         trap_ed,            /* 0x0c    */
  64.         trap_ed,            /* 0x0d    */
  65.         trap_ed,            /* 0x0e    */
  66.         trap_ed,            /* 0x0f    */
  67.         trap_ed,            /* 0x10    */
  68.         trap_ed,            /* 0x11    */
  69.         trap_ed,            /* 0x12    */
  70.         trap_ed,            /* 0x13    */
  71.         trap_ed,            /* 0x14    */
  72.         trap_ed,            /* 0x15    */
  73.         trap_ed,            /* 0x16    */
  74.         trap_ed,            /* 0x17    */
  75.         trap_ed,            /* 0x18    */
  76.         trap_ed,            /* 0x19    */
  77.         trap_ed,            /* 0x1a    */
  78.         trap_ed,            /* 0x1b    */
  79.         trap_ed,            /* 0x1c    */
  80.         trap_ed,            /* 0x1d    */
  81.         trap_ed,            /* 0x1e    */
  82.         trap_ed,            /* 0x1f    */
  83.         trap_ed,            /* 0x20    */
  84.         trap_ed,            /* 0x21    */
  85.         trap_ed,            /* 0x22    */
  86.         trap_ed,            /* 0x23    */
  87.         trap_ed,            /* 0x24    */
  88.         trap_ed,            /* 0x25    */
  89.         trap_ed,            /* 0x26    */
  90.         trap_ed,            /* 0x27    */
  91.         trap_ed,            /* 0x28    */
  92.         trap_ed,            /* 0x29    */
  93.         trap_ed,            /* 0x2a    */
  94.         trap_ed,            /* 0x2b    */
  95.         trap_ed,            /* 0x2c    */
  96.         trap_ed,            /* 0x2d    */
  97.         trap_ed,            /* 0x2e    */
  98.         trap_ed,            /* 0x2f    */
  99.         trap_ed,            /* 0x30    */
  100.         trap_ed,            /* 0x31    */
  101.         trap_ed,            /* 0x32    */
  102.         trap_ed,            /* 0x33    */
  103.         trap_ed,            /* 0x34    */
  104.         trap_ed,            /* 0x35    */
  105.         trap_ed,            /* 0x36    */
  106.         trap_ed,            /* 0x37    */
  107.         trap_ed,            /* 0x38    */
  108.         trap_ed,            /* 0x39    */
  109.         trap_ed,            /* 0x3a    */
  110.         trap_ed,            /* 0x3b    */
  111.         trap_ed,            /* 0x3c    */
  112.         trap_ed,            /* 0x3d    */
  113.         trap_ed,            /* 0x3e    */
  114.         trap_ed,            /* 0x3f    */
  115.         op_inbic,            /* 0x40    */
  116.         op_outcb,            /* 0x41    */
  117.         op_sbchb,            /* 0x42    */
  118.         op_ldinbc,            /* 0x43    */
  119.         op_neg,                /* 0x44    */
  120.         op_retn,            /* 0x45    */
  121.         op_im0,                /* 0x46    */
  122.         op_ldia,            /* 0x47    */
  123.         op_incic,            /* 0x48    */
  124.         op_outcc,            /* 0x49    */
  125.         op_adchb,            /* 0x4a    */
  126.         op_ldbcinn,            /* 0x4b    */
  127.         trap_ed,            /* 0x4c    */
  128.         op_reti,            /* 0x4d    */
  129.         trap_ed,            /* 0x4e    */
  130.         op_ldra,            /* 0x4f    */
  131.         op_indic,            /* 0x50    */
  132.         op_outcd,            /* 0x51    */
  133.         op_sbchd,            /* 0x52    */
  134.         op_ldinde,            /* 0x53    */
  135.         trap_ed,            /* 0x54    */
  136.         trap_ed,            /* 0x55    */
  137.         op_im1,                /* 0x56    */
  138.         op_ldai,            /* 0x57    */
  139.         op_ineic,            /* 0x58    */
  140.         op_outce,            /* 0x59    */
  141.         op_adchd,            /* 0x5a    */
  142.         op_lddeinn,            /* 0x5b    */
  143.         trap_ed,            /* 0x5c    */
  144.         trap_ed,            /* 0x5d    */
  145.         op_im2,                /* 0x5e    */
  146.         op_ldar,            /* 0x5f    */
  147.         op_inhic,            /* 0x60    */
  148.         op_outch,            /* 0x61    */
  149.         op_sbchh,            /* 0x62    */
  150.         trap_ed,            /* 0x63    */
  151.         trap_ed,            /* 0x64    */
  152.         trap_ed,            /* 0x65    */
  153.         trap_ed,            /* 0x66    */
  154.         op_oprrd,            /* 0x67    */
  155.         op_inlic,            /* 0x68    */
  156.         op_outcl,            /* 0x69    */
  157.         op_adchh,            /* 0x6a    */
  158.         trap_ed,            /* 0x6b    */
  159.         trap_ed,            /* 0x6c    */
  160.         trap_ed,            /* 0x6d    */
  161.         trap_ed,            /* 0x6e    */
  162.         op_oprld,            /* 0x6f    */
  163.         trap_ed,            /* 0x70    */
  164.         trap_ed,            /* 0x71    */
  165.         op_sbchs,            /* 0x72    */
  166.         op_ldinsp,            /* 0x73    */
  167.         trap_ed,            /* 0x74    */
  168.         trap_ed,            /* 0x75    */
  169.         trap_ed,            /* 0x76    */
  170.         trap_ed,            /* 0x77    */
  171.         op_inaic,            /* 0x78    */
  172.         op_outca,            /* 0x79    */
  173.         op_adchs,            /* 0x7a    */
  174.         op_ldspinn,            /* 0x7b    */
  175.         trap_ed,            /* 0x7c    */
  176.         trap_ed,            /* 0x7d    */
  177.         trap_ed,            /* 0x7e    */
  178.         trap_ed,            /* 0x7f    */
  179.         trap_ed,            /* 0x80    */
  180.         trap_ed,            /* 0x81    */
  181.         trap_ed,            /* 0x82    */
  182.         trap_ed,            /* 0x83    */
  183.         trap_ed,            /* 0x84    */
  184.         trap_ed,            /* 0x85    */
  185.         trap_ed,            /* 0x86    */
  186.         trap_ed,            /* 0x87    */
  187.         trap_ed,            /* 0x88    */
  188.         trap_ed,            /* 0x89    */
  189.         trap_ed,            /* 0x8a    */
  190.         trap_ed,            /* 0x8b    */
  191.         trap_ed,            /* 0x8c    */
  192.         trap_ed,            /* 0x8d    */
  193.         trap_ed,            /* 0x8e    */
  194.         trap_ed,            /* 0x8f    */
  195.         trap_ed,            /* 0x90    */
  196.         trap_ed,            /* 0x91    */
  197.         trap_ed,            /* 0x92    */
  198.         trap_ed,            /* 0x93    */
  199.         trap_ed,            /* 0x94    */
  200.         trap_ed,            /* 0x95    */
  201.         trap_ed,            /* 0x96    */
  202.         trap_ed,            /* 0x97    */
  203.         trap_ed,            /* 0x98    */
  204.         trap_ed,            /* 0x99    */
  205.         trap_ed,            /* 0x9a    */
  206.         trap_ed,            /* 0x9b    */
  207.         trap_ed,            /* 0x9c    */
  208.         trap_ed,            /* 0x9d    */
  209.         trap_ed,            /* 0x9e    */
  210.         trap_ed,            /* 0x9f    */
  211.         op_ldi,                /* 0xa0    */
  212.         op_cpi,                /* 0xa1    */
  213.         op_ini,                /* 0xa2    */
  214.         op_outi,            /* 0xa3    */
  215.         trap_ed,            /* 0xa4    */
  216.         trap_ed,            /* 0xa5    */
  217.         trap_ed,            /* 0xa6    */
  218.         trap_ed,            /* 0xa7    */
  219.         op_ldd,                /* 0xa8    */
  220.         op_cpdop,            /* 0xa9    */
  221.         op_ind,                /* 0xaa    */
  222.         op_outd,            /* 0xab    */
  223.         trap_ed,            /* 0xac    */
  224.         trap_ed,            /* 0xad    */
  225.         trap_ed,            /* 0xae    */
  226.         trap_ed,            /* 0xaf    */
  227.         op_ldir,            /* 0xb0    */
  228.         op_cpir,            /* 0xb1    */
  229.         op_inir,            /* 0xb2    */
  230.         op_otir,            /* 0xb3    */
  231.         trap_ed,            /* 0xb4    */
  232.         trap_ed,            /* 0xb5    */
  233.         trap_ed,            /* 0xb6    */
  234.         trap_ed,            /* 0xb7    */
  235.         op_lddr,            /* 0xb8    */
  236.         op_cpdr,            /* 0xb9    */
  237.         op_indr,            /* 0xba    */
  238.         op_otdr,            /* 0xbb    */
  239.         trap_ed,            /* 0xbc    */
  240.         trap_ed,            /* 0xbd    */
  241.         trap_ed,            /* 0xbe    */
  242.         trap_ed,            /* 0xbf    */
  243.         trap_ed,            /* 0xc0    */
  244.         trap_ed,            /* 0xc1    */
  245.         trap_ed,            /* 0xc2    */
  246.         trap_ed,            /* 0xc3    */
  247.         trap_ed,            /* 0xc4    */
  248.         trap_ed,            /* 0xc5    */
  249.         trap_ed,            /* 0xc6    */
  250.         trap_ed,            /* 0xc7    */
  251.         trap_ed,            /* 0xc8    */
  252.         trap_ed,            /* 0xc9    */
  253.         trap_ed,            /* 0xca    */
  254.         trap_ed,            /* 0xcb    */
  255.         trap_ed,            /* 0xcc    */
  256.         trap_ed,            /* 0xcd    */
  257.         trap_ed,            /* 0xce    */
  258.         trap_ed,            /* 0xcf    */
  259.         trap_ed,            /* 0xd0    */
  260.         trap_ed,            /* 0xd1    */
  261.         trap_ed,            /* 0xd2    */
  262.         trap_ed,            /* 0xd3    */
  263.         trap_ed,            /* 0xd4    */
  264.         trap_ed,            /* 0xd5    */
  265.         trap_ed,            /* 0xd6    */
  266.         trap_ed,            /* 0xd7    */
  267.         trap_ed,            /* 0xd8    */
  268.         trap_ed,            /* 0xd9    */
  269.         trap_ed,            /* 0xda    */
  270.         trap_ed,            /* 0xdb    */
  271.         trap_ed,            /* 0xdc    */
  272.         trap_ed,            /* 0xdd    */
  273.         trap_ed,            /* 0xde    */
  274.         trap_ed,            /* 0xdf    */
  275.         trap_ed,            /* 0xe0    */
  276.         trap_ed,            /* 0xe1    */
  277.         trap_ed,            /* 0xe2    */
  278.         trap_ed,            /* 0xe3    */
  279.         trap_ed,            /* 0xe4    */
  280.         trap_ed,            /* 0xe5    */
  281.         trap_ed,            /* 0xe6    */
  282.         trap_ed,            /* 0xe7    */
  283.         trap_ed,            /* 0xe8    */
  284.         trap_ed,            /* 0xe9    */
  285.         trap_ed,            /* 0xea    */
  286.         trap_ed,            /* 0xeb    */
  287.         trap_ed,            /* 0xec    */
  288.         trap_ed,            /* 0xed    */
  289.         trap_ed,            /* 0xee    */
  290.         trap_ed,            /* 0xef    */
  291.         trap_ed,            /* 0xf0    */
  292.         trap_ed,            /* 0xf1    */
  293.         trap_ed,            /* 0xf2    */
  294.         trap_ed,            /* 0xf3    */
  295.         trap_ed,            /* 0xf4    */
  296.         trap_ed,            /* 0xf5    */
  297.         trap_ed,            /* 0xf6    */
  298.         trap_ed,            /* 0xf7    */
  299.         trap_ed,            /* 0xf8    */
  300.         trap_ed,            /* 0xf9    */
  301.         trap_ed,            /* 0xfa    */
  302.         trap_ed,            /* 0xfb    */
  303.         trap_ed,            /* 0xfc    */
  304.         trap_ed,            /* 0xfd    */
  305.         trap_ed,            /* 0xfe    */
  306.         trap_ed                /* 0xff    */
  307.     };
  308.  
  309. #ifdef WANT_TIM
  310.     register long t;
  311.     t = (*op_ed[*PC++]) ();        /* execute next opcode */
  312. #else
  313.     (*op_ed[*PC++]) ();
  314. #endif
  315.  
  316. #ifdef WANT_PCC
  317.         if (PC > ram + 65535)    /* correct PC overrun */
  318.             PC = ram;
  319. #endif
  320.  
  321. #ifdef WANT_TIM
  322.     return(t);
  323. #endif
  324. }
  325.  
  326. /*
  327.  *    This function traps all illegal opcodes following the
  328.  *    initial 0xed of a multi byte opcode.
  329.  */
  330. static long trap_ed()
  331. {
  332.     cpu_error = OPTRAP2;
  333.     cpu_state = STOPPED;
  334. #ifdef WANT_TIM
  335.     return(0L);
  336. #endif
  337. }
  338.  
  339. static long op_im0()             /*    IM 0 */
  340. {
  341.     int_mode = 0;
  342. #ifdef WANT_TIM
  343.     return(8L);
  344. #endif
  345. }
  346.  
  347. static long op_im1()             /*    IM 1 */
  348. {
  349.     int_mode = 1;
  350. #ifdef WANT_TIM
  351.     return(8L);
  352. #endif
  353. }
  354.  
  355. static long op_im2()             /*    IM 2 */
  356. {
  357.     int_mode = 2;
  358. #ifdef WANT_TIM
  359.     return(8L);
  360. #endif
  361. }
  362.  
  363. static long op_reti()             /*    RETI */
  364. {
  365.     register unsigned i;
  366.  
  367.     i = *STACK++;
  368. #ifdef WANT_SPC
  369.     if (STACK >= ram + 65536L)
  370.         STACK =    ram;
  371. #endif
  372.     i += *STACK++ << 8;
  373. #ifdef WANT_SPC
  374.     if (STACK >= ram + 65536L)
  375.         STACK =    ram;
  376. #endif
  377.     PC = ram + i;
  378. #ifdef WANT_TIM
  379.     return(14L);
  380. #endif
  381. }
  382.  
  383. static long op_retn()             /*    RETN */
  384. {
  385.     register unsigned i;
  386.  
  387.     i = *STACK++;
  388. #ifdef WANT_SPC
  389.     if (STACK >= ram + 65536L)
  390.         STACK =    ram;
  391. #endif
  392.     i += *STACK++ << 8;
  393. #ifdef WANT_SPC
  394.     if (STACK >= ram + 65536L)
  395.         STACK =    ram;
  396. #endif
  397.     PC = ram + i;
  398.     (IFF & 2) ? (IFF |= 1) : (IFF &= ~1);
  399. #ifdef WANT_TIM
  400.     return(14L);
  401. #endif
  402. }
  403.  
  404. static long op_neg()             /*    NEG */
  405. {
  406.     (A) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  407.     (A == 0x80) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  408.     (0 - ((char) A & 0xf) <    0) ? (F    |= H_FLAG) : (F    &= ~H_FLAG);
  409.     A = 0 -    A;
  410.     F |= N_FLAG;
  411.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  412.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  413. #ifdef WANT_TIM
  414.     return(8L);
  415. #endif
  416. }
  417.  
  418. static long op_inaic()             /*    IN A,(C) */
  419. {
  420.     BYTE io_in();
  421.  
  422.     A = io_in(C);
  423.     F &= ~(N_FLAG |    H_FLAG);
  424.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  425.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  426.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  427. #ifdef WANT_TIM
  428.     return(12L);
  429. #endif
  430. }
  431.  
  432. static long op_inbic()             /*    IN B,(C) */
  433. {
  434.     BYTE io_in();
  435.  
  436.     B = io_in(C);
  437.     F &= ~(N_FLAG |    H_FLAG);
  438.     (B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  439.     (B & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  440.     (parrity[B]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  441. #ifdef WANT_TIM
  442.     return(12L);
  443. #endif
  444. }
  445.  
  446. static long op_incic()             /*    IN C,(C) */
  447. {
  448.     BYTE io_in();
  449.  
  450.     C = io_in(C);
  451.     F &= ~(N_FLAG |    H_FLAG);
  452.     (C) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  453.     (C & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  454.     (parrity[C]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  455. #ifdef WANT_TIM
  456.     return(12L);
  457. #endif
  458. }
  459.  
  460. static long op_indic()             /*    IN D,(C) */
  461. {
  462.     BYTE io_in();
  463.  
  464.     D = io_in(C);
  465.     F &= ~(N_FLAG |    H_FLAG);
  466.     (D) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  467.     (D & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  468.     (parrity[D]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  469. #ifdef WANT_TIM
  470.     return(12L);
  471. #endif
  472. }
  473.  
  474. static long op_ineic()             /*    IN E,(C) */
  475. {
  476.     BYTE io_in();
  477.  
  478.     E = io_in(C);
  479.     F &= ~(N_FLAG |    H_FLAG);
  480.     (E) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  481.     (E & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  482.     (parrity[E]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  483. #ifdef WANT_TIM
  484.     return(12L);
  485. #endif
  486. }
  487.  
  488. static long op_inhic()             /*    IN H,(C) */
  489. {
  490.     BYTE io_in();
  491.  
  492.     H = io_in(C);
  493.     F &= ~(N_FLAG |    H_FLAG);
  494.     (H) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  495.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  496.     (parrity[H]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  497. #ifdef WANT_TIM
  498.     return(12L);
  499. #endif
  500. }
  501.  
  502. static long op_inlic()             /*    IN L,(C) */
  503. {
  504.     BYTE io_in();
  505.  
  506.     L = io_in(C);
  507.     F &= ~(N_FLAG |    H_FLAG);
  508.     (L) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  509.     (L & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  510.     (parrity[L]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  511. #ifdef WANT_TIM
  512.     return(12L);
  513. #endif
  514. }
  515.  
  516. static long op_outca()             /*    OUT (C),A */
  517. {
  518.     BYTE io_out();
  519.  
  520.     io_out(C, A);
  521. #ifdef WANT_TIM
  522.     return(12L);
  523. #endif
  524. }
  525.  
  526. static long op_outcb()             /*    OUT (C),B */
  527. {
  528.     BYTE io_out();
  529.  
  530.     io_out(C, B);
  531. #ifdef WANT_TIM
  532.     return(12L);
  533. #endif
  534. }
  535.  
  536. static long op_outcc()             /*    OUT (C),C */
  537. {
  538.     BYTE io_out();
  539.  
  540.     io_out(C, C);
  541. #ifdef WANT_TIM
  542.     return(12L);
  543. #endif
  544. }
  545.  
  546. static long op_outcd()             /*    OUT (C),D */
  547. {
  548.     BYTE io_out();
  549.  
  550.     io_out(C, D);
  551. #ifdef WANT_TIM
  552.     return(12L);
  553. #endif
  554. }
  555.  
  556. static long op_outce()             /*    OUT (C),E */
  557. {
  558.     BYTE io_out();
  559.  
  560.     io_out(C, E);
  561. #ifdef WANT_TIM
  562.     return(12L);
  563. #endif
  564. }
  565.  
  566. static long op_outch()             /*    OUT (C),H */
  567. {
  568.     BYTE io_out();
  569.  
  570.     io_out(C, H);
  571. #ifdef WANT_TIM
  572.     return(12L);
  573. #endif
  574. }
  575.  
  576. static long op_outcl()             /*    OUT (C),L */
  577. {
  578.     BYTE io_out();
  579.  
  580.     io_out(C, L);
  581. #ifdef WANT_TIM
  582.     return(12L);
  583. #endif
  584. }
  585.  
  586. static long op_ini()             /*    INI */
  587. {
  588.     BYTE io_in();
  589.  
  590.     *(ram +    (H << 8) + L) =    io_in(C);
  591.     L++;
  592.     if (!L)
  593.         H++;
  594.     B--;
  595.     F |= N_FLAG;
  596.     (B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  597. #ifdef WANT_TIM
  598.     return(16L);
  599. #endif
  600. }
  601.  
  602. static long op_inir()             /*    INIR */
  603. {
  604. #ifdef WANT_TIM
  605.     register long t    = -21L;
  606. #endif
  607.     register BYTE *d;
  608.     BYTE io_in();
  609.  
  610.     d = ram    + (H <<    8) + L;
  611.     do {
  612.         *d++ = io_in(C);
  613.         B--;
  614. #ifdef WANT_TIM
  615.         t += 21L;
  616. #endif
  617.     } while    (B);
  618.     H = (d - ram) >> 8;
  619.     L = d -    ram;
  620.     F |= N_FLAG | Z_FLAG;
  621. #ifdef WANT_TIM
  622.     return(t + 16L);
  623. #endif
  624. }
  625.  
  626. static long op_ind()             /*    IND */
  627. {
  628.     BYTE io_in();
  629.  
  630.     *(ram +    (H << 8) + L) =    io_in(C);
  631.     L--;
  632.     if (L == 0xff)
  633.         H--;
  634.     B--;
  635.     F |= N_FLAG;
  636.     (B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  637. #ifdef WANT_TIM
  638.     return(16L);
  639. #endif
  640. }
  641.  
  642. static long op_indr()             /*    INDR */
  643. {
  644. #ifdef WANT_TIM
  645.     register long t    = -21L;
  646. #endif
  647.     register BYTE *d;
  648.     BYTE io_in();
  649.  
  650.     d = ram    + (H <<    8) + L;
  651.     do {
  652.         *d-- = io_in(C);
  653.         B--;
  654. #ifdef WANT_TIM
  655.         t += 21L;
  656. #endif
  657.     } while    (B);
  658.     H = (d - ram) >> 8;
  659.     L = d -    ram;
  660.     F |= N_FLAG | Z_FLAG;
  661. #ifdef WANT_TIM
  662.     return(t + 16L);
  663. #endif
  664. }
  665.  
  666. static long op_outi()             /*    OUTI */
  667. {
  668.     BYTE io_out();
  669.  
  670.     io_out(C, *(ram    + (H <<    8) * L));
  671.     L++;
  672.     if (!L)
  673.         H++;
  674.     B--;
  675.     F |= N_FLAG;
  676.     (B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  677. #ifdef WANT_TIM
  678.     return(16L);
  679. #endif
  680. }
  681.  
  682. static long op_otir()             /*    OTIR */
  683. {
  684. #ifdef WANT_TIM
  685.     register long t    = -21L;
  686. #endif
  687.     register BYTE *d;
  688.     BYTE io_out();
  689.  
  690.     d = ram    + (H <<    8) + L;
  691.     do {
  692.         io_out(C, *d++);
  693.         B--;
  694. #ifdef WANT_TIM
  695.         t += 21L;
  696. #endif
  697.     } while    (B);
  698.     H = (d - ram) >> 8;
  699.     L = d -    ram;
  700.     F |= N_FLAG | Z_FLAG;
  701. #ifdef WANT_TIM
  702.     return(t + 16L);
  703. #endif
  704. }
  705.  
  706. static long op_outd()             /*    OUTD */
  707. {
  708.     BYTE io_out();
  709.  
  710.     io_out(C, *(ram    + (H <<    8) * L));
  711.     L--;
  712.     if (L == 0xff)
  713.         H--;
  714.     B--;
  715.     F |= N_FLAG;
  716.     (B) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  717. #ifdef WANT_TIM
  718.     return(16L);
  719. #endif
  720. }
  721.  
  722. static long op_otdr()             /*    OTDR */
  723. {
  724. #ifdef WANT_TIM
  725.     register long t    = -21L;
  726. #endif
  727.     register BYTE *d;
  728.     BYTE io_out();
  729.  
  730.     d = ram    + (H <<    8) + L;
  731.     do {
  732.         io_out(C, *d--);
  733.         B--;
  734. #ifdef WANT_TIM
  735.         t += 21L;
  736. #endif
  737.     } while    (B);
  738.     H = (d - ram) >> 8;
  739.     L = d -    ram;
  740.     F |= N_FLAG | Z_FLAG;
  741. #ifdef WANT_TIM
  742.     return(t + 16L);
  743. #endif
  744. }
  745.  
  746. static long op_ldai()             /*    LD A,I */
  747. {
  748.     A = I;
  749.     F &= ~(N_FLAG |    H_FLAG);
  750.     (IFF & 2) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  751.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  752.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  753. #ifdef WANT_TIM
  754.     return(9L);
  755. #endif
  756. }
  757.  
  758. static long op_ldar()             /*    LD A,R */
  759. {
  760.     A = (BYTE) R;
  761.     F &= ~(N_FLAG |    H_FLAG);
  762.     (IFF & 2) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  763.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  764.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  765. #ifdef WANT_TIM
  766.     return(9L);
  767. #endif
  768. }
  769.  
  770. static long op_ldia()             /*    LD I,A */
  771. {
  772.     I = A;
  773. #ifdef WANT_TIM
  774.     return(9L);
  775. #endif
  776. }
  777.  
  778. static long op_ldra()             /*    LD R,A */
  779. {
  780.     R = A;
  781. #ifdef WANT_TIM
  782.     return(9L);
  783. #endif
  784. }
  785.  
  786. static long op_ldbcinn()         /*    LD BC,(nn) */
  787. {
  788.     register BYTE *p;
  789.  
  790.     p = ram    + *PC++;
  791.     p += *PC++ << 8;
  792.     C = *p++;
  793.     B = *p;
  794. #ifdef WANT_TIM
  795.     return(20L);
  796. #endif
  797. }
  798.  
  799. static long op_lddeinn()         /*    LD DE,(nn) */
  800. {
  801.     register BYTE *p;
  802.  
  803.     p = ram    + *PC++;
  804.     p += *PC++ << 8;
  805.     E = *p++;
  806.     D = *p;
  807. #ifdef WANT_TIM
  808.     return(20L);
  809. #endif
  810. }
  811.  
  812. static long op_ldspinn()         /*    LD SP,(nn) */
  813. {
  814.     register BYTE *p;
  815.  
  816.     p = ram    + *PC++;
  817.     p += *PC++ << 8;
  818.     STACK =    ram + *p++;
  819.     STACK += *p << 8;
  820. #ifdef WANT_TIM
  821.     return(20L);
  822. #endif
  823. }
  824.  
  825. static long op_ldinbc()             /*    LD (nn),BC */
  826. {
  827.     register BYTE *p;
  828.  
  829.     p = ram    + *PC++;
  830.     p += *PC++ << 8;
  831.     *p++ = C;
  832.     *p = B;
  833. #ifdef WANT_TIM
  834.     return(20L);
  835. #endif
  836. }
  837.  
  838. static long op_ldinde()             /*    LD (nn),DE */
  839. {
  840.     register BYTE *p;
  841.  
  842.     p = ram    + *PC++;
  843.     p += *PC++ << 8;
  844.     *p++ = E;
  845.     *p = D;
  846. #ifdef WANT_TIM
  847.     return(20L);
  848. #endif
  849. }
  850.  
  851. static long op_ldinsp()             /*    LD (nn),SP */
  852. {
  853.     register BYTE *p;
  854.     register int i;
  855.  
  856.     p = ram    + *PC++;
  857.     p += *PC++ << 8;
  858.     i = STACK - ram;
  859.     *p++ = i;
  860.     *p = i >> 8;
  861. #ifdef WANT_TIM
  862.     return(20L);
  863. #endif
  864. }
  865.  
  866. static long op_adchb()             /*    ADC HL,BC */
  867. {
  868.     register int carry;
  869.     register WORD hl, bc;
  870.     register long i;
  871.  
  872.     carry =    (F & C_FLAG) ? 1 : 0;
  873.     hl = (H    << 8) +    L;
  874.     bc = (B    << 8) +    C;
  875.     i = ((long)hl) + ((long)bc) + carry;
  876.     ((hl < 0x8000) && (i > 0x7fffL)) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  877.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  878.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  879.     H = i >> 8;
  880.     L = i;
  881.     F &= ~N_FLAG;
  882.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  883. #ifdef WANT_TIM
  884.     return(15L);
  885. #endif
  886. }
  887.  
  888. static long op_adchd()             /*    ADC HL,DE */
  889. {
  890.     register int carry;
  891.     register WORD hl, de;
  892.     register long i;
  893.  
  894.     carry =    (F & C_FLAG) ? 1 : 0;
  895.     hl = (H    << 8) +    L;
  896.     de = (D    << 8) +    E;
  897.     i = ((long)hl) + ((long)de) + carry;
  898.     ((hl < 0x8000) && (i > 0x7fffL)) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  899.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  900.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  901.     H = i >> 8;
  902.     L = i;
  903.     F &= ~N_FLAG;
  904.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  905. #ifdef WANT_TIM
  906.     return(15L);
  907. #endif
  908. }
  909.  
  910. static long op_adchh()             /*    ADC HL,HL */
  911. {
  912.     register int carry;
  913.     register WORD hl;
  914.     register long i;
  915.  
  916.     carry =    (F & C_FLAG) ? 1 : 0;
  917.     hl = (H    << 8) +    L;
  918.     i = ((((long)hl) << 1) + carry);
  919.     ((hl < 0x8000) && (i > 0x7fffL)) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  920.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  921.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  922.     H = i >> 8;
  923.     L = i;
  924.     F &= ~N_FLAG;
  925.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  926. #ifdef WANT_TIM
  927.     return(15L);
  928. #endif
  929. }
  930.  
  931. static long op_adchs()             /*    ADC HL,SP */
  932. {
  933.     register int carry;
  934.     register WORD hl, sp;
  935.     register long i;
  936.  
  937.     carry =    (F & C_FLAG) ? 1 : 0;
  938.     hl = (H    << 8) +    L;
  939.     sp = STACK - ram;
  940.     i = ((long)hl) + ((long)sp) + carry;
  941.     ((hl < 0x8000) && (i > 0x7fffL)) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  942.     (i > 0xffffL) ?    (F |= C_FLAG) :    (F &= ~C_FLAG);
  943.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  944.     H = i >> 8;
  945.     L = i;
  946.     F &= ~N_FLAG;
  947.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  948. #ifdef WANT_TIM
  949.     return(15L);
  950. #endif
  951. }
  952.  
  953. static long op_sbchb()             /*    SBC HL,BC */
  954. {
  955.     register int carry;
  956.     register WORD hl, bc;
  957.     register long i;
  958.  
  959.     carry =    (F & C_FLAG) ? 1 : 0;
  960.     hl = (H    << 8) +    L;
  961.     bc = (B    << 8) +    C;
  962.     i = ((long)hl) - ((long)bc) - carry;
  963.     ((hl > 0x7fff) && (i < 0x8000L)) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  964.     (i < 0L) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  965.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  966.     H = i >> 8;
  967.     L = i;
  968.     F |= N_FLAG;
  969.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  970. #ifdef WANT_TIM
  971.     return(15L);
  972. #endif
  973. }
  974.  
  975. static long op_sbchd()             /*    SBC HL,DE */
  976. {
  977.     register int carry;
  978.     register WORD hl, de;
  979.     register long i;
  980.  
  981.     carry =    (F & C_FLAG) ? 1 : 0;
  982.     hl = (H    << 8) +    L;
  983.     de = (D    << 8) +    E;
  984.     i = ((long)hl) - ((long)de) - carry;
  985.     ((hl > 0x7fff) && (i < 0x8000L)) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  986.     (i < 0L) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  987.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  988.     H = i >> 8;
  989.     L = i;
  990.     F |= N_FLAG;
  991.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  992. #ifdef WANT_TIM
  993.     return(15L);
  994. #endif
  995. }
  996.  
  997. static long op_sbchh()             /*    SBC HL,HL */
  998. {
  999.     if (F &    C_FLAG)    {
  1000.         F |= S_FLAG | P_FLAG | N_FLAG |    C_FLAG;
  1001.         F &= ~Z_FLAG;
  1002.         H = L =    255;
  1003.     } else {
  1004.         F |= Z_FLAG | N_FLAG;
  1005.         F &= ~(S_FLAG |    P_FLAG | C_FLAG);
  1006.         H = L =    0;
  1007.     }
  1008. #ifdef WANT_TIM
  1009.     return(15L);
  1010. #endif
  1011. }
  1012.  
  1013. static long op_sbchs()             /*    SBC HL,SP */
  1014. {
  1015.     register int carry;
  1016.     register WORD hl, sp;
  1017.     register long i;
  1018.  
  1019.     carry =    (F & C_FLAG) ? 1 : 0;
  1020.     hl = (H    << 8) +    L;
  1021.     sp = STACK - ram;
  1022.     i = ((long)hl) - ((long)sp) - carry;
  1023.     ((hl > 0x7fff) && (i < 0x8000L)) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  1024.     (i < 0L) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  1025.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1026.     H = i >> 8;
  1027.     L = i;
  1028.     F |= N_FLAG;
  1029.     (H & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1030. #ifdef WANT_TIM
  1031.     return(15L);
  1032. #endif
  1033. }
  1034.  
  1035. static long op_ldi()             /*    LDI */
  1036. {
  1037.     *(ram +    (D << 8) + E) =    *(ram +    (H << 8) + L);
  1038.     E++;
  1039.     if (!E)
  1040.         D++;
  1041.     L++;
  1042.     if (!L)
  1043.         H++;
  1044.     C--;
  1045.     if (C == 0xff)
  1046.         B--;
  1047.     (B | C)    ? (F |=    P_FLAG)    : (F &=    ~P_FLAG);
  1048.     F &= ~(N_FLAG |    H_FLAG);
  1049. #ifdef WANT_TIM
  1050.     return(16L);
  1051. #endif
  1052. }
  1053.  
  1054. static long op_ldir()             /*    LDIR */
  1055. {
  1056. #ifdef WANT_TIM
  1057.     register long t    = -21L;
  1058. #endif
  1059.     register WORD i;
  1060.     register BYTE *s, *d;
  1061.  
  1062.     i = (B << 8) + C;
  1063.     d = ram    + (D <<    8) + E;
  1064.     s = ram    + (H <<    8) + L;
  1065.     do {
  1066.         *d++ = *s++;
  1067. #ifdef WANT_TIM
  1068.         t += 21L;
  1069. #endif
  1070.     } while    (--i);
  1071.     B = C =    0;
  1072.     D = (d - ram) >> 8;
  1073.     E = d -    ram;
  1074.     H = (s - ram) >> 8;
  1075.     L = s -    ram;
  1076.     F &= ~(N_FLAG |    P_FLAG | H_FLAG);
  1077. #ifdef WANT_TIM
  1078.     return(t + 16L);
  1079. #endif
  1080. }
  1081.  
  1082. static long op_ldd()             /*    LDD */
  1083. {
  1084.     *(ram +    (D << 8) + E) =    *(ram +    (H << 8) + L);
  1085.     E--;
  1086.     if (E == 0xff)
  1087.         D--;
  1088.     L--;
  1089.     if (L == 0xff)
  1090.         H--;
  1091.     C--;
  1092.     if (C == 0xff)
  1093.         B--;
  1094.     (B | C)    ? (F |=    P_FLAG)    : (F &=    ~P_FLAG);
  1095.     F &= ~(N_FLAG |    H_FLAG);
  1096. #ifdef WANT_TIM
  1097.     return(16L);
  1098. #endif
  1099. }
  1100.  
  1101. static long op_lddr()             /*    LDDR */
  1102. {
  1103. #ifdef WANT_TIM
  1104.     register long t    = -21L;
  1105. #endif
  1106.     register WORD i;
  1107.     register BYTE *s, *d;
  1108.  
  1109.     i = (B << 8) + C;
  1110.     d = ram    + (D <<    8) + E;
  1111.     s = ram    + (H <<    8) + L;
  1112.     do {
  1113.         *d-- = *s--;
  1114. #ifdef WANT_TIM
  1115.         t += 21L;
  1116. #endif
  1117.     } while    (--i);
  1118.     B = C =    0;
  1119.     D = (d - ram) >> 8;
  1120.     E = d -    ram;
  1121.     H = (s - ram) >> 8;
  1122.     L = s -    ram;
  1123.     F &= ~(N_FLAG |    P_FLAG | H_FLAG);
  1124. #ifdef WANT_TIM
  1125.     return(t + 16L);
  1126. #endif
  1127. }
  1128.  
  1129. static long op_cpi()             /*    CPI */
  1130. {            /* H flag isn't set here ! */
  1131.     register BYTE i;
  1132.  
  1133.     i = A -    *(ram +    (H << 8) + L);
  1134.     L++;
  1135.     if (!L)
  1136.         H++;
  1137.     C--;
  1138.     if (C == 0xff)
  1139.         B--;
  1140.     F |= N_FLAG;
  1141.     (B | C)    ? (F |=    P_FLAG)    : (F &=    ~P_FLAG);
  1142.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1143.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1144. #ifdef WANT_TIM
  1145.     return(16L);
  1146. #endif
  1147. }
  1148.  
  1149. static long op_cpir()             /*    CPIR */
  1150. {            /* H flag isn't set here ! */
  1151. #ifdef WANT_TIM
  1152.     register long t    = -21L;
  1153. #endif
  1154.     register BYTE *s;
  1155.     register BYTE d;
  1156.     register WORD i;
  1157.  
  1158.     i = (B << 8) + C;
  1159.     s = ram    + (H <<    8) + L;
  1160.     do {
  1161.         d = A -    *s++;
  1162. #ifdef WANT_TIM
  1163.         t += 21L;
  1164. #endif
  1165.     } while    (--i &&    d);
  1166.     F |= N_FLAG;
  1167.     B = i >> 8;
  1168.     C = i;
  1169.     H = (s - ram) >> 8;
  1170.     L = s -    ram;
  1171.     (i) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  1172.     (d) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1173.     (d & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1174. #ifdef WANT_TIM
  1175.     return(t + 16L);
  1176. #endif
  1177. }
  1178.  
  1179. static long op_cpdop()             /*    CPD */
  1180. {            /* H flag isn't set here ! */
  1181.     register BYTE i;
  1182.  
  1183.     i = A -    *(ram +    (H << 8) + L);
  1184.     L--;
  1185.     if (L == 0xff)
  1186.         H--;
  1187.     C--;
  1188.     if (C == 0xff)
  1189.         B--;
  1190.     F |= N_FLAG;
  1191.     (B | C)    ? (F |=    P_FLAG)    : (F &=    ~P_FLAG);
  1192.     (i) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1193.     (i & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1194. #ifdef WANT_TIM
  1195.     return(16L);
  1196. #endif
  1197. }
  1198.  
  1199. static long op_cpdr()             /*    CPDR */
  1200. {            /* H flag isn't set here ! */
  1201. #ifdef WANT_TIM
  1202.     register long t    = -21L;
  1203. #endif
  1204.     register BYTE *s;
  1205.     register BYTE d;
  1206.     register WORD i;
  1207.  
  1208.     i = (B << 8) + C;
  1209.     s = ram    + (H <<    8) + L;
  1210.     do {
  1211.         d = A -    *s--;
  1212. #ifdef WANT_TIM
  1213.         t += 21L;
  1214. #endif
  1215.     } while    (--i &&    d);
  1216.     F |= N_FLAG;
  1217.     B = i >> 8;
  1218.     C = i;
  1219.     H = (s - ram) >> 8;
  1220.     L = s -    ram;
  1221.     (i) ? (F |= P_FLAG) : (F &= ~P_FLAG);
  1222.     (d) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1223.     (d & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1224. #ifdef WANT_TIM
  1225.     return(t + 16L);
  1226. #endif
  1227. }
  1228.  
  1229. static long op_oprld()             /*    RLD (HL) */
  1230. {
  1231.     register int i,    j;
  1232.  
  1233.     i = *(ram + (H << 8) + L);
  1234.     j = A &    0x0f;
  1235.     A = (A & 0xf0) | (i >> 4);
  1236.     i = (i << 4) | j;
  1237.     *(ram +    (H << 8) + L) =    i;
  1238.     F &= ~(H_FLAG |    N_FLAG);
  1239.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1240.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1241.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1242. #ifdef WANT_TIM
  1243.     return(18L);
  1244. #endif
  1245. }
  1246.  
  1247. static long op_oprrd()             /*    RRD (HL) */
  1248. {
  1249.     register int i,    j;
  1250.  
  1251.     i = *(ram + (H << 8) + L);
  1252.     j = A &    0x0f;
  1253.     A = (A & 0xf0) | (i & 0x0f);
  1254.     i = (i >> 4) | (j << 4);
  1255.     *(ram +    (H << 8) + L) =    i;
  1256.     F &= ~(H_FLAG |    N_FLAG);
  1257.     (A) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  1258.     (A & 128) ? (F |= S_FLAG) : (F &= ~S_FLAG);
  1259.     (parrity[A]) ? (F &= ~P_FLAG) :    (F |= P_FLAG);
  1260. #ifdef WANT_TIM
  1261.     return(18L);
  1262. #endif
  1263. }
  1264.  
  1265.