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 / SIM7.C < prev    next >
C/C++ Source or Header  |  2000-06-30  |  15KB  |  706 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.1)
  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 4 byte opcodes
  23.  *    starting with 0xfd 0xcb
  24.  */
  25.  
  26. #include "sim.h"
  27. #include "simglb.h"
  28.  
  29. long op_fdcb_handel()
  30. {
  31.     long trap_fdcb();
  32.     long op_tb0iyd(), op_tb1iyd(), op_tb2iyd(), op_tb3iyd();
  33.     long op_tb4iyd(), op_tb5iyd(), op_tb6iyd(), op_tb7iyd();
  34.     long op_rb0iyd(), op_rb1iyd(), op_rb2iyd(), op_rb3iyd();
  35.     long op_rb4iyd(), op_rb5iyd(), op_rb6iyd(), op_rb7iyd();
  36.     long op_sb0iyd(), op_sb1iyd(), op_sb2iyd(), op_sb3iyd();
  37.     long op_sb4iyd(), op_sb5iyd(), op_sb6iyd(), op_sb7iyd();
  38.     long op_rlciyd(), op_rrciyd(), op_rliyd(), op_rriyd();
  39.     long op_slaiyd(), op_sraiyd(), op_srliyd();
  40.  
  41.     static long (*op_fdcb[256]) () = {
  42.         trap_fdcb,            /* 0x00    */
  43.         trap_fdcb,            /* 0x01    */
  44.         trap_fdcb,            /* 0x02    */
  45.         trap_fdcb,            /* 0x03    */
  46.         trap_fdcb,            /* 0x04    */
  47.         trap_fdcb,            /* 0x05    */
  48.         op_rlciyd,            /* 0x06    */
  49.         trap_fdcb,            /* 0x07    */
  50.         trap_fdcb,            /* 0x08    */
  51.         trap_fdcb,            /* 0x09    */
  52.         trap_fdcb,            /* 0x0a    */
  53.         trap_fdcb,            /* 0x0b    */
  54.         trap_fdcb,            /* 0x0c    */
  55.         trap_fdcb,            /* 0x0d    */
  56.         op_rrciyd,            /* 0x0e    */
  57.         trap_fdcb,            /* 0x0f    */
  58.         trap_fdcb,            /* 0x10    */
  59.         trap_fdcb,            /* 0x11    */
  60.         trap_fdcb,            /* 0x12    */
  61.         trap_fdcb,            /* 0x13    */
  62.         trap_fdcb,            /* 0x14    */
  63.         trap_fdcb,            /* 0x15    */
  64.         op_rliyd,            /* 0x16    */
  65.         trap_fdcb,            /* 0x17    */
  66.         trap_fdcb,            /* 0x18    */
  67.         trap_fdcb,            /* 0x19    */
  68.         trap_fdcb,            /* 0x1a    */
  69.         trap_fdcb,            /* 0x1b    */
  70.         trap_fdcb,            /* 0x1c    */
  71.         trap_fdcb,            /* 0x1d    */
  72.         op_rriyd,            /* 0x1e    */
  73.         trap_fdcb,            /* 0x1f    */
  74.         trap_fdcb,            /* 0x20    */
  75.         trap_fdcb,            /* 0x21    */
  76.         trap_fdcb,            /* 0x22    */
  77.         trap_fdcb,            /* 0x23    */
  78.         trap_fdcb,            /* 0x24    */
  79.         trap_fdcb,            /* 0x25    */
  80.         op_slaiyd,            /* 0x26    */
  81.         trap_fdcb,            /* 0x27    */
  82.         trap_fdcb,            /* 0x28    */
  83.         trap_fdcb,            /* 0x29    */
  84.         trap_fdcb,            /* 0x2a    */
  85.         trap_fdcb,            /* 0x2b    */
  86.         trap_fdcb,            /* 0x2c    */
  87.         trap_fdcb,            /* 0x2d    */
  88.         op_sraiyd,            /* 0x2e    */
  89.         trap_fdcb,            /* 0x2f    */
  90.         trap_fdcb,            /* 0x30    */
  91.         trap_fdcb,            /* 0x31    */
  92.         trap_fdcb,            /* 0x32    */
  93.         trap_fdcb,            /* 0x33    */
  94.         trap_fdcb,            /* 0x34    */
  95.         trap_fdcb,            /* 0x35    */
  96.         trap_fdcb,            /* 0x36    */
  97.         trap_fdcb,            /* 0x37    */
  98.         trap_fdcb,            /* 0x38    */
  99.         trap_fdcb,            /* 0x39    */
  100.         trap_fdcb,            /* 0x3a    */
  101.         trap_fdcb,            /* 0x3b    */
  102.         trap_fdcb,            /* 0x3c    */
  103.         trap_fdcb,            /* 0x3d    */
  104.         op_srliyd,            /* 0x3e    */
  105.         trap_fdcb,            /* 0x3f    */
  106.         trap_fdcb,            /* 0x40    */
  107.         trap_fdcb,            /* 0x41    */
  108.         trap_fdcb,            /* 0x42    */
  109.         trap_fdcb,            /* 0x43    */
  110.         trap_fdcb,            /* 0x44    */
  111.         trap_fdcb,            /* 0x45    */
  112.         op_tb0iyd,            /* 0x46    */
  113.         trap_fdcb,            /* 0x47    */
  114.         trap_fdcb,            /* 0x48    */
  115.         trap_fdcb,            /* 0x49    */
  116.         trap_fdcb,            /* 0x4a    */
  117.         trap_fdcb,            /* 0x4b    */
  118.         trap_fdcb,            /* 0x4c    */
  119.         trap_fdcb,            /* 0x4d    */
  120.         op_tb1iyd,            /* 0x4e    */
  121.         trap_fdcb,            /* 0x4f    */
  122.         trap_fdcb,            /* 0x50    */
  123.         trap_fdcb,            /* 0x51    */
  124.         trap_fdcb,            /* 0x52    */
  125.         trap_fdcb,            /* 0x53    */
  126.         trap_fdcb,            /* 0x54    */
  127.         trap_fdcb,            /* 0x55    */
  128.         op_tb2iyd,            /* 0x56    */
  129.         trap_fdcb,            /* 0x57    */
  130.         trap_fdcb,            /* 0x58    */
  131.         trap_fdcb,            /* 0x59    */
  132.         trap_fdcb,            /* 0x5a    */
  133.         trap_fdcb,            /* 0x5b    */
  134.         trap_fdcb,            /* 0x5c    */
  135.         trap_fdcb,            /* 0x5d    */
  136.         op_tb3iyd,            /* 0x5e    */
  137.         trap_fdcb,            /* 0x5f    */
  138.         trap_fdcb,            /* 0x60    */
  139.         trap_fdcb,            /* 0x61    */
  140.         trap_fdcb,            /* 0x62    */
  141.         trap_fdcb,            /* 0x63    */
  142.         trap_fdcb,            /* 0x64    */
  143.         trap_fdcb,            /* 0x65    */
  144.         op_tb4iyd,            /* 0x66    */
  145.         trap_fdcb,            /* 0x67    */
  146.         trap_fdcb,            /* 0x68    */
  147.         trap_fdcb,            /* 0x69    */
  148.         trap_fdcb,            /* 0x6a    */
  149.         trap_fdcb,            /* 0x6b    */
  150.         trap_fdcb,            /* 0x6c    */
  151.         trap_fdcb,            /* 0x6d    */
  152.         op_tb5iyd,            /* 0x6e    */
  153.         trap_fdcb,            /* 0x6f    */
  154.         trap_fdcb,            /* 0x70    */
  155.         trap_fdcb,            /* 0x71    */
  156.         trap_fdcb,            /* 0x72    */
  157.         trap_fdcb,            /* 0x73    */
  158.         trap_fdcb,            /* 0x74    */
  159.         trap_fdcb,            /* 0x75    */
  160.         op_tb6iyd,            /* 0x76    */
  161.         trap_fdcb,            /* 0x77    */
  162.         trap_fdcb,            /* 0x78    */
  163.         trap_fdcb,            /* 0x79    */
  164.         trap_fdcb,            /* 0x7a    */
  165.         trap_fdcb,            /* 0x7b    */
  166.         trap_fdcb,            /* 0x7c    */
  167.         trap_fdcb,            /* 0x7d    */
  168.         op_tb7iyd,            /* 0x7e    */
  169.         trap_fdcb,            /* 0x7f    */
  170.         trap_fdcb,            /* 0x80    */
  171.         trap_fdcb,            /* 0x81    */
  172.         trap_fdcb,            /* 0x82    */
  173.         trap_fdcb,            /* 0x83    */
  174.         trap_fdcb,            /* 0x84    */
  175.         trap_fdcb,            /* 0x85    */
  176.         op_rb0iyd,            /* 0x86    */
  177.         trap_fdcb,            /* 0x87    */
  178.         trap_fdcb,            /* 0x88    */
  179.         trap_fdcb,            /* 0x89    */
  180.         trap_fdcb,            /* 0x8a    */
  181.         trap_fdcb,            /* 0x8b    */
  182.         trap_fdcb,            /* 0x8c    */
  183.         trap_fdcb,            /* 0x8d    */
  184.         op_rb1iyd,            /* 0x8e    */
  185.         trap_fdcb,            /* 0x8f    */
  186.         trap_fdcb,            /* 0x90    */
  187.         trap_fdcb,            /* 0x91    */
  188.         trap_fdcb,            /* 0x92    */
  189.         trap_fdcb,            /* 0x93    */
  190.         trap_fdcb,            /* 0x94    */
  191.         trap_fdcb,            /* 0x95    */
  192.         op_rb2iyd,            /* 0x96    */
  193.         trap_fdcb,            /* 0x97    */
  194.         trap_fdcb,            /* 0x98    */
  195.         trap_fdcb,            /* 0x99    */
  196.         trap_fdcb,            /* 0x9a    */
  197.         trap_fdcb,            /* 0x9b    */
  198.         trap_fdcb,            /* 0x9c    */
  199.         trap_fdcb,            /* 0x9d    */
  200.         op_rb3iyd,            /* 0x9e    */
  201.         trap_fdcb,            /* 0x9f    */
  202.         trap_fdcb,            /* 0xa0    */
  203.         trap_fdcb,            /* 0xa1    */
  204.         trap_fdcb,            /* 0xa2    */
  205.         trap_fdcb,            /* 0xa3    */
  206.         trap_fdcb,            /* 0xa4    */
  207.         trap_fdcb,            /* 0xa5    */
  208.         op_rb4iyd,            /* 0xa6    */
  209.         trap_fdcb,            /* 0xa7    */
  210.         trap_fdcb,            /* 0xa8    */
  211.         trap_fdcb,            /* 0xa9    */
  212.         trap_fdcb,            /* 0xaa    */
  213.         trap_fdcb,            /* 0xab    */
  214.         trap_fdcb,            /* 0xac    */
  215.         trap_fdcb,            /* 0xad    */
  216.         op_rb5iyd,            /* 0xae    */
  217.         trap_fdcb,            /* 0xaf    */
  218.         trap_fdcb,            /* 0xb0    */
  219.         trap_fdcb,            /* 0xb1    */
  220.         trap_fdcb,            /* 0xb2    */
  221.         trap_fdcb,            /* 0xb3    */
  222.         trap_fdcb,            /* 0xb4    */
  223.         trap_fdcb,            /* 0xb5    */
  224.         op_rb6iyd,            /* 0xb6    */
  225.         trap_fdcb,            /* 0xb7    */
  226.         trap_fdcb,            /* 0xb8    */
  227.         trap_fdcb,            /* 0xb9    */
  228.         trap_fdcb,            /* 0xba    */
  229.         trap_fdcb,            /* 0xbb    */
  230.         trap_fdcb,            /* 0xbc    */
  231.         trap_fdcb,            /* 0xbd    */
  232.         op_rb7iyd,            /* 0xbe    */
  233.         trap_fdcb,            /* 0xbf    */
  234.         trap_fdcb,            /* 0xc0    */
  235.         trap_fdcb,            /* 0xc1    */
  236.         trap_fdcb,            /* 0xc2    */
  237.         trap_fdcb,            /* 0xc3    */
  238.         trap_fdcb,            /* 0xc4    */
  239.         trap_fdcb,            /* 0xc5    */
  240.         op_sb0iyd,            /* 0xc6    */
  241.         trap_fdcb,            /* 0xc7    */
  242.         trap_fdcb,            /* 0xc8    */
  243.         trap_fdcb,            /* 0xc9    */
  244.         trap_fdcb,            /* 0xca    */
  245.         trap_fdcb,            /* 0xcb    */
  246.         trap_fdcb,            /* 0xcc    */
  247.         trap_fdcb,            /* 0xcd    */
  248.         op_sb1iyd,            /* 0xce    */
  249.         trap_fdcb,            /* 0xcf    */
  250.         trap_fdcb,            /* 0xd0    */
  251.         trap_fdcb,            /* 0xd1    */
  252.         trap_fdcb,            /* 0xd2    */
  253.         trap_fdcb,            /* 0xd3    */
  254.         trap_fdcb,            /* 0xd4    */
  255.         trap_fdcb,            /* 0xd5    */
  256.         op_sb2iyd,            /* 0xd6    */
  257.         trap_fdcb,            /* 0xd7    */
  258.         trap_fdcb,            /* 0xd8    */
  259.         trap_fdcb,            /* 0xd9    */
  260.         trap_fdcb,            /* 0xda    */
  261.         trap_fdcb,            /* 0xdb    */
  262.         trap_fdcb,            /* 0xdc    */
  263.         trap_fdcb,            /* 0xdd    */
  264.         op_sb3iyd,            /* 0xde    */
  265.         trap_fdcb,            /* 0xdf    */
  266.         trap_fdcb,            /* 0xe0    */
  267.         trap_fdcb,            /* 0xe1    */
  268.         trap_fdcb,            /* 0xe2    */
  269.         trap_fdcb,            /* 0xe3    */
  270.         trap_fdcb,            /* 0xe4    */
  271.         trap_fdcb,            /* 0xe5    */
  272.         op_sb4iyd,            /* 0xe6    */
  273.         trap_fdcb,            /* 0xe7    */
  274.         trap_fdcb,            /* 0xe8    */
  275.         trap_fdcb,            /* 0xe9    */
  276.         trap_fdcb,            /* 0xea    */
  277.         trap_fdcb,            /* 0xeb    */
  278.         trap_fdcb,            /* 0xec    */
  279.         trap_fdcb,            /* 0xed    */
  280.         op_sb5iyd,            /* 0xee    */
  281.         trap_fdcb,            /* 0xef    */
  282.         trap_fdcb,            /* 0xf0    */
  283.         trap_fdcb,            /* 0xf1    */
  284.         trap_fdcb,            /* 0xf2    */
  285.         trap_fdcb,            /* 0xf3    */
  286.         trap_fdcb,            /* 0xf4    */
  287.         trap_fdcb,            /* 0xf5    */
  288.         op_sb6iyd,            /* 0xf6    */
  289.         trap_fdcb,            /* 0xf7    */
  290.         trap_fdcb,            /* 0xf8    */
  291.         trap_fdcb,            /* 0xf9    */
  292.         trap_fdcb,            /* 0xfa    */
  293.         trap_fdcb,            /* 0xfb    */
  294.         trap_fdcb,            /* 0xfc    */
  295.         trap_fdcb,            /* 0xfd    */
  296.         op_sb7iyd,            /* 0xfe    */
  297.         trap_fdcb            /* 0xff    */
  298.     };
  299.  
  300.     register int d;
  301. #ifdef WANT_TIM
  302.     register long t;
  303. #endif
  304.  
  305.     d = (char) *PC++;
  306.  
  307. #ifdef WANT_PCC
  308.         if (PC > ram + 65535)    /* correct PC overrun */
  309.             PC = ram;
  310. #endif
  311.  
  312. #ifdef WANT_TIM
  313.     t = (*op_fdcb[*PC++]) (d);    /* execute next opcode */
  314. #else
  315.     (*op_fdcb[*PC++]) (d);
  316. #endif
  317.  
  318. #ifdef WANT_PCC
  319.         if (PC > ram + 65535)    /* again correct PC overrun */
  320.             PC = ram;
  321. #endif
  322.  
  323. #ifdef WANT_TIM
  324.     return(t);
  325. #endif
  326. }
  327.  
  328. /*
  329.  *    This function traps all illegal opcodes following the
  330.  *    initial 0xfd 0xcb of a 4 byte opcode.
  331.  */
  332. static long trap_fdcb()
  333. {
  334.     cpu_error = OPTRAP4;
  335.     cpu_state = STOPPED;
  336. #ifdef WANT_TIM
  337.     return(0L);
  338. #endif
  339. }
  340.  
  341. static long op_tb0iyd(data)         /*    BIT 0,(IY+d) */
  342. register int data;
  343. {
  344.     F &= ~N_FLAG;
  345.     F |= H_FLAG;
  346.     (*(ram + IY + data) & 1) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  347. #ifdef WANT_TIM
  348.     return(20L);
  349. #endif
  350. }
  351.  
  352. static long op_tb1iyd(data)         /*    BIT 1,(IY+d) */
  353. register int data;
  354. {
  355.     F &= ~N_FLAG;
  356.     F |= H_FLAG;
  357.     (*(ram + IY + data) & 2) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  358. #ifdef WANT_TIM
  359.     return(20L);
  360. #endif
  361. }
  362.  
  363. static long op_tb2iyd(data)         /*    BIT 2,(IY+d) */
  364. register int data;
  365. {
  366.     F &= ~N_FLAG;
  367.     F |= H_FLAG;
  368.     (*(ram + IY + data) & 4) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  369. #ifdef WANT_TIM
  370.     return(20L);
  371. #endif
  372. }
  373.  
  374. static long op_tb3iyd(data)         /*    BIT 3,(IY+d) */
  375. register int data;
  376. {
  377.     F &= ~N_FLAG;
  378.     F |= H_FLAG;
  379.     (*(ram + IY + data) & 8) ? (F &= ~Z_FLAG) : (F |= Z_FLAG);
  380. #ifdef WANT_TIM
  381.     return(20L);
  382. #endif
  383. }
  384.  
  385. static long op_tb4iyd(data)         /*    BIT 4,(IY+d) */
  386. register int data;
  387. {
  388.     F &= ~N_FLAG;
  389.     F |= H_FLAG;
  390.     (*(ram + IY + data) & 16) ? (F &= ~Z_FLAG) : (F    |= Z_FLAG);
  391. #ifdef WANT_TIM
  392.     return(20L);
  393. #endif
  394. }
  395.  
  396. static long op_tb5iyd(data)         /*    BIT 5,(IY+d) */
  397. register int data;
  398. {
  399.     F &= ~N_FLAG;
  400.     F |= H_FLAG;
  401.     (*(ram + IY + data) & 32) ? (F &= ~Z_FLAG) : (F    |= Z_FLAG);
  402. #ifdef WANT_TIM
  403.     return(20L);
  404. #endif
  405. }
  406.  
  407. static long op_tb6iyd(data)         /*    BIT 6,(IY+d) */
  408. register int data;
  409. {
  410.     F &= ~N_FLAG;
  411.     F |= H_FLAG;
  412.     (*(ram + IY + data) & 64) ? (F &= ~Z_FLAG) : (F    |= Z_FLAG);
  413. #ifdef WANT_TIM
  414.     return(20L);
  415. #endif
  416. }
  417.  
  418. static long op_tb7iyd(data)         /*    BIT 7,(IY+d) */
  419. register int data;
  420. {
  421.     F &= ~N_FLAG;
  422.     F |= H_FLAG;
  423.     (*(ram + IY + data) & 128) ? (F    &= ~Z_FLAG) : (F |= Z_FLAG);
  424. #ifdef WANT_TIM
  425.     return(20L);
  426. #endif
  427. }
  428.  
  429. static long op_rb0iyd(data)         /*    RES 0,(IY+d) */
  430. register int data;
  431. {
  432.     *(ram +    IY + data) &= ~1;
  433. #ifdef WANT_TIM
  434.     return(23L);
  435. #endif
  436. }
  437.  
  438. static long op_rb1iyd(data)         /*    RES 1,(IY+d) */
  439. register int data;
  440. {
  441.     *(ram +    IY + data) &= ~2;
  442. #ifdef WANT_TIM
  443.     return(23L);
  444. #endif
  445. }
  446.  
  447. static long op_rb2iyd(data)         /*    RES 2,(IY+d) */
  448. register int data;
  449. {
  450.     *(ram +    IY + data) &= ~4;
  451. #ifdef WANT_TIM
  452.     return(23L);
  453. #endif
  454. }
  455.  
  456. static long op_rb3iyd(data)         /*    RES 3,(IY+d) */
  457. register int data;
  458. {
  459.     *(ram +    IY + data) &= ~8;
  460. #ifdef WANT_TIM
  461.     return(23L);
  462. #endif
  463. }
  464.  
  465. static long op_rb4iyd(data)         /*    RES 4,(IY+d) */
  466. register int data;
  467. {
  468.     *(ram +    IY + data) &= ~16;
  469. #ifdef WANT_TIM
  470.     return(23L);
  471. #endif
  472. }
  473.  
  474. static long op_rb5iyd(data)         /*    RES 5,(IY+d) */
  475. register int data;
  476. {
  477.     *(ram +    IY + data) &= ~32;
  478. #ifdef WANT_TIM
  479.     return(23L);
  480. #endif
  481. }
  482.  
  483. static long op_rb6iyd(data)         /*    RES 6,(IY+d) */
  484. register int data;
  485. {
  486.     *(ram +    IY + data) &= ~64;
  487. #ifdef WANT_TIM
  488.     return(23L);
  489. #endif
  490. }
  491.  
  492. static long op_rb7iyd(data)         /*    RES 7,(IY+d) */
  493. register int data;
  494. {
  495.     *(ram +    IY + data) &= ~128;
  496. #ifdef WANT_TIM
  497.     return(23L);
  498. #endif
  499. }
  500.  
  501. static long op_sb0iyd(data)         /*    SET 0,(IY+d) */
  502. register int data;
  503. {
  504.     *(ram +    IY + data) |= 1;
  505. #ifdef WANT_TIM
  506.     return(23L);
  507. #endif
  508. }
  509.  
  510. static long op_sb1iyd(data)         /*    SET 1,(IY+d) */
  511. register int data;
  512. {
  513.     *(ram +    IY + data) |= 2;
  514. #ifdef WANT_TIM
  515.     return(23L);
  516. #endif
  517. }
  518.  
  519. static long op_sb2iyd(data)         /*    SET 2,(IY+d) */
  520. register int data;
  521. {
  522.     *(ram +    IY + data) |= 4;
  523. #ifdef WANT_TIM
  524.     return(23L);
  525. #endif
  526. }
  527.  
  528. static long op_sb3iyd(data)         /*    SET 3,(IY+d) */
  529. register int data;
  530. {
  531.     *(ram +    IY + data) |= 8;
  532. #ifdef WANT_TIM
  533.     return(23L);
  534. #endif
  535. }
  536.  
  537. static long op_sb4iyd(data)         /*    SET 4,(IY+d) */
  538. register int data;
  539. {
  540.     *(ram +    IY + data) |= 16;
  541. #ifdef WANT_TIM
  542.     return(23L);
  543. #endif
  544. }
  545.  
  546. static long op_sb5iyd(data)         /*    SET 5,(IY+d) */
  547. register int data;
  548. {
  549.     *(ram +    IY + data) |= 32;
  550. #ifdef WANT_TIM
  551.     return(23L);
  552. #endif
  553. }
  554.  
  555. static long op_sb6iyd(data)         /*    SET 6,(IY+d) */
  556. register int data;
  557. {
  558.     *(ram +    IY + data) |= 64;
  559. #ifdef WANT_TIM
  560.     return(23L);
  561. #endif
  562. }
  563.  
  564. static long op_sb7iyd(data)         /*    SET 7,(IY+d) */
  565. register int data;
  566. {
  567.     *(ram +    IY + data) |= 128;
  568. #ifdef WANT_TIM
  569.     return(23L);
  570. #endif
  571. }
  572.  
  573. static long op_rlciyd(data)         /*    RLC (IY+d) */
  574. register int data;
  575. {
  576.     register int i;
  577.     register BYTE *p;
  578.  
  579.     p = ram    + IY + data;
  580.     i = *p & 128;
  581.     (i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  582.     F &= ~(H_FLAG |    N_FLAG);
  583.     *p <<= 1;
  584.     if (i) *p |= 1;
  585.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  586.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  587.     (parrity[*p]) ?    (F &= ~P_FLAG) : (F |= P_FLAG);
  588. #ifdef WANT_TIM
  589.     return(23L);
  590. #endif
  591. }
  592.  
  593. static long op_rrciyd(data)         /*    RRC (IY+d) */
  594. register int data;
  595. {
  596.     register int i;
  597.     register BYTE *p;
  598.  
  599.     p = ram    + IY + data;
  600.     i = *p & 1;
  601.     (i) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  602.     F &= ~(H_FLAG |    N_FLAG);
  603.     *p >>= 1;
  604.     if (i) *p |= 128;
  605.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  606.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  607.     (parrity[*p]) ?    (F &= ~P_FLAG) : (F |= P_FLAG);
  608. #ifdef WANT_TIM
  609.     return(23L);
  610. #endif
  611. }
  612.  
  613. static long op_rliyd(data)         /*    RL (IY+d) */
  614. register int data;
  615. {
  616.     register int old_c_flag;
  617.     register BYTE *p;
  618.  
  619.     p = ram    + IY + data;
  620.     old_c_flag = F & C_FLAG;
  621.     (*p & 128) ? (F    |= C_FLAG) : (F    &= ~C_FLAG);
  622.     *p <<= 1;
  623.     if (old_c_flag)    *p |= 1;
  624.     F &= ~(H_FLAG |    N_FLAG);
  625.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  626.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  627.     (parrity[*p]) ?    (F &= ~P_FLAG) : (F |= P_FLAG);
  628. #ifdef WANT_TIM
  629.     return(23L);
  630. #endif
  631. }
  632.  
  633. static long op_rriyd(data)         /*    RR (IY+d) */
  634. register int data;
  635. {
  636.     register int old_c_flag;
  637.     register BYTE *p;
  638.  
  639.     old_c_flag = F & C_FLAG;
  640.     p = ram    + IY + data;
  641.     (*p & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  642.     *p >>= 1;
  643.     if (old_c_flag)    *p |= 128;
  644.     F &= ~(H_FLAG |    N_FLAG);
  645.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  646.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  647.     (parrity[*p]) ?    (F &= ~P_FLAG) : (F |= P_FLAG);
  648. #ifdef WANT_TIM
  649.     return(23L);
  650. #endif
  651. }
  652.  
  653. static long op_slaiyd(data)         /*    SLA (IY+d) */
  654. register int data;
  655. {
  656.     register BYTE *p;
  657.  
  658.     p = ram    + IY + data;
  659.     (*p & 128) ? (F    |= C_FLAG) : (F    &= ~C_FLAG);
  660.     *p <<= 1;
  661.     F &= ~(H_FLAG |    N_FLAG);
  662.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  663.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  664.     (parrity[*p]) ?    (F &= ~P_FLAG) : (F |= P_FLAG);
  665. #ifdef WANT_TIM
  666.     return(23L);
  667. #endif
  668. }
  669.  
  670. static long op_sraiyd(data)         /*    SRA (IY+d) */
  671. register int data;
  672. {
  673.     register int i;
  674.     register BYTE *p;
  675.  
  676.     p = ram    + IY + data;
  677.     i = *p & 128;
  678.     (*p & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  679.     *p >>= 1;
  680.     *p |= i;
  681.     F &= ~(H_FLAG |    N_FLAG);
  682.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  683.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  684.     (parrity[*p]) ?    (F &= ~P_FLAG) : (F |= P_FLAG);
  685. #ifdef WANT_TIM
  686.     return(23L);
  687. #endif
  688. }
  689.  
  690. static long op_srliyd(data)         /*    SRL (IY+d) */
  691. register int data;
  692. {
  693.     register BYTE *p;
  694.  
  695.     p = ram    + IY + data;
  696.     (*p & 1) ? (F |= C_FLAG) : (F &= ~C_FLAG);
  697.     *p >>= 1;
  698.     F &= ~(H_FLAG |    N_FLAG);
  699.     (*p) ? (F &= ~Z_FLAG) :    (F |= Z_FLAG);
  700.     (*p & 128) ? (F    |= S_FLAG) : (F    &= ~S_FLAG);
  701.     (parrity[*p]) ?    (F &= ~P_FLAG) : (F |= P_FLAG);
  702. #ifdef WANT_TIM
  703.     return(23L);
  704. #endif
  705. }
  706.