
/* optap.h */

struct optable op_adc[] = {
    R4,R4,2,0x12,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x13,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x14,ZSOURCE,ZDEST,
    R8,IR8,3,0x15,ZSOURCE,ZDEST,
    R8,IM8,3,0x16,ZDEST,ZSOURCE,
    IR8,IM8,3,0x17,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_add[] = {
    R4,R4,2,0x02,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x03,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x04,ZSOURCE,ZDEST,
    R8,IR8,3,0x05,ZSOURCE,ZDEST,
    R8,IM8,3,0x06,ZDEST,ZSOURCE,
    IR8,IM8,3,0x07,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_and[] = {
    R4,R4,2,0x52,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x53,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x54,ZSOURCE,ZDEST,
    R8,IR8,3,0x55,ZSOURCE,ZDEST,
    R8,IM8,3,0x56,ZDEST,ZSOURCE,
    IR8,IM8,3,0x57,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_cp[] = {
    R4,R4,2,0xa2,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0xa3,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0xa4,ZSOURCE,ZDEST,
    R8,IR8,3,0xa5,ZSOURCE,ZDEST,
    R8,IM8,3,0xa6,ZDEST,ZSOURCE,
    IR8,IM8,3,0xa7,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_or[] = {
    R4,R4,2,0x42,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x43,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x44,ZSOURCE,ZDEST,
    R8,IR8,3,0x45,ZSOURCE,ZDEST,
    R8,IM8,3,0x46,ZDEST,ZSOURCE,
    IR8,IM8,3,0x47,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_sbc[] = {
    R4,R4,2,0x32,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x33,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x34,ZSOURCE,ZDEST,
    R8,IR8,3,0x35,ZSOURCE,ZDEST,
    R8,IM8,3,0x36,ZDEST,ZSOURCE,
    IR8,IM8,3,0x37,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_sub[] = {
    R4,R4,2,0x22,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x23,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x24,ZSOURCE,ZDEST,
    R8,IR8,3,0x25,ZSOURCE,ZDEST,
    R8,IM8,3,0x26,ZDEST,ZSOURCE,
    IR8,IM8,3,0x27,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_tcm[] = {
    R4,R4,2,0x62,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x63,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x64,ZSOURCE,ZDEST,
    R8,IR8,3,0x65,ZSOURCE,ZDEST,
    R8,IM8,3,0x66,ZDEST,ZSOURCE,
    IR8,IM8,3,0x67,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_tm[] = {
    R4,R4,2,0x72,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0x73,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0x74,ZSOURCE,ZDEST,
    R8,IR8,3,0x75,ZSOURCE,ZDEST,
    R8,IM8,3,0x76,ZDEST,ZSOURCE,
    IR8,IM8,3,0x77,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_xor[] = {
    R4,R4,2,0xb2,DESTSL4_OR_SOURCE,0,
    R4,IR4,2,0xb3,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0xb4,ZSOURCE,ZDEST,
    R8,IR8,3,0xb5,ZSOURCE,ZDEST,
    R8,IM8,3,0xb6,ZDEST,ZSOURCE,
    IR8,IM8,3,0xb7,ZDEST,ZSOURCE,
    0,0,0,0,0,0				/* terminator */
};

struct optable op_call[] = {
    DA,0,3,0xd6,ZDEST,0,
    IRR8,0,2,0xd4,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_ld[] = {
    R4,IM8,2,0x0c,OPCODE_OR_DESTSL4,ZSOURCE,
    R4,R8,2,0x08,OPCODE_OR_DESTSL4,ZSOURCE,
    R8,R4,2,0x09,OPCODE_OR_SOURCESL4,ZDEST,
    R4,IR4,2,0xe3,DESTSL4_OR_SOURCE,0,
    IR4,R4,2,0xf3,DESTSL4_OR_SOURCE,0,
    R8,R8,3,0xe4,ZSOURCE,ZDEST,
    R8,IR8,3,0xe5,ZSOURCE,ZDEST,
    R8,IM8,3,0xe6,ZDEST,ZSOURCE,
    IR8,IM8,3,0xe7,ZDEST,ZSOURCE,
    IR8,R8,3,0xf5,ZSOURCE,ZDEST,
    0,0,0,0,0,0
};

struct optable op_lde[] = {
    R4,IRR4,2,0x82,DESTSL4_OR_SOURCE,0,
    IRR4,R4,2,0x92,SOURCESL4_OR_DEST,0,
    0,0,0,0,0,0
};

struct optable op_ldei[] = {
    IR4,IRR4,2,0x83,DESTSL4_OR_SOURCE,0,
    IRR4,IR4,2,0x93,SOURCESL4_OR_DEST,0,
    0,0,0,0,0,0
};

struct optable op_ldc[] = {
    R4,IRR4,2,0xc2,DESTSL4_OR_SOURCE,0,
    IRR4,R4,2,0xd2,SOURCESL4_OR_DEST,0,
    0,0,0,0,0,0
};

struct optable op_ldci[] = {
    IR4,IRR4,2,0xc3,DESTSL4_OR_SOURCE,0,
    IRR4,IR4,2,0xd3,SOURCESL4_OR_DEST,0,
    0,0,0,0,0,0
};

struct optable op_inc[] = {
    R4,0,1,0x0e,OPCODE_OR_DESTSL4,0,
    R8,0,2,0x20,ZDEST,0,
    IR8,0,2,0x21,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_clr[] = {
    R8,0,2,0xb0,ZDEST,0,
    IR8,0,2,0xb1,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_com[] = {
    R8,0,2,0x60,ZDEST,0,
    IR8,0,2,0x61,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_da[] = {
    R8,0,2,0x40,ZDEST,0,
    IR8,0,2,0x41,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_pop[] = {
    R8,0,2,0x50,ZDEST,0,
    IR8,0,2,0x51,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_push[] = {
    R8,0,2,0x70,ZDEST,0,
    IR8,0,2,0x71,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_dec[] = {
    R8,0,2,0x00,ZDEST,0,
    IR8,0,2,0x01,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_rl[] = {
    R8,0,2,0x90,ZDEST,0,
    IR8,0,2,0x91,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_rlc[] = {
    R8,0,2,0x10,ZDEST,0,
    IR8,0,2,0x11,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_rr[] = {
    R8,0,2,0xe0,ZDEST,0,
    IR8,0,2,0xe1,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_rrc[] = {
    R8,0,2,0xc0,ZDEST,0,
    IR8,0,2,0xc1,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_sra[] = {
    R8,0,2,0xd0,ZDEST,0,
    IR8,0,2,0xd1,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_swap[] = {
    R8,0,2,0xf0,ZDEST,0,
    IR8,0,2,0xf1,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_ccf[] = {
    IMP,0,1,0xef,0,0,
    0,0,0,0,0,0
};

struct optable op_di[] = {
    IMP,0,1,0x8f,0,0,
    0,0,0,0,0,0
};

struct optable op_iret[] = {
    IMP,0,1,0xbf,0,0,
    0,0,0,0,0,0
};

struct optable op_nop[] = {
    IMP,0,1,0xff,0,0,
    0,0,0,0,0,0
};


struct optable op_ei[] = {
    IMP,0,1,0x9f,0,0,
    0,0,0,0,0,0
};

struct optable op_srp[] = {
    IM8,0,2,0x31,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_ret[] = {
    IMP,0,1,0xaf,0,0,
    0,0,0,0,0,0
};

struct optable op_rcf[] = {
    IMP,0,1,0xcf,0,0,
    0,0,0,0,0,0
};

struct optable op_scf[] = {
    IMP,0,1,0xdf,0,0,
    0,0,0,0,0,0
};

struct optable op_incw[] = {
    RR8,0,2,0xa0,ZDEST,0,
    IRR8,0,2,0xa1,ZDEST,0,
    0,0,0,0,0,0
};

struct optable op_decw[] = {
    RR8,0,2,0x80,ZDEST,0,
    IRR8,0,2,0x81,ZDEST,0,
    0,0,0,0,0,0
};

        
struct syntax {
    char *mne;		/* ascii mneumonic */
    int opr_type;	/* operand type descriptor */
    struct optable *otab;  /* pointer to operand evaluation table */
    int tot_args;       /* total minimum arguments including mne */
};

/* the z8 syntax description */

struct syntax z8[] = {
    "Invalid",0,NULL,0,
    "ADC",DEST_SOURCE,op_adc,3,
    "ADD",DEST_SOURCE,op_add,3,
    "AND",DEST_SOURCE,op_and,3,
    "CALL",DEST_ONLY,op_call,2,
    "CCF",IMPLIED,op_ccf,1,
    "CLR",DEST_ONLY,op_clr,2,
    "COM",DEST_ONLY,op_com,2,
    "CP",DEST_SOURCE,op_cp,2,
    "DA",DEST_ONLY,op_da,2,
    "DEC",DEST_ONLY,op_dec,2,
    "DECW",DEST_ONLY,op_decw,3,
    "DI",IMPLIED,op_di,1,
    "DJNZ",CREATE_DJ,NULL,3,
    "EI",IMPLIED,op_ei,1,
    "INC",DEST_ONLY,op_inc,2,
    "INCW",DEST_ONLY,op_incw,3,
    "IRET",IMPLIED,op_iret,1,
    "JP",CREATE_JP,NULL,3,
    "JR",CREATE_JR,NULL,3,
    "LD",DEST_SOURCE,op_ld,3,
    "LDC",DEST_SOURCE,op_ldc,2,
    "LDCI",DEST_SOURCE,op_ldci,2,
    "LDE",DEST_SOURCE,op_lde,2,
    "LDEI",DEST_SOURCE,op_ldei,2,
    "NOP",IMPLIED,op_nop,1,
    "OR",DEST_SOURCE,op_or,2,
    "POP",DEST_ONLY,op_pop,2,
    "PUSH",DEST_ONLY,op_push,2,
    "RCF",IMPLIED,op_rcf,1,
    "RET",IMPLIED,op_ret,1,
    "RL",DEST_ONLY,op_rl,2,
    "RLC",DEST_ONLY,op_rlc,2,
    "RR",DEST_ONLY,op_rr,2,
    "RRC",DEST_ONLY,op_rrc,2,
    "SBC",DEST_SOURCE,op_sbc,3,
    "SCF",IMPLIED,op_scf,1,
    "SRA",DEST_ONLY,op_sra,2,
    "SRP",DEST_ONLY,op_srp,2,
    "SUB",DEST_SOURCE,op_sub,3,
    "SWAP",DEST_ONLY,op_swap,2,
    "TCM",DEST_SOURCE,op_tcm,3,
    "TM",DEST_SOURCE,op_tm,3,
    "XOR",DEST_SOURCE,op_xor,3
};

#define Z8SIZE sizeof(z8) / sizeof(z8[0])
