//
//  Copyright (C) 1997,1998,1999 Forest Edge Software, see License.txt for Rights
//
//  Program:    eVAX, a "Virtual VAX" for Mac OS Computers
//
//  Author:     Tom Cole
//
//  Module:     vaxinstr.h
//
//  Purpose:    Describes what we know about instructions, the emulator
//              entry points, and how to decode instruction operand data.
//
//  History:    07/28/97    New header format standardization
//
//

typedef LONGWORD (*emulator )( struct OPCODE * opcode );


// #define BOOTSTRAP only if instruction_table.h is damaged or incompatible

//
//  Table of instruction data

struct INSTRUCTION {
    char                scale[ 6 ];         // Sizes of each operand type
    char                type;               // Type of input operand (needed for short lits)
    emulator            routine;            // Entry point of emulation module
    unsigned char       extended;           // MSB of instruction (normally zero)
    unsigned char       opcode;             // Actual opcode of instruction
    unsigned char       operand_count;      // Count of operands we use
    LONGWORD            access[ 6 ];        // Access attributes for each operand (int array)
    LONGWORD            use_count;          // Instruction profile data here.
    char *              name;
};

#define OP_NONE     0       //  This means there are no operands (default)


//  Operand data types.  These are needed so we recognize how to interpret the
//  S^ short literal type.  If it's a LONGWORD data type, then shorts are interpreted
//  as literal bit patterns.  Otherwise, we use the short integer value as an index
//  to look up the correct float type.

#define OP_TYPE_INT     0   //  (Source) operand data type is integer
#define OP_TYPE_FLOAT   1   //  (Source) operand data type is float


//  Define an access mask as an array of integers.  This used to be a bit-mask
//  but it was really expensive to disassemble them on instruction decodes, so
//  now we go for the fluffy but fast array of integers.
//

#define ACCESS( n0, n1, n2, n3, n4, n5 )  { n0, n1, n2, n3, n4, n5 }

//  Given a mode mask value 'n' and opcode number 'v', extract the
//  opcode mode value.

#define GETMODE( n, v ) ( n[ v ])

#ifndef GLOBAL
extern struct INSTRUCTION instruction[];
#else

/*  For the definitions of the instructions, we include the header  */
/*  file that's generated by the TEST 11001 command.  If the table  */
/*  must be changed, use the TEST command to generate a new table   */
/*  and THEN modify the code to use the new table.  Finally, move   */
/*  the newly geneated file to the Headers folder to compile.       */

#include "instruction_table.h"

#endif      // if we are creating the GLOBAL storage instance

//
//  Include the emulator routine entry points.

#include "emulator_entries.h"

