home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / emulator / unix / z80pack / z80asm / z80arfun.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-09  |  71.6 KB  |  3,330 lines

  1. /*
  2.  *      Z80 - Assembler
  3.  *      Copyright (C) 1987-1992 by Udo Munk
  4.  *
  5.  *    History:
  6.  *    17-SEP-1987 Development under Digital Research CP/M 2.2
  7.  *      28-JUN-1988 Switched to Unix System V.3
  8.  */
  9.  
  10. /*
  11.  *      Dieses Modul enthaelt die Funktionen zur Bearbeitung
  12.  *      aller Op-Codes
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include "z80a.h"
  17. #include "z80aglb.h"
  18.  
  19. /*
  20.  *      Diese Funktion behandelt alle Op-Codes,
  21.  *      die keine Argumente benoetigen, und
  22.  *      ein Byte Op-Code Laenge haben
  23.  */
  24. op_1b(b1, dummy)
  25. int b1, dummy;
  26. {
  27.     if (pass == 1) {                /* Pass 1 */
  28.         if (*label)
  29.             put_label();
  30.     } else                          /* Pass 2 */
  31.         ops[0] = b1;
  32.     return(1);
  33. }
  34.  
  35. /*
  36.  *      Diese Funktion behandelt alle Op-Codes,
  37.  *      die keine Argumente benoetigen, und
  38.  *      zwei Byte Op-Code Laenge haben
  39.  */
  40. op_2b(b1, b2)
  41. int b1, b2;
  42. {
  43.     if (pass == 1) {                /* Pass 1 */
  44.         if (*label)
  45.             put_label();
  46.     } else {                        /* Pass 2 */
  47.         ops[0] = b1;
  48.         ops[1] = b2;
  49.     }
  50.     return(2);
  51. }
  52.  
  53. /*
  54.  *      Diese Funktion behandelt die Op-Codes IM
  55.  */
  56. op_im()
  57. {
  58.     if (pass == 1)
  59.         if (*label)
  60.             put_label();
  61.     if (pass == 2) {
  62.         ops[0] = 0xed;
  63.         switch(eval(operand)) {
  64.         case 0:
  65.             ops[1] = 0x46;
  66.             break;
  67.         case 1:
  68.             ops[1] = 0x56;
  69.             break;
  70.         case 2:
  71.             ops[1] = 0x5e;
  72.             break;
  73.         default:
  74.             ops[1] = 0;
  75.             asmerr(E_ILLOPE);
  76.             break;
  77.         }
  78.     }
  79.     return(2);
  80. }
  81.  
  82. /*
  83.  *      Diese Funktion behandelt die Op-Codes PUSH und POP
  84.  */
  85. op_pupo(op_code, dummy)
  86. int op_code, dummy;
  87. {
  88.     register int len;
  89.  
  90.     if (pass == 1)
  91.         if (*label)
  92.             put_label();
  93.     switch (get_reg(operand)) {
  94.     case REGAF:
  95.         if (pass == 2) {
  96.             if (op_code == 1)
  97.                 ops[0] = 0xf1;     /* POP AF */
  98.             else
  99.                 ops[0] = 0xf5;     /* PUSH AF */
  100.         }
  101.         len = 1;
  102.         break;
  103.     case REGBC:
  104.         if (pass == 2) {
  105.             if (op_code == 1)
  106.                 ops[0] = 0xc1;     /* POP BC */
  107.             else
  108.                 ops[0] = 0xc5;     /* PUSH BC */
  109.         }
  110.         len = 1;
  111.         break;
  112.     case REGDE:
  113.         if (pass == 2) {
  114.             if (op_code == 1)
  115.                 ops[0] = 0xd1;     /* POP DE */
  116.             else
  117.                 ops[0] = 0xd5;     /* PUSH DE */
  118.         }
  119.         len = 1;
  120.         break;
  121.     case REGHL:
  122.         if (pass == 2) {
  123.             if (op_code == 1)
  124.                 ops[0] = 0xe1;     /* POP HL */
  125.             else
  126.                 ops[0] = 0xe5;     /* PUSH HL */
  127.         }
  128.         len = 1;
  129.         break;
  130.     case REGIX:
  131.         if (pass == 2) {
  132.             if (op_code == 1) {
  133.                 ops[0] = 0xdd;     /* POP IX */
  134.                 ops[1] = 0xe1;
  135.             } else {
  136.                 ops[0] = 0xdd;     /* PUSH IX */
  137.                 ops[1] = 0xe5;
  138.             }
  139.         }
  140.         len = 2;
  141.         break;
  142.     case REGIY:
  143.         if (pass == 2) {
  144.             if (op_code == 1) {
  145.                 ops[0] = 0xfd;     /* POP IY */
  146.                 ops[1] = 0xe1;
  147.             } else {
  148.                 ops[0] = 0xfd;     /* PUSH IY */
  149.                 ops[1] = 0xe5;
  150.             }
  151.         }
  152.         len = 2;
  153.         break;
  154.     case NOOPERA:                   /* Operand fehlt */
  155.         len = 1;
  156.         ops[0] = 0;
  157.         asmerr(E_MISOPE);
  158.         break;
  159.     default:                        /* ungueltiger Operand */
  160.         len = 1;
  161.         ops[0] = 0;
  162.         asmerr(E_ILLOPE);
  163.     }
  164.     return(len);
  165. }
  166.  
  167. /*
  168.  *      Diese Funktion behandelt den EX Op-Code
  169.  */
  170. op_ex()
  171. {
  172.     register int len;
  173.  
  174.     if (pass == 1)
  175.         if (*label)
  176.             put_label();
  177.     if (strncmp(operand, "DE,HL", 5) == 0) {
  178.         ops[0] = 0xeb;
  179.         len = 1;
  180.     } else if (strncmp(operand, "AF,AF'", 7) == 0) {
  181.         ops[0] = 0x08;
  182.         len = 1;
  183.     } else if (strncmp(operand, "(SP),HL", 7) == 0) {
  184.         ops[0] = 0xe3;
  185.         len = 1;
  186.     } else if (strncmp(operand, "(SP),IX", 7) == 0) {
  187.         ops[0] = 0xdd;
  188.         ops[1] = 0xe3;
  189.         len = 2;
  190.     } else if (strncmp(operand, "(SP),IY", 7) == 0) {
  191.         ops[0] = 0xfd;
  192.         ops[1] = 0xe3;
  193.         len = 2;
  194.     } else {
  195.         ops[0] = 0;
  196.         len = 1;
  197.         asmerr(E_ILLOPE);
  198.     }
  199.     return(len);
  200. }
  201.  
  202. /*
  203.  *      Diese Funktion behandelt den CALL Op-Code
  204.  */
  205. op_call()
  206. {
  207.     char *strchr();
  208.     register char *p1, *p2;
  209.     register int i;
  210.  
  211.     if (pass == 1) {        /* PASS 1 */
  212.         if (*label)
  213.             put_label();
  214.     } else {                /* PASS 2 */
  215.         p1 = operand;
  216.         p2 = tmp;
  217.         while (*p1 != ',' && *p1 != '\0')
  218.             *p2++ = *p1++;
  219.         *p2 = '\0';
  220.         switch (get_reg(tmp)) {
  221.         case REGC:                      /* CALL C,nn */
  222.             i = eval(strchr(operand, ',') + 1);
  223.             ops[0] = 0xdc;
  224.             ops[1] = i & 0xff;
  225.             ops[2] = i >> 8;
  226.             break;
  227.         case FLGNC:                     /* CALL NC,nn */
  228.             i = eval(strchr(operand, ',') + 1);
  229.             ops[0] = 0xd4;
  230.             ops[1] = i & 0xff;
  231.             ops[2] = i >> 8;
  232.             break;
  233.         case FLGZ:                      /* CALL Z,nn */
  234.             i = eval(strchr(operand, ',') + 1);
  235.             ops[0] = 0xcc;
  236.             ops[1] = i & 0xff;
  237.             ops[2] = i >> 8;
  238.             break;
  239.         case FLGNZ:                     /* CALL NZ,nn */
  240.             i = eval(strchr(operand, ',') + 1);
  241.             ops[0] = 0xc4;
  242.             ops[1] = i & 0xff;
  243.             ops[2] = i >> 8;
  244.             break;
  245.         case FLGPE:                     /* CALL PE,nn */
  246.             i = eval(strchr(operand, ',') + 1);
  247.             ops[0] = 0xec;
  248.             ops[1] = i & 0xff;
  249.             ops[2] = i >> 8;
  250.             break;
  251.         case FLGPO:                     /* CALL PO,nn */
  252.             i = eval(strchr(operand, ',') + 1);
  253.             ops[0] = 0xe4;
  254.             ops[1] = i & 0xff;
  255.             ops[2] = i >> 8;
  256.             break;
  257.         case FLGM:                      /* CALL M,nn */
  258.             i = eval(strchr(operand, ',') + 1);
  259.             ops[0] = 0xfc;
  260.             ops[1] = i & 0xff;
  261.             ops[2] = i >> 8;
  262.             break;
  263.         case FLGP:                      /* CALL P,nn */
  264.             i = eval(strchr(operand, ',') + 1);
  265.             ops[0] = 0xf4;
  266.             ops[1] = i & 0xff;
  267.             ops[2] = i >> 8;
  268.             break;
  269.         case NOREG:                     /* CALL nn */
  270.             i = eval(operand);
  271.             ops[0] = 0xcd;
  272.             ops[1] = i & 0xff;
  273.             ops[2] = i >> 8;
  274.             break;
  275.         case NOOPERA:                   /* Operand fehlt */
  276.             ops[0] = 0;
  277.             ops[1] = 0;
  278.             ops[2] = 0;
  279.             asmerr(E_MISOPE);
  280.             break;
  281.         default:                        /* ungueltiger Operand */
  282.             ops[0] = 0;
  283.             ops[1] = 0;
  284.             ops[2] = 0;
  285.             asmerr(E_ILLOPE);
  286.         }
  287.     }
  288.     return(3);
  289. }
  290.  
  291. /*
  292.  *      Diese Funktion behandelt den RST Op-Code
  293.  */
  294. op_rst()
  295. {
  296.     register int op;
  297.  
  298.     if (pass == 1) {        /* PASS 1 */
  299.         if (*label)
  300.             put_label();
  301.     } else {                /* PASS 2 */
  302.         op = eval(operand);
  303.         if ((op / 8 > 7) || (op % 8 != 0)) {
  304.             ops[0] = 0;
  305.             asmerr(E_VALOUT);
  306.         } else
  307.             ops[0] = 0xc7 + op;
  308.     }
  309.     return(1);
  310. }
  311.  
  312. /*
  313.  *      Diese Funktion behandelt den RET Op-Code
  314.  */
  315. op_ret()
  316. {
  317.     if (pass == 1) {        /* PASS 1 */
  318.         if (*label)
  319.             put_label();
  320.     } else {                /* PASS 2 */
  321.         switch (get_reg(operand)) {
  322.         case NOOPERA:                   /* RET */
  323.             ops[0] = 0xc9;
  324.             break;
  325.         case REGC:                      /* RET C */
  326.             ops[0] = 0xd8;
  327.             break;
  328.         case FLGNC:                     /* RET NC */
  329.             ops[0] = 0xd0;
  330.             break;
  331.         case FLGZ:                      /* RET Z */
  332.             ops[0] = 0xc8;
  333.             break;
  334.         case FLGNZ:                     /* RET NZ */
  335.             ops[0] = 0xc0;
  336.             break;
  337.         case FLGPE:                     /* RET PE */
  338.             ops[0] = 0xe8;
  339.             break;
  340.         case FLGPO:                     /* RET PO */
  341.             ops[0] = 0xe0;
  342.             break;
  343.         case FLGM:                      /* RET M */
  344.             ops[0] = 0xf8;
  345.             break;
  346.         case FLGP:                      /* RET P */
  347.             ops[0] = 0xf0;
  348.             break;
  349.         default:                        /* ungueltiger Operand */
  350.             ops[0] = 0;
  351.             asmerr(E_ILLOPE);
  352.         }
  353.     }
  354.     return(1);
  355. }
  356.  
  357. /*
  358.  *      Diese Funktion behandelt den JP Op-Code
  359.  */
  360. op_jp()
  361. {
  362.     char *strchr();
  363.     register char *p1, *p2;
  364.     register int i, len;
  365.  
  366.     if (pass == 1)
  367.         if (*label)
  368.             put_label();
  369.     p1 = operand;
  370.     p2 = tmp;
  371.     while (*p1 != ',' && *p1 != '\0')
  372.         *p2++ = *p1++;
  373.     *p2 = '\0';
  374.     switch (get_reg(tmp)) {
  375.     case REGC:                      /* JP C,nn */
  376.         len = 3;
  377.         if (pass == 2) {
  378.             i = eval(strchr(operand, ',') + 1);
  379.             ops[0] = 0xda;
  380.             ops[1] = i & 0xff;
  381.             ops[2] = i >> 8;
  382.         }
  383.         break;
  384.     case FLGNC:                     /* JP NC,nn */
  385.         len = 3;
  386.         if (pass == 2) {
  387.             i = eval(strchr(operand, ',') + 1);
  388.             ops[0] = 0xd2;
  389.             ops[1] = i & 0xff;
  390.             ops[2] = i >> 8;
  391.         }
  392.         break;
  393.     case FLGZ:                      /* JP Z,nn */
  394.         len = 3;
  395.         if (pass == 2) {
  396.             i = eval(strchr(operand, ',') + 1);
  397.             ops[0] = 0xca;
  398.             ops[1] = i & 0xff;
  399.             ops[2] = i >> 8;
  400.         }
  401.         break;
  402.     case FLGNZ:                     /* JP NZ,nn */
  403.         len = 3;
  404.         if (pass == 2) {
  405.             i = eval(strchr(operand, ',') + 1);
  406.             ops[0] = 0xc2;
  407.             ops[1] = i & 0xff;
  408.             ops[2] = i >> 8;
  409.         }
  410.         break;
  411.     case FLGPE:                     /* JP PE,nn */
  412.         len = 3;
  413.         if (pass == 2) {
  414.             i = eval(strchr(operand, ',') + 1);
  415.             ops[0] = 0xea;
  416.             ops[1] = i & 0xff;
  417.             ops[2] = i >> 8;
  418.         }
  419.         break;
  420.     case FLGPO:                     /* JP PO,nn */
  421.         len = 3;
  422.         if (pass == 2) {
  423.             i = eval(strchr(operand, ',') + 1);
  424.             ops[0] = 0xe2;
  425.             ops[1] = i & 0xff;
  426.             ops[2] = i >> 8;
  427.         }
  428.         break;
  429.     case FLGM:                      /* JP M,nn */
  430.         len = 3;
  431.         if (pass == 2) {
  432.             i = eval(strchr(operand, ',') + 1);
  433.             ops[0] = 0xfa;
  434.             ops[1] = i & 0xff;
  435.             ops[2] = i >> 8;
  436.         }
  437.         break;
  438.     case FLGP:                      /* JP P,nn */
  439.         len = 3;
  440.         if (pass == 2) {
  441.             i = eval(strchr(operand, ',') + 1);
  442.             ops[0] = 0xf2;
  443.             ops[1] = i & 0xff;
  444.             ops[2] = i >> 8;
  445.         }
  446.         break;
  447.     case REGIHL:                    /* JP (HL) */
  448.         ops[0] = 0xe9;
  449.         len = 1;
  450.         break;
  451.     case REGIIX:                    /* JP (IX) */
  452.         ops[0] = 0xdd;
  453.         ops[1] = 0xe9;
  454.         len = 2;
  455.         break;
  456.     case REGIIY:                    /* JP (IY) */
  457.         ops[0] = 0xfd;
  458.         ops[1] = 0xe9;
  459.         len = 2;
  460.         break;
  461.     case NOREG:                     /* JP nn */
  462.         len = 3;
  463.         if (pass == 2) {
  464.             i = eval(operand);
  465.             ops[0] = 0xc3;
  466.             ops[1] = i & 0xff;
  467.             ops[2] = i >> 8;
  468.         }
  469.         break;
  470.     case NOOPERA:                   /* Operand fehlt */
  471.         ops[0] = 0;
  472.         len = 1;
  473.         asmerr(E_MISOPE);
  474.         break;
  475.     default:                        /* ungueltiger Operand */
  476.         ops[0] = 0;
  477.         len = 1;
  478.         asmerr(E_ILLOPE);
  479.     }
  480.     return(len);
  481. }
  482.  
  483. /*
  484.  *      Diese Funktion behandelt den JR Op-Code
  485.  */
  486. op_jr()
  487. {
  488.     char *strchr();
  489.     register char *p1, *p2;
  490.  
  491.     if (pass == 1) {        /* PASS 1 */
  492.         if (*label)
  493.             put_label();
  494.     } else {                /* PASS 2 */
  495.         p1 = operand;
  496.         p2 = tmp;
  497.         while (*p1 != ',' && *p1 != '\0')
  498.             *p2++ = *p1++;
  499.         *p2 = '\0';
  500.         switch (get_reg(tmp)) {
  501.         case REGC:                      /* JR C,n */
  502.             ops[0] = 0x38;
  503.             ops[1] = chk_v2(eval(strchr(operand, ',') + 1) - pc - 2);
  504.             break;
  505.         case FLGNC:                     /* JR NC,n */
  506.             ops[0] = 0x30;
  507.             ops[1] = chk_v2(eval(strchr(operand, ',') + 1) - pc - 2);
  508.             break;
  509.         case FLGZ:                      /* JR Z,n */
  510.             ops[0] = 0x28;
  511.             ops[1] = chk_v2(eval(strchr(operand, ',') + 1) - pc - 2);
  512.             break;
  513.         case FLGNZ:                     /* JR NZ,n */
  514.             ops[0] = 0x20;
  515.             ops[1] = chk_v2(eval(strchr(operand, ',') + 1) - pc - 2);
  516.             break;
  517.         case NOREG:                     /* JR n */
  518.             ops[0] = 0x18;
  519.             ops[1] = chk_v2(eval(operand) - pc - 2);
  520.             break;
  521.         case NOOPERA:                   /* Operand fehlt */
  522.             ops[0] = 0;
  523.             ops[1] = 0;
  524.             asmerr(E_MISOPE);
  525.             break;
  526.         default:                        /* ungueltiger Operand */
  527.             ops[0] = 0;
  528.             ops[1] = 0;
  529.             asmerr(E_ILLOPE);
  530.         }
  531.     }
  532.     return(2);
  533. }
  534.  
  535. /*
  536.  *      Diese Funktion behandelt den DJNZ Op-Code
  537.  */
  538. op_djnz()
  539. {
  540.     if (pass == 1) {        /* PASS 1 */
  541.         if (*label)
  542.             put_label();
  543.     } else {                /* PASS 2 */
  544.         ops[0] = 0x10;
  545.         ops[1] = chk_v2(eval(operand) - pc - 2);
  546.     }
  547.     return(2);
  548. }
  549.  
  550. /*
  551.  *      Diese Funktion behandelt die LD Op-Codes
  552.  */
  553. op_ld()
  554. {
  555.     register int len;
  556.     register char *p1, *p2;
  557.     char *get_second();
  558.  
  559.     if (pass == 1)
  560.         if (*label)
  561.             put_label();
  562.     p1 = operand;
  563.     p2 = tmp;
  564.     while (*p1 != ',' && *p1 != '\0')
  565.         *p2++ = *p1++;
  566.     *p2 = '\0';
  567.     switch (get_reg(tmp)) {
  568.     case REGA:                      /* LD A,? */
  569.         len = lda();
  570.         break;
  571.     case REGB:                      /* LD B,? */
  572.         len = ldb();
  573.         break;
  574.     case REGC:                      /* LD C,? */
  575.         len = ldc();
  576.         break;
  577.     case REGD:                      /* LD D,? */
  578.         len = ldd();
  579.         break;
  580.     case REGE:                      /* LD E,? */
  581.         len = lde();
  582.         break;
  583.     case REGH:                      /* LD H,? */
  584.         len = ldh();
  585.         break;
  586.     case REGL:                      /* LD L,? */
  587.         len = ldl();
  588.         break;
  589.     case REGI:                      /* LD I,A */
  590.         if (get_reg(get_second(operand)) == REGA) {
  591.             len = 2;
  592.             ops[0] = 0xed;
  593.             ops[1] = 0x47;
  594.             break;
  595.         }
  596.         len = 1;
  597.         ops[0] = 0;
  598.         asmerr(E_ILLOPE);
  599.         break;
  600.     case REGR:                      /* LD R,A */
  601.         if (get_reg(get_second(operand)) == REGA) {
  602.             len = 2;
  603.             ops[0] = 0xed;
  604.             ops[1] = 0x4f;
  605.             break;
  606.         }
  607.         len = 1;
  608.         ops[0] = 0;
  609.         asmerr(E_ILLOPE);
  610.         break;
  611.     case REGBC:                     /* LD BC,? */
  612.         len = ldbc();
  613.         break;
  614.     case REGDE:                     /* LD DE,? */
  615.         len = ldde();
  616.         break;
  617.     case REGHL:                     /* LD HL,? */
  618.         len = ldhl();
  619.         break;
  620.     case REGIX:                     /* LD IX,? */
  621.         len = ldix();
  622.         break;
  623.     case REGIY:                     /* LD IY,? */
  624.         len = ldiy();
  625.         break;
  626.     case REGSP:                     /* LD SP,? */
  627.         len = ldsp();
  628.         break;
  629.     case REGIHL:                    /* LD (HL),? */
  630.         len = ldihl();
  631.         break;
  632.     case REGIBC:                    /* LD (BC),A */
  633.         if (get_reg(get_second(operand)) == REGA) {
  634.             len = 1;
  635.             ops[0] = 0x02;
  636.             break;
  637.         }
  638.         len = 1;
  639.         ops[0] = 0;
  640.         asmerr(E_ILLOPE);
  641.         break;
  642.     case REGIDE:                    /* LD (DE),A */
  643.         if (get_reg(get_second(operand)) == REGA) {
  644.             len = 1;
  645.             ops[0] = 0x12;
  646.             break;
  647.         }
  648.         len = 1;
  649.         ops[0] = 0;
  650.         asmerr(E_ILLOPE);
  651.         break;
  652.     case NOOPERA:                   /* Operand fehlt */
  653.         len = 1;
  654.         ops[0] = 0;
  655.         asmerr(E_MISOPE);
  656.         break;
  657.     default:                        /* ungueltiger Operand */
  658.         if (strncmp(operand, "(IX+", 4) == 0)
  659.             len = ldiix();  /* LD (IX+d),? */
  660.         else if (strncmp(operand, "(IY+", 4) == 0)
  661.             len = ldiiy();  /* LD (IY+d),? */
  662.         else if (*operand == '(')
  663.             len = ldinn();  /* LD (nn),? */
  664.         else {
  665.             len = 1;
  666.             ops[0] = 0;
  667.             asmerr(E_ILLOPE);
  668.         }
  669.     }
  670.     return(len);
  671. }
  672.  
  673. /*
  674.  *      Die Funktion behandelt alle Op-Codes LD A,?
  675.  */
  676. lda()
  677. {
  678.     char *get_second(), *strchr();
  679.     register int op;
  680.     register int i, len;
  681.     register char *p;
  682.  
  683.     p = get_second(operand);
  684.     switch (op = get_reg(p)) {
  685.     case REGA:                      /* LD A,A */
  686.     case REGB:                      /* LD A,B */
  687.     case REGC:                      /* LD A,C */
  688.     case REGD:                      /* LD A,D */
  689.     case REGE:                      /* LD A,E */
  690.     case REGH:                      /* LD A,H */
  691.     case REGL:                      /* LD A,L */
  692.     case REGIHL:                    /* LD A,(HL) */
  693.         len = 1;
  694.         ops[0] = 0x78 + op;
  695.         break;
  696.     case REGI:                      /* LD A,I */
  697.         len = 2;
  698.         ops[0] = 0xed;
  699.         ops[1] = 0x57;
  700.         break;
  701.     case REGR:                      /* LD A,R */
  702.         len = 2;
  703.         ops[0] = 0xed;
  704.         ops[1] = 0x5f;
  705.         break;
  706.     case REGIBC:                    /* LD A,(BC) */
  707.         len = 1;
  708.         ops[0] = 0x0a;
  709.         break;
  710.     case REGIDE:                    /* LD A,(DE) */
  711.         len = 1;
  712.         ops[0] = 0x1a;
  713.         break;
  714.     case NOREG:                     /* Operand ist kein Register */
  715.         if (strncmp(p, "(IX+", 4) == 0) { /* LD A,(IX+d) */
  716.             len = 3;
  717.             if (pass == 2) {
  718.                 ops[0] = 0xdd;
  719.                 ops[1] = 0x7e;
  720.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  721.             }
  722.             break;
  723.         }
  724.         if (strncmp(p, "(IY+", 4) == 0) { /* LD A,(IY+d) */
  725.             len = 3;
  726.             if (pass == 2) {
  727.                 ops[0] = 0xfd;
  728.                 ops[1] = 0x7e;
  729.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  730.             }
  731.             break;
  732.         }
  733.         if (*p == '(' && *(p + strlen(p) - 1) == ')') {
  734.             len = 3;                /* LD A,(nn) */
  735.             if (pass == 2) {
  736.                 i = calc_val(p + 1);
  737.                 ops[0] = 0x3a;
  738.                 ops[1] = i & 255;
  739.                 ops[2] = i >> 8;
  740.             }
  741.             break;
  742.         }
  743.         len = 2;                        /* LD A,n */
  744.         if (pass == 2) {
  745.             ops[0] = 0x3e;
  746.             ops[1] = chk_v1(eval(p));
  747.         }
  748.         break;
  749.     case NOOPERA:                   /* Operand fehlt */
  750.         len = 1;
  751.         ops[0] = 0;
  752.         asmerr(E_MISOPE);
  753.         break;
  754.     default:                        /* ungueltiger Operand */
  755.         len = 1;
  756.         ops[0] = 0;
  757.         asmerr(E_ILLOPE);
  758.     }
  759.     return(len);
  760. }
  761.  
  762. /*
  763.  *      Die Funktion behandelt alle Op-Codes LD B,?
  764.  */
  765. ldb()
  766. {
  767.     char *get_second(), *strchr();
  768.     register int op;
  769.     register int len;
  770.     register char *p;
  771.  
  772.     p = get_second(operand);
  773.     switch (op = get_reg(p)) {
  774.     case REGA:                      /* LD B,A */
  775.     case REGB:                      /* LD B,B */
  776.     case REGC:                      /* LD B,C */
  777.     case REGD:                      /* LD B,D */
  778.     case REGE:                      /* LD B,E */
  779.     case REGH:                      /* LD B,H */
  780.     case REGL:                      /* LD B,L */
  781.     case REGIHL:                    /* LD B,(HL) */
  782.         len = 1;
  783.         ops[0] = 0x40 + op;
  784.         break;
  785.     case NOREG:                     /* Operand ist kein Register */
  786.         if (strncmp(p, "(IX+", 4) == 0) { /* LD B,(IX+d) */
  787.             len = 3;
  788.             if (pass == 2) {
  789.                 ops[0] = 0xdd;
  790.                 ops[1] = 0x46;
  791.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  792.             }
  793.             break;
  794.         }
  795.         if (strncmp(p, "(IY+", 4) == 0) { /* LD B,(IY+d) */
  796.             len = 3;
  797.             if (pass == 2) {
  798.                 ops[0] = 0xfd;
  799.                 ops[1] = 0x46;
  800.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  801.             }
  802.             break;
  803.         }
  804.         len = 2;                        /* LD B,n */
  805.         if (pass == 2) {
  806.             ops[0] = 0x06;
  807.             ops[1] = chk_v1(eval(p));
  808.         }
  809.         break;
  810.     case NOOPERA:                   /* Operand fehlt */
  811.         len = 1;
  812.         ops[0] = 0;
  813.         asmerr(E_MISOPE);
  814.         break;
  815.     default:                        /* ungueltiger Operand */
  816.         len = 1;
  817.         ops[0] = 0;
  818.         asmerr(E_ILLOPE);
  819.     }
  820.     return(len);
  821. }
  822.  
  823. /*
  824.  *      Die Funktion behandelt alle Op-Codes LD C,?
  825.  */
  826. ldc()
  827. {
  828.     char *get_second(), *strchr();
  829.     register int op;
  830.     register int len;
  831.     register char *p;
  832.  
  833.     p = get_second(operand);
  834.     switch (op = get_reg(p)) {
  835.     case REGA:                      /* LD C,A */
  836.     case REGB:                      /* LD C,B */
  837.     case REGC:                      /* LD C,C */
  838.     case REGD:                      /* LD C,D */
  839.     case REGE:                      /* LD C,E */
  840.     case REGH:                      /* LD C,H */
  841.     case REGL:                      /* LD C,L */
  842.     case REGIHL:                    /* LD C,(HL) */
  843.         len = 1;
  844.         ops[0] = 0x48 + op;
  845.         break;
  846.     case NOREG:                     /* Operand ist kein Register */
  847.         if (strncmp(p, "(IX+", 4) == 0) { /* LD C,(IX+d) */
  848.             len = 3;
  849.             if (pass == 2) {
  850.                 ops[0] = 0xdd;
  851.                 ops[1] = 0x4e;
  852.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  853.             }
  854.             break;
  855.         }
  856.         if (strncmp(p, "(IY+", 4) == 0) { /* LD C,(IY+d) */
  857.             len = 3;
  858.             if (pass == 2) {
  859.                 ops[0] = 0xfd;
  860.                 ops[1] = 0x4e;
  861.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  862.             }
  863.             break;
  864.         }
  865.         len = 2;                        /* LD C,n */
  866.         if (pass == 2) {
  867.             ops[0] = 0x0e;
  868.             ops[1] = chk_v1(eval(p));
  869.         }
  870.         break;
  871.     case NOOPERA:                   /* Operand fehlt */
  872.         len = 1;
  873.         ops[0] = 0;
  874.         asmerr(E_MISOPE);
  875.         break;
  876.     default:                        /* ungueltiger Operand */
  877.         len = 1;
  878.         ops[0] = 0;
  879.         asmerr(E_ILLOPE);
  880.     }
  881.     return(len);
  882. }
  883.  
  884. /*
  885.  *      Die Funktion behandelt alle Op-Codes LD D,?
  886.  */
  887. ldd()
  888. {
  889.     char *get_second(), *strchr();
  890.     register int op;
  891.     register int len;
  892.     register char *p;
  893.  
  894.     p = get_second(operand);
  895.     switch (op = get_reg(p)) {
  896.     case REGA:                      /* LD D,A */
  897.     case REGB:                      /* LD D,B */
  898.     case REGC:                      /* LD D,C */
  899.     case REGD:                      /* LD D,D */
  900.     case REGE:                      /* LD D,E */
  901.     case REGH:                      /* LD D,H */
  902.     case REGL:                      /* LD D,L */
  903.     case REGIHL:                    /* LD D,(HL) */
  904.         len = 1;
  905.         ops[0] = 0x50 + op;
  906.         break;
  907.     case NOREG:                     /* Operand ist kein Register */
  908.         if (strncmp(p, "(IX+", 4) == 0) { /* LD D,(IX+d) */
  909.             len = 3;
  910.             if (pass == 2) {
  911.                 ops[0] = 0xdd;
  912.                 ops[1] = 0x56;
  913.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  914.             }
  915.             break;
  916.         }
  917.         if (strncmp(p, "(IY+", 4) == 0) { /* LD D,(IY+d) */
  918.             len = 3;
  919.             if (pass == 2) {
  920.                 ops[0] = 0xfd;
  921.                 ops[1] = 0x56;
  922.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  923.             }
  924.             break;
  925.         }
  926.         len = 2;                        /* LD D,n */
  927.         if (pass == 2) {
  928.             ops[0] = 0x16;
  929.             ops[1] = chk_v1(eval(p));
  930.         }
  931.         break;
  932.     case NOOPERA:                   /* Operand fehlt */
  933.         len = 1;
  934.         ops[0] = 0;
  935.         asmerr(E_MISOPE);
  936.         break;
  937.     default:                        /* ungueltiger Operand */
  938.         len = 1;
  939.         ops[0] = 0;
  940.         asmerr(E_ILLOPE);
  941.     }
  942.     return(len);
  943. }
  944.  
  945. /*
  946.  *      Die Funktion behandelt alle Op-Codes LD E,?
  947.  */
  948. lde()
  949. {
  950.     char *get_second(), *strchr();
  951.     register int op;
  952.     register int len;
  953.     register char *p;
  954.  
  955.     p = get_second(operand);
  956.     switch (op = get_reg(p)) {
  957.     case REGA:                      /* LD E,A */
  958.     case REGB:                      /* LD E,B */
  959.     case REGC:                      /* LD E,C */
  960.     case REGD:                      /* LD E,D */
  961.     case REGE:                      /* LD E,E */
  962.     case REGH:                      /* LD E,H */
  963.     case REGL:                      /* LD E,L */
  964.     case REGIHL:                    /* LD E,(HL) */
  965.         len = 1;
  966.         ops[0] = 0x58 + op;
  967.         break;
  968.     case NOREG:                     /* Operand ist kein Register */
  969.         if (strncmp(p, "(IX+", 4) == 0) { /* LD E,(IX+d) */
  970.             len = 3;
  971.             if (pass == 2) {
  972.                 ops[0] = 0xdd;
  973.                 ops[1] = 0x5e;
  974.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  975.             }
  976.             break;
  977.         }
  978.         if (strncmp(p, "(IY+", 4) == 0) { /* LD E,(IY+d) */
  979.             len = 3;
  980.             if (pass == 2) {
  981.                 ops[0] = 0xfd;
  982.                 ops[1] = 0x5e;
  983.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  984.             }
  985.             break;
  986.         }
  987.         len = 2;                        /* LD E,n */
  988.         if (pass == 2) {
  989.             ops[0] = 0x1e;
  990.             ops[1] = chk_v1(eval(p));
  991.         }
  992.         break;
  993.     case NOOPERA:                   /* Operand fehlt */
  994.         len = 1;
  995.         ops[0] = 0;
  996.         asmerr(E_MISOPE);
  997.         break;
  998.     default:                        /* ungueltiger Operand */
  999.         len = 1;
  1000.         ops[0] = 0;
  1001.         asmerr(E_ILLOPE);
  1002.     }
  1003.     return(len);
  1004. }
  1005.  
  1006. /*
  1007.  *      Die Funktion behandelt alle Op-Codes LD H,?
  1008.  */
  1009. ldh()
  1010. {
  1011.     char *get_second(), *strchr();
  1012.     register int op;
  1013.     register int len;
  1014.     register char *p;
  1015.  
  1016.     p = get_second(operand);
  1017.     switch (op = get_reg(p)) {
  1018.     case REGA:                      /* LD H,A */
  1019.     case REGB:                      /* LD H,B */
  1020.     case REGC:                      /* LD H,C */
  1021.     case REGD:                      /* LD H,D */
  1022.     case REGE:                      /* LD H,E */
  1023.     case REGH:                      /* LD H,H */
  1024.     case REGL:                      /* LD H,L */
  1025.     case REGIHL:                    /* LD H,(HL) */
  1026.         len = 1;
  1027.         ops[0] = 0x60 + op;
  1028.         break;
  1029.     case NOREG:                     /* Operand ist kein Register */
  1030.         if (strncmp(p, "(IX+", 4) == 0) { /* LD H,(IX+d) */
  1031.             len = 3;
  1032.             if (pass == 2) {
  1033.                 ops[0] = 0xdd;
  1034.                 ops[1] = 0x66;
  1035.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1036.             }
  1037.             break;
  1038.         }
  1039.         if (strncmp(p, "(IY+", 4) == 0) { /* LD H,(IY+d) */
  1040.             len = 3;
  1041.             if (pass == 2) {
  1042.                 ops[0] = 0xfd;
  1043.                 ops[1] = 0x66;
  1044.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1045.             }
  1046.             break;
  1047.         }
  1048.         len = 2;                        /* LD H,n */
  1049.         if (pass == 2) {
  1050.             ops[0] = 0x26;
  1051.             ops[1] = chk_v1(eval(p));
  1052.         }
  1053.         break;
  1054.     case NOOPERA:                   /* Operand fehlt */
  1055.         len = 1;
  1056.         ops[0] = 0;
  1057.         asmerr(E_MISOPE);
  1058.         break;
  1059.     default:                        /* ungueltiger Operand */
  1060.         len = 1;
  1061.         ops[0] = 0;
  1062.         asmerr(E_ILLOPE);
  1063.     }
  1064.     return(len);
  1065. }
  1066.  
  1067. /*
  1068.  *      Die Funktion behandelt alle Op-Codes LD L,?
  1069.  */
  1070. ldl()
  1071. {
  1072.     char *get_second(), *strchr();
  1073.     register int op;
  1074.     register int len;
  1075.     register char *p;
  1076.  
  1077.     p = get_second(operand);
  1078.     switch (op = get_reg(p)) {
  1079.     case REGA:                      /* LD L,A */
  1080.     case REGB:                      /* LD L,B */
  1081.     case REGC:                      /* LD L,C */
  1082.     case REGD:                      /* LD L,D */
  1083.     case REGE:                      /* LD L,E */
  1084.     case REGH:                      /* LD L,H */
  1085.     case REGL:                      /* LD L,L */
  1086.     case REGIHL:                    /* LD L,(HL) */
  1087.         len = 1;
  1088.         ops[0] = 0x68 + op;
  1089.         break;
  1090.     case NOREG:                     /* Operand ist kein Register */
  1091.         if (strncmp(p, "(IX+", 4) == 0) { /* LD L,(IX+d) */
  1092.             len = 3;
  1093.             if (pass == 2) {
  1094.                 ops[0] = 0xdd;
  1095.                 ops[1] = 0x6e;
  1096.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1097.             }
  1098.             break;
  1099.         }
  1100.         if (strncmp(p, "(IY+", 4) == 0) { /* LD L,(IY+d) */
  1101.             len = 3;
  1102.             if (pass == 2) {
  1103.                 ops[0] = 0xfd;
  1104.                 ops[1] = 0x6e;
  1105.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1106.             }
  1107.             break;
  1108.         }
  1109.         len = 2;                        /* LD L,n */
  1110.         if (pass == 2) {
  1111.             ops[0] = 0x2e;
  1112.             ops[1] = chk_v1(eval(p));
  1113.         }
  1114.         break;
  1115.     case NOOPERA:                   /* Operand fehlt */
  1116.         len = 1;
  1117.         ops[0] = 0;
  1118.         asmerr(E_MISOPE);
  1119.         break;
  1120.     default:                        /* ungueltiger Operand */
  1121.         len = 1;
  1122.         ops[0] = 0;
  1123.         asmerr(E_ILLOPE);
  1124.     }
  1125.     return(len);
  1126. }
  1127.  
  1128. /*
  1129.  *      Die Funktion behandelt alle Op-Codes LD BC,?
  1130.  */
  1131. ldbc()
  1132. {
  1133.     register int i, len;
  1134.     register char *p;
  1135.     char *get_second();
  1136.  
  1137.     p = get_second(operand);
  1138.     switch (get_reg(p)) {
  1139.     case NOREG:                     /* Operand ist kein Register */
  1140.         if (*p == '(' && *(p + strlen(p) - 1) == ')') {
  1141.             len = 4;                /* LD BC,(nn) */
  1142.             if (pass == 2) {
  1143.                 i = calc_val(p + 1);
  1144.                 ops[0] = 0xed;
  1145.                 ops[1] = 0x4b;
  1146.                 ops[2] = i & 0xff;
  1147.                 ops[3] = i >> 8;
  1148.             }
  1149.             break;
  1150.         }
  1151.         len = 3;                        /* LD BC,nn */
  1152.         if (pass == 2) {
  1153.             i = eval(p);
  1154.             ops[0] = 0x01;
  1155.             ops[1] = i & 0xff;
  1156.             ops[2] = i >> 8;
  1157.         }
  1158.         break;
  1159.     case NOOPERA:                   /* Operand fehlt */
  1160.         len = 1;
  1161.         ops[0] = 0;
  1162.         asmerr(E_MISOPE);
  1163.         break;
  1164.     default:                        /* ungueltiger Operand */
  1165.         len = 1;
  1166.         ops[0] = 0;
  1167.         asmerr(E_ILLOPE);
  1168.     }
  1169.     return(len);
  1170. }
  1171.  
  1172. /*
  1173.  *      Die Funktion behandelt alle Op-Codes LD DE,?
  1174.  */
  1175. ldde()
  1176. {
  1177.     register int i, len;
  1178.     register char *p;
  1179.     char *get_second();
  1180.  
  1181.     p = get_second(operand);
  1182.     switch (get_reg(p)) {
  1183.     case NOREG:                     /* Operand ist kein Register */
  1184.         if (*p == '(' && *(p + strlen(p) - 1) == ')') {
  1185.             len = 4;                /* LD DE,(nn) */
  1186.             if (pass == 2) {
  1187.                 i = calc_val(p + 1);
  1188.                 ops[0] = 0xed;
  1189.                 ops[1] = 0x5b;
  1190.                 ops[2] = i & 0xff;
  1191.                 ops[3] = i >> 8;
  1192.             }
  1193.             break;
  1194.         }
  1195.         len = 3;                        /* LD DE,nn */
  1196.         if (pass == 2) {
  1197.             i = eval(p);
  1198.             ops[0] = 0x11;
  1199.             ops[1] = i & 0xff;
  1200.             ops[2] = i >> 8;
  1201.         }
  1202.         break;
  1203.     case NOOPERA:                   /* Operand fehlt */
  1204.         len = 1;
  1205.         ops[0] = 0;
  1206.         asmerr(E_MISOPE);
  1207.         break;
  1208.     default:                        /* ungueltiger Operand */
  1209.         len = 1;
  1210.         ops[0] = 0;
  1211.         asmerr(E_ILLOPE);
  1212.     }
  1213.     return(len);
  1214. }
  1215.  
  1216. /*
  1217.  *      Die Funktion behandelt alle Op-Codes LD HL,?
  1218.  */
  1219. ldhl()
  1220. {
  1221.     register int i, len;
  1222.     register char *p;
  1223.     char *get_second();
  1224.  
  1225.     p = get_second(operand);
  1226.     switch (get_reg(p)) {
  1227.     case NOREG:                     /* Operand ist kein Register */
  1228.         if (*p == '(' && *(p + strlen(p) - 1) == ')') {
  1229.             len = 3;                /* LD HL,(nn) */
  1230.             if (pass == 2) {
  1231.                 i = calc_val(p + 1);
  1232.                 ops[0] = 0x2a;
  1233.                 ops[1] = i & 0xff;
  1234.                 ops[2] = i >> 8;
  1235.             }
  1236.             break;
  1237.         }
  1238.         len = 3;                        /* LD HL,nn */
  1239.         if (pass == 2) {
  1240.             i = eval(p);
  1241.             ops[0] = 0x21;
  1242.             ops[1] = i & 0xff;
  1243.             ops[2] = i >> 8;
  1244.         }
  1245.         break;
  1246.     case NOOPERA:                   /* Operand fehlt */
  1247.         len = 1;
  1248.         ops[0] = 0;
  1249.         asmerr(E_MISOPE);
  1250.         break;
  1251.     default:                        /* ungueltiger Operand */
  1252.         len = 1;
  1253.         ops[0] = 0;
  1254.         asmerr(E_ILLOPE);
  1255.     }
  1256.     return(len);
  1257. }
  1258.  
  1259. /*
  1260.  *      Die Funktion behandelt alle Op-Codes LD IX,?
  1261.  */
  1262. ldix()
  1263. {
  1264.     register int i, len;
  1265.     register char *p;
  1266.     char *get_second();
  1267.  
  1268.     p = get_second(operand);
  1269.     switch (get_reg(p)) {
  1270.     case NOREG:                     /* Operand ist kein Register */
  1271.         if (*p == '(' && *(p + strlen(p) - 1) == ')') {
  1272.             len = 4;                /* LD IX,(nn) */
  1273.             if (pass == 2) {
  1274.                 i = calc_val(p + 1);
  1275.                 ops[0] = 0xdd;
  1276.                 ops[1] = 0x2a;
  1277.                 ops[2] = i & 0xff;
  1278.                 ops[3] = i >> 8;
  1279.             }
  1280.             break;
  1281.         }
  1282.         len = 4;                        /* LD IX,nn */
  1283.         if (pass == 2) {
  1284.             i = eval(p);
  1285.             ops[0] = 0xdd;
  1286.             ops[1] = 0x21;
  1287.             ops[2] = i & 0xff;
  1288.             ops[3] = i >> 8;
  1289.         }
  1290.         break;
  1291.     case NOOPERA:                   /* Operand fehlt */
  1292.         len = 1;
  1293.         ops[0] = 0;
  1294.         asmerr(E_MISOPE);
  1295.         break;
  1296.     default:                        /* ungueltiger Operand */
  1297.         len = 1;
  1298.         ops[0] = 0;
  1299.         asmerr(E_ILLOPE);
  1300.     }
  1301.     return(len);
  1302. }
  1303.  
  1304. /*
  1305.  *      Die Funktion behandelt alle Op-Codes LD IY,?
  1306.  */
  1307. ldiy()
  1308. {
  1309.     register int i, len;
  1310.     register char *p;
  1311.     char *get_second();
  1312.  
  1313.     p = get_second(operand);
  1314.     switch (get_reg(p)) {
  1315.     case NOREG:                     /* Operand ist kein Register */
  1316.         if (*p == '(' && *(p + strlen(p) - 1) == ')') {
  1317.             len = 4;                /* LD IY,(nn) */
  1318.             if (pass == 2) {
  1319.                 i = calc_val(p + 1);
  1320.                 ops[0] = 0xfd;
  1321.                 ops[1] = 0x2a;
  1322.                 ops[2] = i & 0xff;
  1323.                 ops[3] = i >> 8;
  1324.             }
  1325.             break;
  1326.         }
  1327.         len = 4;                        /* LD IY,nn */
  1328.         if (pass == 2) {
  1329.             i = eval(p);
  1330.             ops[0] = 0xfd;
  1331.             ops[1] = 0x21;
  1332.             ops[2] = i & 0xff;
  1333.             ops[3] = i >> 8;
  1334.         }
  1335.         break;
  1336.     case NOOPERA:                   /* Operand fehlt */
  1337.         len = 1;
  1338.         ops[0] = 0;
  1339.         asmerr(E_MISOPE);
  1340.         break;
  1341.     default:                        /* ungueltiger Operand */
  1342.         len = 1;
  1343.         ops[0] = 0;
  1344.         asmerr(E_ILLOPE);
  1345.     }
  1346.     return(len);
  1347. }
  1348.  
  1349. /*
  1350.  *      Die Funktion behandelt alle Op-Codes LD SP,?
  1351.  */
  1352. ldsp()
  1353. {
  1354.     register int i, len;
  1355.     register char *p;
  1356.     char *get_second();
  1357.  
  1358.     p = get_second(operand);
  1359.     switch (get_reg(p)) {
  1360.     case REGHL:                     /* LD SP,HL */
  1361.         len = 1;
  1362.         ops[0] = 0xf9;
  1363.         break;
  1364.     case REGIX:                     /* LD SP,IX */
  1365.         len = 2;
  1366.         ops[0] = 0xdd;
  1367.         ops[1] = 0xf9;
  1368.         break;
  1369.     case REGIY:                     /* LD SP,IY */
  1370.         len = 2;
  1371.         ops[0] = 0xfd;
  1372.         ops[1] = 0xf9;
  1373.         break;
  1374.     case NOREG:                     /* Operand ist kein Register */
  1375.         if (*p == '(' && *(p + strlen(p) - 1) == ')') {
  1376.             len = 4;                /* LD SP,(nn) */
  1377.             if (pass == 2) {
  1378.                 i = calc_val(p + 1);
  1379.                 ops[0] = 0xed;
  1380.                 ops[1] = 0x7b;
  1381.                 ops[2] = i & 0xff;
  1382.                 ops[3] = i >> 8;
  1383.             }
  1384.             break;
  1385.         }
  1386.         len = 3;                        /* LD SP,nn */
  1387.         if (pass == 2) {
  1388.             i = eval(p);
  1389.             ops[0] = 0x31;
  1390.             ops[1] = i & 0xff;
  1391.             ops[2] = i >> 8;
  1392.         }
  1393.         break;
  1394.     case NOOPERA:                   /* Operand fehlt */
  1395.         len = 1;
  1396.         ops[0] = 0;
  1397.         asmerr(E_MISOPE);
  1398.         break;
  1399.     default:                        /* ungueltiger Operand */
  1400.         len = 1;
  1401.         ops[0] = 0;
  1402.         asmerr(E_ILLOPE);
  1403.     }
  1404.     return(len);
  1405. }
  1406.  
  1407. /*
  1408.  *      Die Funktion behandelt alle Op-Codes LD (HL),?
  1409.  */
  1410. ldihl()
  1411. {
  1412.     register int op;
  1413.     register int len;
  1414.     register char *p;
  1415.     char *get_second();
  1416.  
  1417.     p = get_second(operand);
  1418.     switch (op = get_reg(p)) {
  1419.     case REGA:                      /* LD (HL),A */
  1420.     case REGB:                      /* LD (HL),B */
  1421.     case REGC:                      /* LD (HL),C */
  1422.     case REGD:                      /* LD (HL),D */
  1423.     case REGE:                      /* LD (HL),E */
  1424.     case REGH:                      /* LD (HL),H */
  1425.     case REGL:                      /* LD (HL),L */
  1426.         len = 1;
  1427.         ops[0] = 0x70 + op;
  1428.         break;
  1429.     case NOREG:                     /* Operand ist kein Register */
  1430.         len = 2;                /* LD (HL),n */
  1431.         if (pass == 2) {
  1432.             ops[0] = 0x36;
  1433.             ops[1] = chk_v1(eval(p));
  1434.         }
  1435.         break;
  1436.     case NOOPERA:                   /* Operand fehlt */
  1437.         len = 1;
  1438.         ops[0] = 0;
  1439.         asmerr(E_MISOPE);
  1440.         break;
  1441.     default:                        /* ungueltiger Operand */
  1442.         len = 1;
  1443.         ops[0] = 0;
  1444.         asmerr(E_ILLOPE);
  1445.     }
  1446.     return(len);
  1447. }
  1448.  
  1449. /*
  1450.  *      Die Funktion behandelt alle Op-Codes LD (IX+d),?
  1451.  */
  1452. ldiix()
  1453. {
  1454.     char *get_second(), *strchr();
  1455.     register int op;
  1456.     register int len;
  1457.     register char *p;
  1458.  
  1459.     p = get_second(operand);
  1460.     switch (op = get_reg(p)) {
  1461.     case REGA:                      /* LD (IX+d),A */
  1462.     case REGB:                      /* LD (IX+d),B */
  1463.     case REGC:                      /* LD (IX+d),C */
  1464.     case REGD:                      /* LD (IX+d),D */
  1465.     case REGE:                      /* LD (IX+d),E */
  1466.     case REGH:                      /* LD (IX+d),H */
  1467.     case REGL:                      /* LD (IX+d),L */
  1468.         len = 3;
  1469.         if (pass == 2) {
  1470.             ops[0] = 0xdd;
  1471.             ops[1] = 0x70 + op;
  1472.             ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  1473.         }
  1474.         break;
  1475.     case NOREG:                     /* LD (IX+d),n */
  1476.         len = 4;
  1477.         if (pass == 2) {
  1478.             ops[0] = 0xdd;
  1479.             ops[1] = 0x36;
  1480.             ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  1481.             ops[3] = chk_v1(eval(p));
  1482.         }
  1483.         break;
  1484.     case NOOPERA:                   /* Operand fehlt */
  1485.         len = 1;
  1486.         ops[0] = 0;
  1487.         asmerr(E_MISOPE);
  1488.         break;
  1489.     default:                        /* ungueltiger Operand */
  1490.         len = 1;
  1491.         ops[0] = 0;
  1492.         asmerr(E_ILLOPE);
  1493.     }
  1494.     return(len);
  1495. }
  1496.  
  1497. /*
  1498.  *      Die Funktion behandelt alle Op-Codes LD (IY+d),?
  1499.  */
  1500. ldiiy()
  1501. {
  1502.     char *get_second(), *strchr();
  1503.     register int op;
  1504.     register int len;
  1505.     register char *p;
  1506.  
  1507.     p = get_second(operand);
  1508.     switch (op = get_reg(p)) {
  1509.     case REGA:                      /* LD (IY+d),A */
  1510.     case REGB:                      /* LD (IY+d),B */
  1511.     case REGC:                      /* LD (IY+d),C */
  1512.     case REGD:                      /* LD (IY+d),D */
  1513.     case REGE:                      /* LD (IY+d),E */
  1514.     case REGH:                      /* LD (IY+d),H */
  1515.     case REGL:                      /* LD (IY+d),L */
  1516.         len = 3;
  1517.         if (pass == 2) {
  1518.             ops[0] = 0xfd;
  1519.             ops[1] = 0x70 + op;
  1520.             ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  1521.         }
  1522.         break;
  1523.     case NOREG:                     /* LD (IY+d),n */
  1524.         len = 4;
  1525.         if (pass == 2) {
  1526.             ops[0] = 0xfd;
  1527.             ops[1] = 0x36;
  1528.             ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  1529.             ops[3] = chk_v1(eval(p));
  1530.         }
  1531.         break;
  1532.     case NOOPERA:                   /* Operand fehlt */
  1533.         len = 1;
  1534.         ops[0] = 0;
  1535.         asmerr(E_MISOPE);
  1536.         break;
  1537.     default:                        /* ungueltiger Operand */
  1538.         len = 1;
  1539.         ops[0] = 0;
  1540.         asmerr(E_ILLOPE);
  1541.     }
  1542.     return(len);
  1543. }
  1544.  
  1545. /*
  1546.  *      Die Funktion behandelt alle Op-Codes LD (nn),?
  1547.  */
  1548. ldinn()
  1549. {
  1550.     register int i, len;
  1551.     register char *p;
  1552.     char *get_second();
  1553.  
  1554.     p = get_second(operand);
  1555.     switch (get_reg(p)) {
  1556.     case REGA:                      /* LD (nn),A */
  1557.         len = 3;
  1558.         if (pass == 2) {
  1559.             i = calc_val(operand + 1);
  1560.             ops[0] = 0x32;
  1561.             ops[1] = i & 0xff;
  1562.             ops[2] = i >> 8;
  1563.         }
  1564.         break;
  1565.     case REGBC:                     /* LD (nn),BC */
  1566.         len = 4;
  1567.         if (pass == 2) {
  1568.             i = calc_val(operand + 1);
  1569.             ops[0] = 0xed;
  1570.             ops[1] = 0x43;
  1571.             ops[2] = i & 0xff;
  1572.             ops[3] = i >> 8;
  1573.         }
  1574.         break;
  1575.     case REGDE:                     /* LD (nn),DE */
  1576.         len = 4;
  1577.         if (pass == 2) {
  1578.             i = calc_val(operand + 1);
  1579.             ops[0] = 0xed;
  1580.             ops[1] = 0x53;
  1581.             ops[2] = i & 0xff;
  1582.             ops[3] = i >> 8;
  1583.         }
  1584.         break;
  1585.     case REGHL:                     /* LD (nn),HL */
  1586.         len = 3;
  1587.         if (pass == 2) {
  1588.             i = calc_val(operand + 1);
  1589.             ops[0] = 0x22;
  1590.             ops[1] = i & 0xff;
  1591.             ops[2] = i >> 8;
  1592.         }
  1593.         break;
  1594.     case REGSP:                     /* LD (nn),SP */
  1595.         len = 4;
  1596.         if (pass == 2) {
  1597.             i = calc_val(operand + 1);
  1598.             ops[0] = 0xed;
  1599.             ops[1] = 0x73;
  1600.             ops[2] = i & 0xff;
  1601.             ops[3] = i >> 8;
  1602.         }
  1603.         break;
  1604.     case REGIX:                     /* LD (nn),IX */
  1605.         len = 4;
  1606.         if (pass == 2) {
  1607.             i = calc_val(operand + 1);
  1608.             ops[0] = 0xdd;
  1609.             ops[1] = 0x22;
  1610.             ops[2] = i & 0xff;
  1611.             ops[3] = i >> 8;
  1612.         }
  1613.         break;
  1614.     case REGIY:                     /* LD (nn),IY */
  1615.         len = 4;
  1616.         if (pass == 2) {
  1617.             i = calc_val(operand + 1);
  1618.             ops[0] = 0xfd;
  1619.             ops[1] = 0x22;
  1620.             ops[2] = i & 0xff;
  1621.             ops[3] = i >> 8;
  1622.         }
  1623.         break;
  1624.     case NOOPERA:                   /* Operand fehlt */
  1625.         len = 1;
  1626.         ops[0] = 0;
  1627.         asmerr(E_MISOPE);
  1628.         break;
  1629.     default:                        /* ungueltiger Operand */
  1630.         len = 1;
  1631.         ops[0] = 0;
  1632.         asmerr(E_ILLOPE);
  1633.     }
  1634.     return(len);
  1635. }
  1636.  
  1637. /*
  1638.  *      Die Funktion behandelt alle Op-Codes ADD ?,?
  1639.  */
  1640. op_add()
  1641. {
  1642.     register int len;
  1643.     register char *p1, *p2;
  1644.  
  1645.     if (pass == 1)
  1646.         if (*label)
  1647.             put_label();
  1648.     p1 = operand;
  1649.     p2 = tmp;
  1650.     while (*p1 != ',' && *p1 != '\0')
  1651.         *p2++ = *p1++;
  1652.     *p2 = '\0';
  1653.     switch (get_reg(tmp)) {
  1654.     case REGA:                      /* ADD A,? */
  1655.         len = adda();
  1656.         break;
  1657.     case REGHL:                     /* ADD HL,? */
  1658.         len = addhl();
  1659.         break;
  1660.     case REGIX:                     /* ADD IX,? */
  1661.         len = addix();
  1662.         break;
  1663.     case REGIY:                     /* ADD IY,? */
  1664.         len = addiy();
  1665.         break;
  1666.     case NOOPERA:                   /* Operand fehlt */
  1667.         len = 1;
  1668.         ops[0] = 0;
  1669.         asmerr(E_MISOPE);
  1670.         break;
  1671.     default:                        /* ungueltiger Operand */
  1672.         len = 1;
  1673.         ops[0] = 0;
  1674.         asmerr(E_ILLOPE);
  1675.     }
  1676.     return(len);
  1677. }
  1678.  
  1679. /*
  1680.  *      Die Funktion behandelt alle Op-Codes ADD A,?
  1681.  */
  1682. adda()
  1683. {
  1684.     char *get_second(), *strchr();
  1685.     register int op;
  1686.     register int len;
  1687.     register char *p;
  1688.  
  1689.     p = get_second(operand);
  1690.     switch (op = get_reg(p)) {
  1691.     case REGA:                      /* ADD A,A */
  1692.     case REGB:                      /* ADD A,B */
  1693.     case REGC:                      /* ADD A,C */
  1694.     case REGD:                      /* ADD A,D */
  1695.     case REGE:                      /* ADD A,E */
  1696.     case REGH:                      /* ADD A,H */
  1697.     case REGL:                      /* ADD A,L */
  1698.     case REGIHL:                    /* ADD A,(HL) */
  1699.         len = 1;
  1700.         ops[0] = 0x80 + op;
  1701.         break;
  1702.     case NOREG:                     /* Operand ist kein Register */
  1703.         if (strncmp(p, "(IX+", 4) == 0) {
  1704.             len = 3;        /* ADD A,(IX+d) */
  1705.             if (pass == 2) {
  1706.                 ops[0] = 0xdd;
  1707.                 ops[1] = 0x86;
  1708.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1709.             }
  1710.         } else if (strncmp(p, "(IY+", 4) == 0) {
  1711.             len = 3;        /* ADD A,(IY+d) */
  1712.             if (pass == 2) {
  1713.                 ops[0] = 0xfd;
  1714.                 ops[1] = 0x86;
  1715.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1716.             }
  1717.         } else {
  1718.             len = 2;        /* ADD A,n */
  1719.             if (pass == 2) {
  1720.                 ops[0] = 0xc6;
  1721.                 ops[1] = chk_v1(eval(p));
  1722.             }
  1723.         }
  1724.         break;
  1725.     case NOOPERA:                   /* Operand fehlt */
  1726.         len = 1;
  1727.         ops[0] = 0;
  1728.         asmerr(E_MISOPE);
  1729.         break;
  1730.     default:                        /* ungueltiger Operand */
  1731.         len = 1;
  1732.         ops[0] = 0;
  1733.         asmerr(E_ILLOPE);
  1734.     }
  1735.     return(len);
  1736. }
  1737.  
  1738. /*
  1739.  *      Die Funktion behandelt alle Op-Codes ADD HL,?
  1740.  */
  1741. addhl()
  1742. {
  1743.     char *get_second();
  1744.  
  1745.     switch (get_reg(get_second(operand))) {
  1746.     case REGBC:                     /* ADD HL,BC */
  1747.         ops[0] = 0x09;
  1748.         break;
  1749.     case REGDE:                     /* ADD HL,DE */
  1750.         ops[0] = 0x19;
  1751.         break;
  1752.     case REGHL:                     /* ADD HL,HL */
  1753.         ops[0] = 0x29;
  1754.         break;
  1755.     case REGSP:                     /* ADD HL,SP */
  1756.         ops[0] = 0x39;
  1757.         break;
  1758.     case NOOPERA:                   /* Operand fehlt */
  1759.         ops[0] = 0;
  1760.         ops[1] = 0;
  1761.         asmerr(E_MISOPE);
  1762.         break;
  1763.     default:                        /* ungueltiger Operand */
  1764.         ops[0] = 0;
  1765.         ops[1] = 0;
  1766.         asmerr(E_ILLOPE);
  1767.     }
  1768.     return(1);
  1769. }
  1770.  
  1771. /*
  1772.  *      Die Funktion behandelt alle Op-Codes ADD IX,?
  1773.  */
  1774. addix()
  1775. {
  1776.     char *get_second();
  1777.  
  1778.     switch (get_reg(get_second(operand))) {
  1779.     case REGBC:                     /* ADD IX,BC */
  1780.         ops[0] = 0xdd;
  1781.         ops[1] = 0x09;
  1782.         break;
  1783.     case REGDE:                     /* ADD IX,DE */
  1784.         ops[0] = 0xdd;
  1785.         ops[1] = 0x19;
  1786.         break;
  1787.     case REGIX:                     /* ADD IX,IX */
  1788.         ops[0] = 0xdd;
  1789.         ops[1] = 0x29;
  1790.         break;
  1791.     case REGSP:                     /* ADD IX,SP */
  1792.         ops[0] = 0xdd;
  1793.         ops[1] = 0x39;
  1794.         break;
  1795.     case NOOPERA:                   /* Operand fehlt */
  1796.         ops[0] = 0;
  1797.         ops[1] = 0;
  1798.         asmerr(E_MISOPE);
  1799.         break;
  1800.     default:                        /* ungueltiger Operand */
  1801.         ops[0] = 0;
  1802.         ops[1] = 0;
  1803.         asmerr(E_ILLOPE);
  1804.     }
  1805.     return(2);
  1806. }
  1807.  
  1808. /*
  1809.  *      Die Funktion behandelt alle Op-Codes ADD IY,?
  1810.  */
  1811. addiy()
  1812. {
  1813.     char *get_second();
  1814.  
  1815.     switch (get_reg(get_second(operand))) {
  1816.     case REGBC:                     /* ADD IY,BC */
  1817.         ops[0] = 0xfd;
  1818.         ops[1] = 0x09;
  1819.         break;
  1820.     case REGDE:                     /* ADD IY,DE */
  1821.         ops[0] = 0xfd;
  1822.         ops[1] = 0x19;
  1823.         break;
  1824.     case REGIY:                     /* ADD IY,IY */
  1825.         ops[0] = 0xfd;
  1826.         ops[1] = 0x29;
  1827.         break;
  1828.     case REGSP:                     /* ADD IY,SP */
  1829.         ops[0] = 0xfd;
  1830.         ops[1] = 0x39;
  1831.         break;
  1832.     case NOOPERA:                   /* Operand fehlt */
  1833.         ops[0] = 0;
  1834.         ops[1] = 0;
  1835.         asmerr(E_MISOPE);
  1836.         break;
  1837.     default:                        /* ungueltiger Operand */
  1838.         ops[0] = 0;
  1839.         ops[1] = 0;
  1840.         asmerr(E_ILLOPE);
  1841.     }
  1842.     return(2);
  1843. }
  1844.  
  1845. /*
  1846.  *      Die Funktion behandelt alle Op-Codes ADC ?,?
  1847.  */
  1848. op_adc()
  1849. {
  1850.     register int len;
  1851.     register char *p1, *p2;
  1852.  
  1853.     if (pass == 1)
  1854.         if (*label)
  1855.             put_label();
  1856.     p1 = operand;
  1857.     p2 = tmp;
  1858.     while (*p1 != ',' && *p1 != '\0')
  1859.         *p2++ = *p1++;
  1860.     *p2 = '\0';
  1861.     switch (get_reg(tmp)) {
  1862.     case REGA:                      /* ADC A,? */
  1863.         len = adca();
  1864.         break;
  1865.     case REGHL:                     /* ADC HL,? */
  1866.         len = adchl();
  1867.         break;
  1868.     case NOOPERA:                   /* Operand fehlt */
  1869.         len = 1;
  1870.         ops[0] = 0;
  1871.         asmerr(E_MISOPE);
  1872.         break;
  1873.     default:                        /* ungueltiger Operand */
  1874.         len = 1;
  1875.         ops[0] = 0;
  1876.         asmerr(E_ILLOPE);
  1877.     }
  1878.     return(len);
  1879. }
  1880.  
  1881. /*
  1882.  *      Die Funktion behandelt alle Op-Codes ADC A,?
  1883.  */
  1884. adca()
  1885. {
  1886.     char *get_second(), *strchr();
  1887.     register int op;
  1888.     register int len;
  1889.     register char *p;
  1890.  
  1891.     p = get_second(operand);
  1892.     switch (op = get_reg(p)) {
  1893.     case REGA:                      /* ADC A,A */
  1894.     case REGB:                      /* ADC A,B */
  1895.     case REGC:                      /* ADC A,C */
  1896.     case REGD:                      /* ADC A,D */
  1897.     case REGE:                      /* ADC A,E */
  1898.     case REGH:                      /* ADC A,H */
  1899.     case REGL:                      /* ADC A,L */
  1900.     case REGIHL:                    /* ADC A,(HL) */
  1901.         len = 1;
  1902.         ops[0] = 0x88 + op;
  1903.         break;
  1904.     case NOREG:                     /* Operand ist kein Register */
  1905.         if (strncmp(p, "(IX+", 4) == 0) {
  1906.             len = 3;        /* ADC A,(IX+d) */
  1907.             if (pass == 2) {
  1908.                 ops[0] = 0xdd;
  1909.                 ops[1] = 0x8e;
  1910.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1911.             }
  1912.         } else if (strncmp(p, "(IY+", 4) == 0) {
  1913.             len = 3;        /* ADC A,(IY+d) */
  1914.             if (pass == 2) {
  1915.                 ops[0] = 0xfd;
  1916.                 ops[1] = 0x8e;
  1917.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  1918.             }
  1919.         } else {
  1920.             len = 2;        /* ADD A,n */
  1921.             if (pass == 2) {
  1922.                 ops[0] = 0xce;
  1923.                 ops[1] = chk_v1(eval(p));
  1924.             }
  1925.         }
  1926.         break;
  1927.     case NOOPERA:                   /* Operand fehlt */
  1928.         len = 1;
  1929.         ops[0] = 0;
  1930.         asmerr(E_MISOPE);
  1931.         break;
  1932.     default:                        /* ungueltiger Operand */
  1933.         len = 1;
  1934.         ops[0] = 0;
  1935.         asmerr(E_ILLOPE);
  1936.     }
  1937.     return(len);
  1938. }
  1939.  
  1940. /*
  1941.  *      Die Funktion behandelt alle Op-Codes ADC HL,?
  1942.  */
  1943. adchl()
  1944. {
  1945.     char *get_second();
  1946.  
  1947.     switch (get_reg(get_second(operand))) {
  1948.     case REGBC:                     /* ADC HL,BC */
  1949.         ops[0] = 0xed;
  1950.         ops[1] = 0x4a;
  1951.         break;
  1952.     case REGDE:                     /* ADC HL,DE */
  1953.         ops[0] = 0xed;
  1954.         ops[1] = 0x5a;
  1955.         break;
  1956.     case REGHL:                     /* ADC HL,HL */
  1957.         ops[0] = 0xed;
  1958.         ops[1] = 0x6a;
  1959.         break;
  1960.     case REGSP:                     /* ADC HL,SP */
  1961.         ops[0] = 0xed;
  1962.         ops[1] = 0x7a;
  1963.         break;
  1964.     case NOOPERA:                   /* Operand fehlt */
  1965.         ops[0] = 0;
  1966.         ops[1] = 0;
  1967.         asmerr(E_MISOPE);
  1968.         break;
  1969.     default:                        /* ungueltiger Operand */
  1970.         ops[0] = 0;
  1971.         ops[1] = 0;
  1972.         asmerr(E_ILLOPE);
  1973.     }
  1974.     return(2);
  1975. }
  1976.  
  1977. /*
  1978.  *      Die Funktion behandelt alle Op-Codes SUB ?
  1979.  */
  1980. op_sub()
  1981. {
  1982.     char *strchr();
  1983.     register int len, op;
  1984.  
  1985.     if (pass == 1)
  1986.         if (*label)
  1987.             put_label();
  1988.     switch (op = get_reg(operand)) {
  1989.     case REGA:                      /* SUB A */
  1990.     case REGB:                      /* SUB B */
  1991.     case REGC:                      /* SUB C */
  1992.     case REGD:                      /* SUB D */
  1993.     case REGE:                      /* SUB E */
  1994.     case REGH:                      /* SUB H */
  1995.     case REGL:                      /* SUB L */
  1996.     case REGIHL:                    /* SUB (HL) */
  1997.         len = 1;
  1998.         ops[0] = 0x90 + op;
  1999.         break;
  2000.     case NOREG:                     /* Operand ist kein Register */
  2001.         if (strncmp(operand, "(IX+", 4) == 0) {
  2002.             len = 3;        /* SUB (IX+d) */
  2003.             if (pass == 2) {
  2004.                 ops[0] = 0xdd;
  2005.                 ops[1] = 0x96;
  2006.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2007.             }
  2008.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2009.             len = 3;        /* SUB (IY+d) */
  2010.             if (pass == 2) {
  2011.                 ops[0] = 0xfd;
  2012.                 ops[1] = 0x96;
  2013.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2014.             }
  2015.         } else {
  2016.             len = 2;        /* SUB n */
  2017.             if (pass == 2) {
  2018.                 ops[0] = 0xd6;
  2019.                 ops[1] = chk_v1(eval(operand));
  2020.             }
  2021.         }
  2022.         break;
  2023.     case NOOPERA:                   /* Operand fehlt */
  2024.         len = 1;
  2025.         ops[0] = 0;
  2026.         asmerr(E_MISOPE);
  2027.         break;
  2028.     default:                        /* ungueltiger Operand */
  2029.         len = 1;
  2030.         ops[0] = 0;
  2031.         asmerr(E_ILLOPE);
  2032.     }
  2033.     return(len);
  2034. }
  2035.  
  2036. /*
  2037.  *      Die Funktion behandelt alle Op-Codes SBC ?,?
  2038.  */
  2039. op_sbc()
  2040. {
  2041.     register int len;
  2042.     register char *p1, *p2;
  2043.  
  2044.     if (pass == 1)
  2045.         if (*label)
  2046.             put_label();
  2047.     p1 = operand;
  2048.     p2 = tmp;
  2049.     while (*p1 != ',' && *p1 != '\0')
  2050.         *p2++ = *p1++;
  2051.     *p2 = '\0';
  2052.     switch (get_reg(tmp)) {
  2053.     case REGA:                      /* SBC A,? */
  2054.         len = sbca();
  2055.         break;
  2056.     case REGHL:                     /* SBC HL,? */
  2057.         len = sbchl();
  2058.         break;
  2059.     case NOOPERA:                   /* Operand fehlt */
  2060.         len = 1;
  2061.         ops[0] = 0;
  2062.         asmerr(E_MISOPE);
  2063.         break;
  2064.     default:                        /* ungueltiger Operand */
  2065.         len = 1;
  2066.         ops[0] = 0;
  2067.         asmerr(E_ILLOPE);
  2068.     }
  2069.     return(len);
  2070. }
  2071.  
  2072. /*
  2073.  *      Die Funktion behandelt alle Op-Codes SBC A,?
  2074.  */
  2075. sbca()
  2076. {
  2077.     char *get_second(), *strchr();
  2078.     register int op;
  2079.     register int len;
  2080.     register char *p;
  2081.  
  2082.     p = get_second(operand);
  2083.     switch (op = get_reg(p)) {
  2084.     case REGA:                      /* SBC A,A */
  2085.     case REGB:                      /* SBC A,B */
  2086.     case REGC:                      /* SBC A,C */
  2087.     case REGD:                      /* SBC A,D */
  2088.     case REGE:                      /* SBC A,E */
  2089.     case REGH:                      /* SBC A,H */
  2090.     case REGL:                      /* SBC A,L */
  2091.     case REGIHL:                    /* SBC A,(HL) */
  2092.         len = 1;
  2093.         ops[0] = 0x98 + op;
  2094.         break;
  2095.     case NOREG:                     /* Operand ist kein Register */
  2096.         if (strncmp(p, "(IX+", 4) == 0) {
  2097.             len = 3;        /* SBC A,(IX+d) */
  2098.             if (pass == 2) {
  2099.                 ops[0] = 0xdd;
  2100.                 ops[1] = 0x9e;
  2101.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  2102.             }
  2103.         } else if (strncmp(p, "(IY+", 4) == 0) {
  2104.             len = 3;        /* SBC A,(IY+d) */
  2105.             if (pass == 2) {
  2106.                 ops[0] = 0xfd;
  2107.                 ops[1] = 0x9e;
  2108.                 ops[2] = chk_v2(calc_val(strchr(p, '+') + 1));
  2109.             }
  2110.         } else {
  2111.             len = 2;        /* SBC A,n */
  2112.             if (pass == 2) {
  2113.                 ops[0] = 0xde;
  2114.                 ops[1] = chk_v1(eval(p));
  2115.             }
  2116.         }
  2117.         break;
  2118.     case NOOPERA:                   /* Operand fehlt */
  2119.         len = 1;
  2120.         ops[0] = 0;
  2121.         asmerr(E_MISOPE);
  2122.         break;
  2123.     default:                        /* ungueltiger Operand */
  2124.         len = 1;
  2125.         ops[0] = 0;
  2126.         asmerr(E_ILLOPE);
  2127.     }
  2128.     return(len);
  2129. }
  2130.  
  2131. /*
  2132.  *      Die Funktion behandelt alle Op-Codes SBC HL,?
  2133.  */
  2134. sbchl()
  2135. {
  2136.     char *get_second();
  2137.  
  2138.     switch (get_reg(get_second(operand))) {
  2139.     case REGBC:                     /* SBC HL,BC */
  2140.         ops[0] = 0xed;
  2141.         ops[1] = 0x42;
  2142.         break;
  2143.     case REGDE:                     /* SBC HL,DE */
  2144.         ops[0] = 0xed;
  2145.         ops[1] = 0x52;
  2146.         break;
  2147.     case REGHL:                     /* SBC HL,HL */
  2148.         ops[0] = 0xed;
  2149.         ops[1] = 0x62;
  2150.         break;
  2151.     case REGSP:                     /* SBC HL,SP */
  2152.         ops[0] = 0xed;
  2153.         ops[1] = 0x72;
  2154.         break;
  2155.     case NOOPERA:                   /* Operand fehlt */
  2156.         ops[0] = 0;
  2157.         ops[1] = 0;
  2158.         asmerr(E_MISOPE);
  2159.         break;
  2160.     default:                        /* ungueltiger Operand */
  2161.         ops[0] = 0;
  2162.         ops[1] = 0;
  2163.         asmerr(E_ILLOPE);
  2164.     }
  2165.     return(2);
  2166. }
  2167.  
  2168. /*
  2169.  *      Die Funktion behandelt alle Op-Codes INC ?
  2170.  */
  2171. op_inc()
  2172. {
  2173.     char *strchr();
  2174.     register int len, op;
  2175.  
  2176.     if (pass == 1)
  2177.         if (*label)
  2178.             put_label();
  2179.     switch (op = get_reg(operand)) {
  2180.     case REGA:                      /* INC A */
  2181.     case REGB:                      /* INC B */
  2182.     case REGC:                      /* INC C */
  2183.     case REGD:                      /* INC D */
  2184.     case REGE:                      /* INC E */
  2185.     case REGH:                      /* INC H */
  2186.     case REGL:                      /* INC L */
  2187.     case REGIHL:                    /* INC (HL) */
  2188.         len = 1;
  2189.         ops[0] = 0x04 + (op << 3);
  2190.         break;
  2191.     case REGBC:                     /* INC BC */
  2192.         len = 1;
  2193.         ops[0] = 0x03;
  2194.         break;
  2195.     case REGDE:                     /* INC DE */
  2196.         len = 1;
  2197.         ops[0] = 0x13;
  2198.         break;
  2199.     case REGHL:                     /* INC HL */
  2200.         len = 1;
  2201.         ops[0] = 0x23;
  2202.         break;
  2203.     case REGSP:                     /* INC SP */
  2204.         len = 1;
  2205.         ops[0] = 0x33;
  2206.         break;
  2207.     case REGIX:                     /* INC IX */
  2208.         len = 2;
  2209.         ops[0] = 0xdd;
  2210.         ops[1] = 0x23;
  2211.         break;
  2212.     case REGIY:                     /* INC IY */
  2213.         len = 2;
  2214.         ops[0] = 0xfd;
  2215.         ops[1] = 0x23;
  2216.         break;
  2217.     case NOREG:                     /* Operand ist kein Register */
  2218.         if (strncmp(operand, "(IX+", 4) == 0) {
  2219.             len = 3;        /* INC (IX+d) */
  2220.             if (pass == 2) {
  2221.                 ops[0] = 0xdd;
  2222.                 ops[1] = 0x34;
  2223.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2224.             }
  2225.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2226.             len = 3;        /* INC (IY+d) */
  2227.             if (pass == 2) {
  2228.                 ops[0] = 0xfd;
  2229.                 ops[1] = 0x34;
  2230.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2231.             }
  2232.         } else {
  2233.             len = 1;
  2234.             ops[0] = 0;
  2235.             asmerr(E_ILLOPE);
  2236.         }
  2237.         break;
  2238.     case NOOPERA:                   /* Operand fehlt */
  2239.         len = 1;
  2240.         ops[0] = 0;
  2241.         asmerr(E_MISOPE);
  2242.         break;
  2243.     default:                        /* ungueltiger Operand */
  2244.         len = 1;
  2245.         ops[0] = 0;
  2246.         asmerr(E_ILLOPE);
  2247.     }
  2248.     return(len);
  2249. }
  2250.  
  2251. /*
  2252.  *      Die Funktion behandelt alle Op-Codes DEC ?
  2253.  */
  2254. op_dec()
  2255. {
  2256.     char *strchr();
  2257.     register int len, op;
  2258.  
  2259.     if (pass == 1)
  2260.         if (*label)
  2261.             put_label();
  2262.     switch (op = get_reg(operand)) {
  2263.     case REGA:                      /* DEC A */
  2264.     case REGB:                      /* DEC B */
  2265.     case REGC:                      /* DEC C */
  2266.     case REGD:                      /* DEC D */
  2267.     case REGE:                      /* DEC E */
  2268.     case REGH:                      /* DEC H */
  2269.     case REGL:                      /* DEC L */
  2270.     case REGIHL:                    /* DEC (HL) */
  2271.         len = 1;
  2272.         ops[0] = 0x05 + (op << 3);
  2273.         break;
  2274.     case REGBC:                     /* DEC BC */
  2275.         len = 1;
  2276.         ops[0] = 0x0b;
  2277.         break;
  2278.     case REGDE:                     /* DEC DE */
  2279.         len = 1;
  2280.         ops[0] = 0x1b;
  2281.         break;
  2282.     case REGHL:                     /* DEC HL */
  2283.         len = 1;
  2284.         ops[0] = 0x2b;
  2285.         break;
  2286.     case REGSP:                     /* DEC SP */
  2287.         len = 1;
  2288.         ops[0] = 0x3b;
  2289.         break;
  2290.     case REGIX:                     /* DEC IX */
  2291.         len = 2;
  2292.         ops[0] = 0xdd;
  2293.         ops[1] = 0x2b;
  2294.         break;
  2295.     case REGIY:                     /* DEC IY */
  2296.         len = 2;
  2297.         ops[0] = 0xfd;
  2298.         ops[1] = 0x2b;
  2299.         break;
  2300.     case NOREG:                     /* Operand ist kein Register */
  2301.         if (strncmp(operand, "(IX+", 4) == 0) {
  2302.             len = 3;        /* DEC (IX+d) */
  2303.             if (pass == 2) {
  2304.                 ops[0] = 0xdd;
  2305.                 ops[1] = 0x35;
  2306.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2307.             }
  2308.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2309.             len = 3;        /* DEC (IY+d) */
  2310.             if (pass == 2) {
  2311.                 ops[0] = 0xfd;
  2312.                 ops[1] = 0x35;
  2313.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2314.             }
  2315.         } else {
  2316.             len = 1;
  2317.             ops[0] = 0;
  2318.             asmerr(E_ILLOPE);
  2319.         }
  2320.         break;
  2321.     case NOOPERA:                   /* Operand fehlt */
  2322.         len = 1;
  2323.         ops[0] = 0;
  2324.         asmerr(E_MISOPE);
  2325.         break;
  2326.     default:                        /* ungueltiger Operand */
  2327.         len = 1;
  2328.         ops[0] = 0;
  2329.         asmerr(E_ILLOPE);
  2330.     }
  2331.     return(len);
  2332. }
  2333.  
  2334. /*
  2335.  *      Die Funktion behandelt alle Op-Codes OR ?
  2336.  */
  2337. op_or()
  2338. {
  2339.     char *strchr();
  2340.     register int len, op;
  2341.  
  2342.     if (pass == 1)
  2343.         if (*label)
  2344.             put_label();
  2345.     switch (op = get_reg(operand)) {
  2346.     case REGA:                      /* OR A */
  2347.     case REGB:                      /* OR B */
  2348.     case REGC:                      /* OR C */
  2349.     case REGD:                      /* OR D */
  2350.     case REGE:                      /* OR E */
  2351.     case REGH:                      /* OR H */
  2352.     case REGL:                      /* OR L */
  2353.     case REGIHL:                    /* OR (HL) */
  2354.         len = 1;
  2355.         ops[0] = 0xb0 + op;
  2356.         break;
  2357.     case NOREG:                     /* Operand ist kein Register */
  2358.         if (strncmp(operand, "(IX+", 4) == 0) {
  2359.             len = 3;        /* OR (IX+d) */
  2360.             if (pass == 2) {
  2361.                 ops[0] = 0xdd;
  2362.                 ops[1] = 0xb6;
  2363.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2364.             }
  2365.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2366.             len = 3;        /* OR (IY+d) */
  2367.             if (pass == 2) {
  2368.                 ops[0] = 0xfd;
  2369.                 ops[1] = 0xb6;
  2370.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2371.             }
  2372.         } else {
  2373.             len = 2;        /* OR n */
  2374.             if (pass == 2) {
  2375.                 ops[0] = 0xf6;
  2376.                 ops[1] = chk_v1(eval(operand));
  2377.             }
  2378.         }
  2379.         break;
  2380.     case NOOPERA:                   /* Operand fehlt */
  2381.         len = 1;
  2382.         ops[0] = 0;
  2383.         asmerr(E_MISOPE);
  2384.         break;
  2385.     default:                        /* ungueltiger Operand */
  2386.         len = 1;
  2387.         ops[0] = 0;
  2388.         asmerr(E_ILLOPE);
  2389.     }
  2390.     return(len);
  2391. }
  2392.  
  2393. /*
  2394.  *      Die Funktion behandelt alle Op-Codes XOR ?
  2395.  */
  2396. op_xor()
  2397. {
  2398.     char *strchr();
  2399.     register int len, op;
  2400.  
  2401.     if (pass == 1)
  2402.         if (*label)
  2403.             put_label();
  2404.     switch (op = get_reg(operand)) {
  2405.     case REGA:                      /* XOR A */
  2406.     case REGB:                      /* XOR B */
  2407.     case REGC:                      /* XOR C */
  2408.     case REGD:                      /* XOR D */
  2409.     case REGE:                      /* XOR E */
  2410.     case REGH:                      /* XOR H */
  2411.     case REGL:                      /* XOR L */
  2412.     case REGIHL:                    /* XOR (HL) */
  2413.         len = 1;
  2414.         ops[0] = 0xa8 + op;
  2415.         break;
  2416.     case NOREG:                     /* Operand ist kein Register */
  2417.         if (strncmp(operand, "(IX+", 4) == 0) {
  2418.             len = 3;        /* XOR (IX+d) */
  2419.             if (pass == 2) {
  2420.                 ops[0] = 0xdd;
  2421.                 ops[1] = 0xae;
  2422.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2423.             }
  2424.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2425.             len = 3;        /* XOR (IY+d) */
  2426.             if (pass == 2) {
  2427.                 ops[0] = 0xfd;
  2428.                 ops[1] = 0xae;
  2429.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2430.             }
  2431.         } else {
  2432.             len = 2;        /* XOR n */
  2433.             if (pass == 2) {
  2434.                 ops[0] = 0xee;
  2435.                 ops[1] = chk_v1(eval(operand));
  2436.             }
  2437.         }
  2438.         break;
  2439.     case NOOPERA:                   /* Operand fehlt */
  2440.         len = 1;
  2441.         ops[0] = 0;
  2442.         asmerr(E_MISOPE);
  2443.         break;
  2444.     default:                        /* ungueltiger Operand */
  2445.         len = 1;
  2446.         ops[0] = 0;
  2447.         asmerr(E_ILLOPE);
  2448.     }
  2449.     return(len);
  2450. }
  2451.  
  2452. /*
  2453.  *      Die Funktion behandelt alle Op-Codes AND ?
  2454.  */
  2455. op_and()
  2456. {
  2457.     char *strchr();
  2458.     register int len, op;
  2459.  
  2460.     if (pass == 1)
  2461.         if (*label)
  2462.             put_label();
  2463.     switch (op = get_reg(operand)) {
  2464.     case REGA:                      /* AND A */
  2465.     case REGB:                      /* AND B */
  2466.     case REGC:                      /* AND C */
  2467.     case REGD:                      /* AND D */
  2468.     case REGE:                      /* AND E */
  2469.     case REGH:                      /* AND H */
  2470.     case REGL:                      /* AND L */
  2471.     case REGIHL:                    /* AND (HL) */
  2472.         len = 1;
  2473.         ops[0] = 0xa0 + op;
  2474.         break;
  2475.     case NOREG:                     /* Operand ist kein Register */
  2476.         if (strncmp(operand, "(IX+", 4) == 0) {
  2477.             len = 3;        /* AND (IX+d) */
  2478.             if (pass == 2) {
  2479.                 ops[0] = 0xdd;
  2480.                 ops[1] = 0xa6;
  2481.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2482.             }
  2483.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2484.             len = 3;        /* AND (IY+d) */
  2485.             if (pass == 2) {
  2486.                 ops[0] = 0xfd;
  2487.                 ops[1] = 0xa6;
  2488.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2489.             }
  2490.         } else {
  2491.             len = 2;        /* AND n */
  2492.             if (pass == 2) {
  2493.                 ops[0] = 0xe6;
  2494.                 ops[1] = chk_v1(eval(operand));
  2495.             }
  2496.         }
  2497.         break;
  2498.     case NOOPERA:                   /* Operand fehlt */
  2499.         len = 1;
  2500.         ops[0] = 0;
  2501.         asmerr(E_MISOPE);
  2502.         break;
  2503.     default:                        /* ungueltiger Operand */
  2504.         len = 1;
  2505.         ops[0] = 0;
  2506.         asmerr(E_ILLOPE);
  2507.     }
  2508.     return(len);
  2509. }
  2510.  
  2511. /*
  2512.  *      Die Funktion behandelt alle Op-Codes CP ?
  2513.  */
  2514. op_cp()
  2515. {
  2516.     char *strchr();
  2517.     register int len, op;
  2518.  
  2519.     if (pass == 1)
  2520.         if (*label)
  2521.             put_label();
  2522.     switch (op = get_reg(operand)) {
  2523.     case REGA:                      /* CP A */
  2524.     case REGB:                      /* CP B */
  2525.     case REGC:                      /* CP C */
  2526.     case REGD:                      /* CP D */
  2527.     case REGE:                      /* CP E */
  2528.     case REGH:                      /* CP H */
  2529.     case REGL:                      /* CP L */
  2530.     case REGIHL:                    /* CP (HL) */
  2531.         len = 1;
  2532.         ops[0] = 0xb8 + op;
  2533.         break;
  2534.     case NOREG:                     /* Operand ist kein Register */
  2535.         if (strncmp(operand, "(IX+", 4) == 0) {
  2536.             len = 3;        /* CP (IX+d) */
  2537.             if (pass == 2) {
  2538.                 ops[0] = 0xdd;
  2539.                 ops[1] = 0xbe;
  2540.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2541.             }
  2542.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2543.             len = 3;        /* CP (IY+d) */
  2544.             if (pass == 2) {
  2545.                 ops[0] = 0xfd;
  2546.                 ops[1] = 0xbe;
  2547.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2548.             }
  2549.         } else {
  2550.             len = 2;        /* OR n */
  2551.             if (pass == 2) {
  2552.                 ops[0] = 0xfe;
  2553.                 ops[1] = chk_v1(eval(operand));
  2554.             }
  2555.         }
  2556.         break;
  2557.     case NOOPERA:                   /* Operand fehlt */
  2558.         len = 1;
  2559.         ops[0] = 0;
  2560.         asmerr(E_MISOPE);
  2561.         break;
  2562.     default:                        /* ungueltiger Operand */
  2563.         len = 1;
  2564.         ops[0] = 0;
  2565.         asmerr(E_ILLOPE);
  2566.     }
  2567.     return(len);
  2568. }
  2569.  
  2570. /*
  2571.  *      Die Funktion behandelt den RL Op-Code
  2572.  */
  2573. op_rl()
  2574. {
  2575.     char *strchr();
  2576.     register int len, op;
  2577.  
  2578.     if (pass == 1)
  2579.         if (*label)
  2580.             put_label();
  2581.     switch (op = get_reg(operand)) {
  2582.     case REGA:                      /* RL A */
  2583.     case REGB:                      /* RL B */
  2584.     case REGC:                      /* RL C */
  2585.     case REGD:                      /* RL D */
  2586.     case REGE:                      /* RL E */
  2587.     case REGH:                      /* RL H */
  2588.     case REGL:                      /* RL L */
  2589.     case REGIHL:                    /* RL (HL) */
  2590.         len = 2;
  2591.         ops[0] = 0xcb;
  2592.         ops[1] = 0x10 + op;
  2593.         break;
  2594.     case NOREG:                     /* Operand ist kein Register */
  2595.         if (strncmp(operand, "(IX+", 4) == 0) {
  2596.             len = 4;        /* RL (IX+d) */
  2597.             if (pass == 2) {
  2598.                 ops[0] = 0xdd;
  2599.                 ops[1] = 0xcb;
  2600.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2601.                 ops[3] = 0x16;
  2602.             }
  2603.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2604.             len = 4;        /* RL (IY+d) */
  2605.             if (pass == 2) {
  2606.                 ops[0] = 0xfd;
  2607.                 ops[1] = 0xcb;
  2608.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2609.                 ops[3] = 0x16;
  2610.             }
  2611.         } else {
  2612.             len = 1;
  2613.             ops[0] = 0;
  2614.             asmerr(E_ILLOPE);
  2615.         }
  2616.         break;
  2617.     case NOOPERA:                   /* Operand fehlt */
  2618.         len = 1;
  2619.         ops[0] = 0;
  2620.         asmerr(E_MISOPE);
  2621.         break;
  2622.     default:                        /* ungueltiger Operand */
  2623.         len = 1;
  2624.         ops[0] = 0;
  2625.         asmerr(E_ILLOPE);
  2626.     }
  2627.     return(len);
  2628. }
  2629.  
  2630. /*
  2631.  *      Die Funktion behandelt den RR Op-Code
  2632.  */
  2633. op_rr()
  2634. {
  2635.     char *strchr();
  2636.     register int len, op;
  2637.  
  2638.     if (pass == 1)
  2639.         if (*label)
  2640.             put_label();
  2641.     switch (op = get_reg(operand)) {
  2642.     case REGA:                      /* RR A */
  2643.     case REGB:                      /* RR B */
  2644.     case REGC:                      /* RR C */
  2645.     case REGD:                      /* RR D */
  2646.     case REGE:                      /* RR E */
  2647.     case REGH:                      /* RR H */
  2648.     case REGL:                      /* RR L */
  2649.     case REGIHL:                    /* RR (HL) */
  2650.         len = 2;
  2651.         ops[0] = 0xcb;
  2652.         ops[1] = 0x18 + op;
  2653.         break;
  2654.     case NOREG:                     /* Operand ist kein Register */
  2655.         if (strncmp(operand, "(IX+", 4) == 0) {
  2656.             len = 4;        /* RR (IX+d) */
  2657.             if (pass == 2) {
  2658.                 ops[0] = 0xdd;
  2659.                 ops[1] = 0xcb;
  2660.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2661.                 ops[3] = 0x1e;
  2662.             }
  2663.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2664.             len = 4;        /* RR (IY+d) */
  2665.             if (pass == 2) {
  2666.                 ops[0] = 0xfd;
  2667.                 ops[1] = 0xcb;
  2668.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2669.                 ops[3] = 0x1e;
  2670.             }
  2671.         } else {
  2672.             len = 1;
  2673.             ops[0] = 0;
  2674.             asmerr(E_ILLOPE);
  2675.         }
  2676.         break;
  2677.     case NOOPERA:                   /* Operand fehlt */
  2678.         len = 1;
  2679.         ops[0] = 0;
  2680.         asmerr(E_MISOPE);
  2681.         break;
  2682.     default:                        /* ungueltiger Operand */
  2683.         len = 1;
  2684.         ops[0] = 0;
  2685.         asmerr(E_ILLOPE);
  2686.     }
  2687.     return(len);
  2688. }
  2689.  
  2690. /*
  2691.  *      Die Funktion behandelt den SLA Op-Code
  2692.  */
  2693. op_sla()
  2694. {
  2695.     char *strchr();
  2696.     register int len, op;
  2697.  
  2698.     if (pass == 1)
  2699.         if (*label)
  2700.             put_label();
  2701.     switch (op = get_reg(operand)) {
  2702.     case REGA:                      /* SLA A */
  2703.     case REGB:                      /* SLA B */
  2704.     case REGC:                      /* SLA C */
  2705.     case REGD:                      /* SLA D */
  2706.     case REGE:                      /* SLA E */
  2707.     case REGH:                      /* SLA H */
  2708.     case REGL:                      /* SLA L */
  2709.     case REGIHL:                    /* SLA (HL) */
  2710.         len = 2;
  2711.         ops[0] = 0xcb;
  2712.         ops[1] = 0x20 + op;
  2713.         break;
  2714.     case NOREG:                     /* Operand ist kein Register */
  2715.         if (strncmp(operand, "(IX+", 4) == 0) {
  2716.             len = 4;        /* SLA (IX+d) */
  2717.             if (pass == 2) {
  2718.                 ops[0] = 0xdd;
  2719.                 ops[1] = 0xcb;
  2720.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2721.                 ops[3] = 0x26;
  2722.             }
  2723.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2724.             len = 4;        /* SLA (IY+d) */
  2725.             if (pass == 2) {
  2726.                 ops[0] = 0xfd;
  2727.                 ops[1] = 0xcb;
  2728.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2729.                 ops[3] = 0x26;
  2730.             }
  2731.         } else {
  2732.             len = 1;
  2733.             ops[0] = 0;
  2734.             asmerr(E_ILLOPE);
  2735.         }
  2736.         break;
  2737.     case NOOPERA:                   /* Operand fehlt */
  2738.         len = 1;
  2739.         ops[0] = 0;
  2740.         asmerr(E_MISOPE);
  2741.         break;
  2742.     default:                        /* ungueltiger Operand */
  2743.         len = 1;
  2744.         ops[0] = 0;
  2745.         asmerr(E_ILLOPE);
  2746.     }
  2747.     return(len);
  2748. }
  2749.  
  2750. /*
  2751.  *      Die Funktion behandelt den SRA Op-Code
  2752.  */
  2753. op_sra()
  2754. {
  2755.     char *strchr();
  2756.     register int len, op;
  2757.  
  2758.     if (pass == 1)
  2759.         if (*label)
  2760.             put_label();
  2761.     switch (op = get_reg(operand)) {
  2762.     case REGA:                      /* SRA A */
  2763.     case REGB:                      /* SRA B */
  2764.     case REGC:                      /* SRA C */
  2765.     case REGD:                      /* SRA D */
  2766.     case REGE:                      /* SRA E */
  2767.     case REGH:                      /* SRA H */
  2768.     case REGL:                      /* SRA L */
  2769.     case REGIHL:                    /* SRA (HL) */
  2770.         len = 2;
  2771.         ops[0] = 0xcb;
  2772.         ops[1] = 0x28 + op;
  2773.         break;
  2774.     case NOREG:                     /* Operand ist kein Register */
  2775.         if (strncmp(operand, "(IX+", 4) == 0) {
  2776.             len = 4;        /* SRA (IX+d) */
  2777.             if (pass == 2) {
  2778.                 ops[0] = 0xdd;
  2779.                 ops[1] = 0xcb;
  2780.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2781.                 ops[3] = 0x2e;
  2782.             }
  2783.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2784.             len = 4;        /* SRA (IY+d) */
  2785.             if (pass == 2) {
  2786.                 ops[0] = 0xfd;
  2787.                 ops[1] = 0xcb;
  2788.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2789.                 ops[3] = 0x2e;
  2790.             }
  2791.         } else {
  2792.             len = 1;
  2793.             ops[0] = 0;
  2794.             asmerr(E_ILLOPE);
  2795.         }
  2796.         break;
  2797.     case NOOPERA:                   /* Operand fehlt */
  2798.         len = 1;
  2799.         ops[0] = 0;
  2800.         asmerr(E_MISOPE);
  2801.         break;
  2802.     default:                        /* ungueltiger Operand */
  2803.         len = 1;
  2804.         ops[0] = 0;
  2805.         asmerr(E_ILLOPE);
  2806.     }
  2807.     return(len);
  2808. }
  2809.  
  2810. /*
  2811.  *      Die Funktion behandelt den SRL Op-Code
  2812.  */
  2813. op_srl()
  2814. {
  2815.     char *strchr();
  2816.     register int len, op;
  2817.  
  2818.     if (pass == 1)
  2819.         if (*label)
  2820.             put_label();
  2821.     switch (op = get_reg(operand)) {
  2822.     case REGA:                      /* SRL A */
  2823.     case REGB:                      /* SRL B */
  2824.     case REGC:                      /* SRL C */
  2825.     case REGD:                      /* SRL D */
  2826.     case REGE:                      /* SRL E */
  2827.     case REGH:                      /* SRL H */
  2828.     case REGL:                      /* SRL L */
  2829.     case REGIHL:                    /* SRL (HL) */
  2830.         len = 2;
  2831.         ops[0] = 0xcb;
  2832.         ops[1] = 0x38 + op;
  2833.         break;
  2834.     case NOREG:                     /* Operand ist kein Register */
  2835.         if (strncmp(operand, "(IX+", 4) == 0) {
  2836.             len = 4;        /* SRL (IX+d) */
  2837.             if (pass == 2) {
  2838.                 ops[0] = 0xdd;
  2839.                 ops[1] = 0xcb;
  2840.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2841.                 ops[3] = 0x3e;
  2842.             }
  2843.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2844.             len = 4;        /* SRL (IY+d) */
  2845.             if (pass == 2) {
  2846.                 ops[0] = 0xfd;
  2847.                 ops[1] = 0xcb;
  2848.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2849.                 ops[3] = 0x3e;
  2850.             }
  2851.         } else {
  2852.             len = 1;
  2853.             ops[0] = 0;
  2854.             asmerr(E_ILLOPE);
  2855.         }
  2856.         break;
  2857.     case NOOPERA:                   /* Operand fehlt */
  2858.         len = 1;
  2859.         ops[0] = 0;
  2860.         asmerr(E_MISOPE);
  2861.         break;
  2862.     default:                        /* ungueltiger Operand */
  2863.         len = 1;
  2864.         ops[0] = 0;
  2865.         asmerr(E_ILLOPE);
  2866.     }
  2867.     return(len);
  2868. }
  2869.  
  2870. /*
  2871.  *      Die Funktion behandelt den RLC Op-Code
  2872.  */
  2873. op_rlc()
  2874. {
  2875.     char *strchr();
  2876.     register int len, op;
  2877.  
  2878.     if (pass == 1)
  2879.         if (*label)
  2880.             put_label();
  2881.     switch (op = get_reg(operand)) {
  2882.     case REGA:                      /* RLC A */
  2883.     case REGB:                      /* RLC B */
  2884.     case REGC:                      /* RLC C */
  2885.     case REGD:                      /* RLC D */
  2886.     case REGE:                      /* RLC E */
  2887.     case REGH:                      /* RLC H */
  2888.     case REGL:                      /* RLC L */
  2889.     case REGIHL:                    /* RLC (HL) */
  2890.         len = 2;
  2891.         ops[0] = 0xcb;
  2892.         ops[1] = 0x00 + op;
  2893.         break;
  2894.     case NOREG:                     /* Operand ist kein Register */
  2895.         if (strncmp(operand, "(IX+", 4) == 0) {
  2896.             len = 4;        /* RLC (IX+d) */
  2897.             if (pass == 2) {
  2898.                 ops[0] = 0xdd;
  2899.                 ops[1] = 0xcb;
  2900.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2901.                 ops[3] = 0x06;
  2902.             }
  2903.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2904.             len = 4;        /* RLC (IY+d) */
  2905.             if (pass == 2) {
  2906.                 ops[0] = 0xfd;
  2907.                 ops[1] = 0xcb;
  2908.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2909.                 ops[3] = 0x06;
  2910.             }
  2911.         } else {
  2912.             len = 1;
  2913.             ops[0] = 0;
  2914.             asmerr(E_ILLOPE);
  2915.         }
  2916.         break;
  2917.     case NOOPERA:                   /* Operand fehlt */
  2918.         len = 1;
  2919.         ops[0] = 0;
  2920.         asmerr(E_MISOPE);
  2921.         break;
  2922.     default:                        /* ungueltiger Operand */
  2923.         len = 1;
  2924.         ops[0] = 0;
  2925.         asmerr(E_ILLOPE);
  2926.     }
  2927.     return(len);
  2928. }
  2929.  
  2930. /*
  2931.  *      Die Funktion behandelt den RRC Op-Code
  2932.  */
  2933. op_rrc()
  2934. {
  2935.     char *strchr();
  2936.     register int len, op;
  2937.  
  2938.     if (pass == 1)
  2939.         if (*label)
  2940.             put_label();
  2941.     switch (op = get_reg(operand)) {
  2942.     case REGA:                      /* RRC A */
  2943.     case REGB:                      /* RRC B */
  2944.     case REGC:                      /* RRC C */
  2945.     case REGD:                      /* RRC D */
  2946.     case REGE:                      /* RRC E */
  2947.     case REGH:                      /* RRC H */
  2948.     case REGL:                      /* RRC L */
  2949.     case REGIHL:                    /* RRC (HL) */
  2950.         len = 2;
  2951.         ops[0] = 0xcb;
  2952.         ops[1] = 0x08 + op;
  2953.         break;
  2954.     case NOREG:                     /* Operand ist kein Register */
  2955.         if (strncmp(operand, "(IX+", 4) == 0) {
  2956.             len = 4;        /* RRC (IX+d) */
  2957.             if (pass == 2) {
  2958.                 ops[0] = 0xdd;
  2959.                 ops[1] = 0xcb;
  2960.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2961.                 ops[3] = 0x0e;
  2962.             }
  2963.         } else if (strncmp(operand, "(IY+", 4) == 0) {
  2964.             len = 4;        /* RRC (IY+d) */
  2965.             if (pass == 2) {
  2966.                 ops[0] = 0xfd;
  2967.                 ops[1] = 0xcb;
  2968.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  2969.                 ops[3] = 0x0e;
  2970.             }
  2971.         } else {
  2972.             len = 1;
  2973.             ops[0] = 0;
  2974.             asmerr(E_ILLOPE);
  2975.         }
  2976.         break;
  2977.     case NOOPERA:                   /* Operand fehlt */
  2978.         len = 1;
  2979.         ops[0] = 0;
  2980.         asmerr(E_MISOPE);
  2981.         break;
  2982.     default:                        /* ungueltiger Operand */
  2983.         len = 1;
  2984.         ops[0] = 0;
  2985.         asmerr(E_ILLOPE);
  2986.     }
  2987.     return(len);
  2988. }
  2989.  
  2990. /*
  2991.  *      Die Funktion behandelt den OUT Op-Code
  2992.  */
  2993. op_out()
  2994. {
  2995.     register int op;
  2996.     char *get_second();
  2997.  
  2998.     if (pass == 1) {                /* PASS 1 */
  2999.         if (*label)
  3000.             put_label();
  3001.     } else {                        /* PASS 2 */
  3002.         if (strncmp(operand, "(C),", 4) == 0) {
  3003.             switch(op = get_reg(get_second(operand))) {
  3004.             case REGA:      /* OUT (C),A */
  3005.             case REGB:      /* OUT (C),B */
  3006.             case REGC:      /* OUT (C),C */
  3007.             case REGD:      /* OUT (C),D */
  3008.             case REGE:      /* OUT (C),E */
  3009.             case REGH:      /* OUT (C),H */
  3010.             case REGL:      /* OUT (C),L */
  3011.                 ops[0] = 0xed;
  3012.                 ops[1] = 0x41 + (op << 3);
  3013.                 break;
  3014.             case NOOPERA:   /* Operand fehlt */
  3015.                 ops[0] = 0;
  3016.                 ops[1] = 0;
  3017.                 asmerr(E_MISOPE);
  3018.                 break;
  3019.             default:        /* ungueltiger Operand */
  3020.                 ops[0] = 0;
  3021.                 ops[1] = 0;
  3022.                 asmerr(E_ILLOPE);
  3023.             }
  3024.         } else {
  3025.             ops[0] = 0xd3;     /* OUT (n),A */
  3026.             ops[1] = chk_v1(calc_val(operand + 1));
  3027.         }
  3028.     }
  3029.     return(2);
  3030. }
  3031.  
  3032. /*
  3033.  *      Die Funktion behandelt den IN Op-Code
  3034.  */
  3035. op_in()
  3036. {
  3037.     char *get_second();
  3038.     register char *p1, *p2;
  3039.     register int op;
  3040.  
  3041.     if (pass == 1) {                /* PASS 1 */
  3042.         if (*label)
  3043.             put_label();
  3044.     } else {                        /* PASS 2 */
  3045.         p1 = operand;
  3046.         p2 = tmp;
  3047.         while (*p1 != ',' && *p1 != '\0')
  3048.             *p2++ = *p1++;
  3049.         *p2 = '\0';
  3050.         switch (op = get_reg(tmp)) {
  3051.         case REGA:
  3052.             if (strncmp(operand, "A,(C)", 5) == 0) {
  3053.                 ops[0] = 0xed;     /* IN A,(C) */
  3054.                 ops[1] = 0x78;
  3055.             } else {
  3056.                 ops[0] = 0xdb;     /* IN A,(n) */
  3057.                 ops[1] = chk_v1(calc_val(get_second(operand) + 1));
  3058.             }
  3059.             break;
  3060.         case REGB:                      /* IN B,(C) */
  3061.         case REGC:                      /* IN C,(C) */
  3062.         case REGD:                      /* IN D,(C) */
  3063.         case REGE:                      /* IN E,(C) */
  3064.         case REGH:                      /* IN H,(C) */
  3065.         case REGL:                      /* IN L,(C) */
  3066.             ops[0] = 0xed;
  3067.             ops[1] = 0x40 + (op << 3);
  3068.             break;
  3069.         default:                /* ungueltiger Operand */
  3070.             ops[0] = 0;
  3071.             ops[1] = 0;
  3072.             asmerr(E_ILLOPE);
  3073.         }
  3074.     }
  3075.     return(2);
  3076. }
  3077.  
  3078. /*
  3079.  *      Diese Funktion behandelt den SET Op-Code
  3080.  */
  3081. op_set()
  3082. {
  3083.     char *strchr();
  3084.     register char *p1, *p2;
  3085.     register int len;
  3086.     register int i;
  3087.     register int op;
  3088.  
  3089.     len = 2;
  3090.     i = 0;
  3091.     if (pass == 1)
  3092.         if (*label)
  3093.             put_label();
  3094.     ops[0] = 0xcb;
  3095.     p1 = operand;
  3096.     p2 = tmp;
  3097.     while (*p1 != ',' && *p1 != '\0')
  3098.         *p2++ = *p1++;
  3099.     *p2 = '\0';
  3100.     if (pass == 2) {
  3101.         i = eval(tmp);
  3102.         if (i < 0 || i > 7)
  3103.             asmerr(E_VALOUT);
  3104.     }
  3105.     switch (op = get_reg(++p1)) {
  3106.     case REGA:                      /* SET n,A */
  3107.     case REGB:                      /* SET n,B */
  3108.     case REGC:                      /* SET n,C */
  3109.     case REGD:                      /* SET n,D */
  3110.     case REGE:                      /* SET n,E */
  3111.     case REGH:                      /* SET n,H */
  3112.     case REGL:                      /* SET n,L */
  3113.     case REGIHL:                    /* SET n,(HL) */
  3114.         ops[1] = 0xc0 + i * 8 + op;
  3115.         break;
  3116.     case NOREG:                     /* Operand ist kein Register */
  3117.         if (strncmp(p1, "(IX+", 4) == 0) {
  3118.             len = 4;        /* SET n,(IX+d) */
  3119.             if (pass == 2) {
  3120.                 ops[0] = 0xdd;
  3121.                 ops[1] = 0xcb;
  3122.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  3123.                 ops[3] = 0xc6 + i * 8;
  3124.             }
  3125.         } else if (strncmp(p1, "(IY+", 4) == 0) {
  3126.             len = 4;        /* SET n,(IY+d) */
  3127.             if (pass == 2) {
  3128.                 ops[0] = 0xfd;
  3129.                 ops[1] = 0xcb;
  3130.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  3131.                 ops[3] = 0xc6 + i * 8;
  3132.             }
  3133.         } else {
  3134.             ops[1] = 0;
  3135.             asmerr(E_ILLOPE);
  3136.         }
  3137.         break;
  3138.     case NOOPERA:                   /* Operand fehlt */
  3139.         ops[1] = 0;
  3140.         asmerr(E_MISOPE);
  3141.         break;
  3142.     default:                        /* ungueltiger Operand */
  3143.         ops[1] = 0;
  3144.         asmerr(E_ILLOPE);
  3145.     }
  3146.     return(len);
  3147. }
  3148.  
  3149. /*
  3150.  *      Diese Funktion behandelt den RES Op-Code
  3151.  */
  3152. op_res()
  3153. {
  3154.     char *strchr();
  3155.     register char *p1, *p2;
  3156.     register int len;
  3157.     register int i;
  3158.     register int op;
  3159.  
  3160.     len = 2;
  3161.     i = 0;
  3162.     if (pass == 1)
  3163.         if (*label)
  3164.             put_label();
  3165.     ops[0] = 0xcb;
  3166.     p1 = operand;
  3167.     p2 = tmp;
  3168.     while (*p1 != ',' && *p1 != '\0')
  3169.         *p2++ = *p1++;
  3170.     *p2 = '\0';
  3171.     if (pass == 2) {
  3172.         i = eval(tmp);
  3173.         if (i < 0 || i > 7)
  3174.             asmerr(E_VALOUT);
  3175.     }
  3176.     switch (op = get_reg(++p1)) {
  3177.     case REGA:                      /* RES n,A */
  3178.     case REGB:                      /* RES n,B */
  3179.     case REGC:                      /* RES n,C */
  3180.     case REGD:                      /* RES n,D */
  3181.     case REGE:                      /* RES n,E */
  3182.     case REGH:                      /* RES n,H */
  3183.     case REGL:                      /* RES n,L */
  3184.     case REGIHL:                    /* RES n,(HL) */
  3185.         ops[1] = 0x80 + i * 8 + op;
  3186.         break;
  3187.     case NOREG:                     /* Operand ist kein Register */
  3188.         if (strncmp(p1, "(IX+", 4) == 0) {
  3189.             len = 4;        /* RES n,(IX+d) */
  3190.             if (pass == 2) {
  3191.                 ops[0] = 0xdd;
  3192.                 ops[1] = 0xcb;
  3193.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  3194.                 ops[3] = 0x86 + i * 8;
  3195.             }
  3196.         } else if (strncmp(p1, "(IY+", 4) == 0) {
  3197.             len = 4;        /* RES n,(IY+d) */
  3198.             if (pass == 2) {
  3199.                 ops[0] = 0xfd;
  3200.                 ops[1] = 0xcb;
  3201.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  3202.                 ops[3] = 0x86 + i * 8;
  3203.             }
  3204.         } else {
  3205.             ops[1] = 0;
  3206.             asmerr(E_ILLOPE);
  3207.         }
  3208.         break;
  3209.     case NOOPERA:                   /* Operand fehlt */
  3210.         ops[1] = 0;
  3211.         asmerr(E_MISOPE);
  3212.         break;
  3213.     default:                        /* ungueltiger Operand */
  3214.         ops[1] = 0;
  3215.         asmerr(E_ILLOPE);
  3216.     }
  3217.     return(len);
  3218. }
  3219.  
  3220. /*
  3221.  *      Diese Funktion behandelt den BIT Op-Code
  3222.  */
  3223. op_bit()
  3224. {
  3225.     char *strchr();
  3226.     register char *p1, *p2;
  3227.     register int len;
  3228.     register int i;
  3229.     register int op;
  3230.  
  3231.     len = 2;
  3232.     i = 0;
  3233.     if (pass == 1)
  3234.         if (*label)
  3235.             put_label();
  3236.     ops[0] = 0xcb;
  3237.     p1 = operand;
  3238.     p2 = tmp;
  3239.     while (*p1 != ',' && *p1 != '\0')
  3240.         *p2++ = *p1++;
  3241.     *p2 = '\0';
  3242.     if (pass == 2) {
  3243.         i = eval(tmp);
  3244.         if (i < 0 || i > 7)
  3245.             asmerr(E_VALOUT);
  3246.     }
  3247.     switch (op = get_reg(++p1)) {
  3248.     case REGA:                      /* BIT n,A */
  3249.     case REGB:                      /* BIT n,B */
  3250.     case REGC:                      /* BIT n,C */
  3251.     case REGD:                      /* BIT n,D */
  3252.     case REGE:                      /* BIT n,E */
  3253.     case REGH:                      /* BIT n,H */
  3254.     case REGL:                      /* BIT n,L */
  3255.     case REGIHL:                    /* BIT n,(HL) */
  3256.         ops[1] = 0x40 + i * 8 + op;
  3257.         break;
  3258.     case NOREG:                     /* Operand ist kein Register */
  3259.         if (strncmp(p1, "(IX+", 4) == 0) {
  3260.             len = 4;        /* BIT n,(IX+d) */
  3261.             if (pass == 2) {
  3262.                 ops[0] = 0xdd;
  3263.                 ops[1] = 0xcb;
  3264.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  3265.                 ops[3] = 0x46 + i * 8;
  3266.             }
  3267.         } else if (strncmp(p1, "(IY+", 4) == 0) {
  3268.             len = 4;        /* BIT n,(IY+d) */
  3269.             if (pass == 2) {
  3270.                 ops[0] = 0xfd;
  3271.                 ops[1] = 0xcb;
  3272.                 ops[2] = chk_v2(calc_val(strchr(operand, '+') + 1));
  3273.                 ops[3] = 0x46 + i * 8;
  3274.             }
  3275.         } else {
  3276.             ops[1] = 0;
  3277.             asmerr(E_ILLOPE);
  3278.         }
  3279.         break;
  3280.     case NOOPERA:                   /* Operand fehlt */
  3281.         ops[1] = 0;
  3282.         asmerr(E_MISOPE);
  3283.         break;
  3284.     default:                        /* ungueltiger Operand */
  3285.         ops[1] = 0;
  3286.         asmerr(E_ILLOPE);
  3287.     }
  3288.     return(len);
  3289. }
  3290.  
  3291. /*
  3292.  *      Die Funktion liefert einen Pointer auf den zweiten Operanden
  3293.  *      bei Befehlen der Form: Op-Code   destination,source
  3294.  *      Fehlt ,source wird ein NULL-Pointer geliefert.
  3295.  */
  3296. char *get_second(s)
  3297. register char *s;
  3298. {
  3299.     char *strchr();
  3300.     register char *p;
  3301.  
  3302.     if ((p = strchr(s, ',')) != NULL)
  3303.         return(p + 1);
  3304.     else
  3305.         return(NULL);
  3306. }
  3307.  
  3308. /*
  3309.  *      Die Funktion bestimmt den Wert eines Reststrings der
  3310.  *      Form: expression)
  3311.  *      Z.B.: LD A,(IX+7)
  3312.  *                     --
  3313.  */
  3314. calc_val(s)
  3315. register char *s;
  3316. {
  3317.     register char *p;
  3318.     register int i;
  3319.     char *strrchr(), *strncpy();
  3320.  
  3321.     if ((p = strrchr(s, ')')) == NULL) {
  3322.         asmerr(E_MISPAR);
  3323.         return(0);
  3324.     }
  3325.     i = p - s;
  3326.     strncpy(tmp, s, i);
  3327.     *(tmp + i) = '\0';
  3328.     return(eval(tmp));
  3329. }
  3330.