home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / CROSSASM / 68ASMSIM.ZIP / asmsrc / asm.h next >
Encoding:
C/C++ Source or Header  |  1988-09-05  |  4.8 KB  |  183 lines

  1. /***********************************************************************
  2.  *
  3.  *        ASM.H
  4.  *        Global Definitions for 68000 Assembler
  5.  *
  6.  *      Author: Paul McKee
  7.  *        ECE492    North Carolina State University
  8.  *
  9.  *        Date:    12/13/86
  10.  *
  11.  ************************************************************************/
  12.  
  13.  
  14. /* include system header files for prototype checking */
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <process.h>
  18. #include <stdlib.h>
  19. #include <malloc.h>
  20.  
  21.  
  22. /* Status values */
  23.  
  24. /* These status values are 12 bits long with
  25.    a severity code in the upper 4 bits */
  26.  
  27. #define OK         0x00
  28.  
  29. /* Severe errors */
  30. #define SEVERE        0x400
  31. #define SYNTAX        0x401
  32. #define INV_OPCODE    0x402
  33. #define INV_ADDR_MODE    0x403
  34. #define LABEL_REQUIRED    0x404
  35. #define PHASE_ERROR    0x405
  36.  
  37. /* Errors */
  38. #define ERROR        0x300
  39. #define UNDEFINED    0x301
  40. #define DIV_BY_ZERO    0x302
  41. #define MULTIPLE_DEFS    0x303
  42. #define REG_MULT_DEFS    0x304
  43. #define REG_LIST_UNDEF    0x305
  44. #define INV_FORWARD_REF    0x306
  45. #define INV_LENGTH    0x307
  46.  
  47. /* Minor errors */
  48. #define MINOR        0x200
  49. #define INV_SIZE_CODE    0x201
  50. #define INV_QUICK_CONST    0x202
  51. #define INV_VECTOR_NUM    0x203
  52. #define INV_BRANCH_DISP 0x204
  53. #define INV_DISP    0x205
  54. #define INV_ABS_ADDRESS    0x206
  55. #define INV_8_BIT_DATA    0x207
  56. #define INV_16_BIT_DATA    0x208
  57. #define ODD_ADDRESS    0x209
  58. #define NOT_REG_LIST    0x20A
  59. #define REG_LIST_SPEC    0x20B
  60. #define INV_SHIFT_COUNT    0x20C
  61.  
  62. /* Warnings */
  63. #define WARNING        0x100
  64. #define ASCII_TOO_BIG    0x101
  65. #define NUMBER_TOO_BIG    0x102
  66. #define INCOMPLETE    0x103
  67.  
  68. #define SEVERITY    0xF00
  69.  
  70. /* The NEWERROR macros updates the error variable var only if the
  71.    new error code is more severe than all previous errors.  Throughout
  72.    ASM this is the standard means of reporting errors. */
  73.  
  74. #define NEWERROR(var, code)    if ((code & SEVERITY) > var) var = code
  75.  
  76.  
  77. /* Symbol table definitions */
  78.  
  79. /* Significant length of a symbol */
  80. #define SIGCHARS 8
  81.  
  82.  
  83. /* Structure for operand descriptors */
  84. typedef struct {
  85.     long int mode;    /* Mode number (see below) */
  86.     long int data;    /* Immediate value, displacement, or absolute address */
  87.  
  88.     char reg;    /* Principal register number (0-7) */
  89.     char index;    /* Index register number (0-7 = D0-D7, 8-15 = A0-A7) */
  90.     char size;    /* Size of index register (WORD or LONG, see below) */
  91.     char backRef;    /* True if data field is known on first pass */
  92.     } opDescriptor;
  93.  
  94.  
  95. /* Structure for a symbol table entry */
  96. typedef struct symbolEntry {
  97.     long int value;            /* 32-bit value of the symbol */
  98.     struct symbolEntry *next;    /* Pointer to next symbol in linked list */
  99.     char flags;            /* Flags (see below) */
  100.     char name[SIGCHARS+1];        /* Name */
  101.     } symbolDef;
  102.  
  103. /* Flag values for the "flags" field of a symbol */
  104.  
  105. #define BACKREF        0x01    /* Set when the symbol is defined on the 2nd pass */
  106. #define REDEFINABLE    0x02    /* Set for symbols defined by the SET directive */
  107. #define REG_LIST_SYM    0x04    /* Set for symbols defined by the REG directive */
  108.  
  109.  
  110. /* Instruction table definitions */
  111.  
  112. /* Structure to describe one "flavor" of an instruction */
  113.  
  114. typedef struct {
  115.     long int source,        /* Bit masks for the legal source...    */
  116.         dest;        /*  and destination addressing modes    */
  117.     char sizes;        /* Bit mask for the legal sizes */
  118.     int (*exec)(int, int, opDescriptor *, opDescriptor *, int *);
  119.                         /* Pointer to routine to build the instruction */
  120.     short int bytemask,    /* Skeleton instruction masks for byte size...  */
  121.           wordmask,    /*  word size, ...                    */
  122.           longmask;    /*  and long sizes of the instruction            */
  123.     } flavor;
  124.  
  125.  
  126. /* Structure for the instruction table */
  127. typedef struct {
  128.     char *mnemonic;        /* Mnemonic */
  129.     flavor *flavorPtr;    /* Pointer to flavor list */
  130.     char flavorCount;    /* Number of flavors in flavor list */
  131.     char parseFlag;        /* Should assemble() parse the operands? */
  132.     int (*exec)(int, char *, char *, int *);
  133.             /* Routine to be called if parseFlag is FALSE */
  134.     } instruction;
  135.  
  136.  
  137. /* Addressing mode codes/bitmasks */
  138.  
  139. #define DnDirect            0x00001
  140. #define AnDirect            0x00002
  141. #define AnInd                0x00004
  142. #define AnIndPost            0x00008
  143. #define AnIndPre            0x00010
  144. #define AnIndDisp            0x00020
  145. #define AnIndIndex        0x00040
  146. #define AbsShort            0x00080
  147. #define AbsLong            0x00100
  148. #define PCDisp                0x00200
  149. #define PCIndex            0x00400
  150. #define Immediate            0x00800
  151. #define SRDirect            0x01000
  152. #define CCRDirect            0x02000
  153. #define USPDirect            0x04000
  154. #define SFCDirect            0x08000
  155. #define DFCDirect            0x10000
  156. #define VBRDirect            0x20000
  157.  
  158.  
  159. /* Register and operation size codes/bitmasks */
  160.  
  161. #define BYTE    ((int) 1)
  162. #define WORD    ((int) 2)
  163. #define LONG    ((int) 4)
  164. #define SHORT    ((int) 8)
  165.  
  166.  
  167. /* added for PC port -- 7/8/1988 */
  168.  
  169. #define    TRUE    -1
  170. #define    FALSE    0
  171.  
  172.  
  173. /* function return codes */
  174.  
  175. #define    NORMAL    0
  176.  
  177.  
  178.  
  179. /* function prototype definitions */
  180. #include "proto.h"
  181.  
  182.  
  183.