home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / dev / cross / caz / src / caz.h < prev    next >
C/C++ Source or Header  |  1994-01-08  |  5KB  |  193 lines

  1. #define MAXLABEL 32
  2. #define MAXDIRECTIVE MAXLABEL
  3. #define MAXCMD    5
  4. #define MAXOBCODE 0xFFFF
  5. #define NEWITEMOFF 5        /* should be greater in future (64) */
  6. #define MAXBYTESIH 16        /* maximum of Data Bytes in any INTELHEX row */
  7.  
  8. #define FILL_CHAR 0xff        /* character to fill DEFS space */
  9.  
  10. #define MAX(a,b) ((a)>(b)?(a):(b))
  11. #define MIN(a,b) ((a)<(b)?(a):(b))
  12. #define ABS(x) ((x<0)?(-(x)):(x))
  13.  
  14. #define ERROR -1
  15. #define U_ERROR 0xFFFFFFFF
  16. #define SERIOUS -2
  17. #define TRUE 1
  18. #define FALSE 0
  19.  
  20. #define RETURN_OK                0  /* No problems, success */
  21. #define RETURN_WARN                5  /* A warning only */
  22. #define RETURN_ERROR               10  /* Something wrong */
  23. #define RETURN_FAIL               20  /* Complete or severe failure*/
  24.  
  25. struct item_file
  26. {
  27.     struct item_file *prev;                        /* Previous Item */
  28.     char              filename[FILENAME_MAX];    /* Filename of pushed/poped File */
  29.     long              filepos;                    /* Absolute Filepostion (seek) */
  30.     long              lnr;                        /* Actual linenumber in this file */
  31. };
  32.  
  33. struct labelitem
  34. {
  35.     u_short     value;
  36.     BOOL    valid;
  37.     int        type;
  38.     char    name[MAXLABEL+1];
  39. };
  40.  
  41. struct listheader
  42. {
  43.     int        nitem;        /* Total number of item's in list */
  44.     int        actitem;    /* Next/First unused item */
  45.     int        sizeitem;    /* Size of one item */
  46.     int        newnitem;    /* Size of list to small ? => Alloc 'n' new items */
  47.     int     userdata;    /* until yet not used */
  48.     void    *list;        /* data */
  49. };
  50.  
  51. /* Note: Size of Objectcode is 'lastbyte-firstbyte', so unfilled ranges
  52.          generated with 'ORG' directives are also counted.
  53.          To get actual 'objbuffer' address you must always subtract 'firstbyte' !
  54. */         
  55. struct objsize
  56. {
  57.     int        firstbyte;  /* Start address of used Range */
  58.     int        actbyte;    /* Actual address */
  59.     int        lastbyte;    /* End address */
  60.     u_char  *objbuffer;    /* Pointer to object buffer */
  61. };
  62.  
  63. #define OBJADABS    1    /* set Object Adress absolute */
  64. #define OBJADREL    2    /* set Object Adress relativ */
  65.  
  66. /* Label Types */
  67. #define L_EQU        1    /* directive type : EQU, constant declaration */
  68. #define L_DEFL        2    /* directive type : EQU, constant declaration */
  69. #define L_POSITION    3    /* directive type : Adress/Memory assignment */
  70.  
  71. #define PARSE1        1    /* flag */
  72. #define PARSE2        2
  73.  
  74. #define ORG          0            
  75. #define EQU          L_EQU        
  76. #define DEFL         L_DEFL        
  77. #define DEFB         3            
  78. #define DEFW         4                
  79. #define DEFS         5           
  80. #define DEFM         6            
  81. #define INCLUDE     7
  82. #define END            8
  83. #define LIST        9
  84. #define LIST_OFF    10
  85. #define LIST_ON        11
  86. #define COND        12
  87. #define ENDC        13
  88. #define EJECT        14
  89. #define MACLIST        15
  90. #define HEADING        16
  91. #define MACRO        17
  92. #define ENDM        18
  93. #define DEFBASE        19
  94.  
  95.  
  96. /*
  97.  *    Definitions for Commands
  98.  */
  99.  
  100. #define BRA_Z        0x00000001
  101. #define BRA_NZ        0x00000002    
  102. #define BRA_C        0x00000004    /* same as REG_C */    
  103. #define BRA_NC        0x00000008    
  104. #define BRA_PO        0x00000010            
  105. #define BRA_PE        0x00000020            
  106. #define BRA_P        0x00000040        
  107. #define BRA_M         0x00000080        
  108.  
  109. #define REG_A        0x00000001    
  110. #define REG_B        0x00000002
  111. #define REG_C        0x00000004    /* same as BRA_C */
  112. #define REG_D        0x00000008
  113. #define REG_E        0x00000010
  114. #define REG_F        0x00000020
  115. #define REG_H        0x00000040
  116. #define REG_I        0x00000080
  117. #define REG_L        0x00000100
  118. #define REG_R        0x00000200
  119. #define REG_AF        0x00000400
  120. #define REG_BC        0x00000800    
  121. #define REG_DE        0x00001000    
  122. #define REG_HL        0x00002000
  123. #define REG_SP        0x00004000
  124. #define REG_IX        0x00008000
  125. #define REG_IY        0x00010000
  126.  
  127. #define BRA            0x00020000    /* Mne makes a branch (means flags) */
  128. #define NBR            0x00040000    /* Mne uses all other than branches */
  129. #define OFF            0x00080000
  130. #define IND            0x00100000    /* Indirekt Adressing */    
  131. #define    IMODE0        0x00200000    /* works together with UNM3 */
  132. #define    IMODE1        0x00400000    /* works together with UNM3 */
  133. #define    IMODE2        (IMODE0|IMODE1)    /* works together with UNM3 */
  134.  
  135. #define EXMASK        (IND|IMODE2|OFF|NBR|BRA) /* Bits with must be equivalent with argument */
  136.  
  137. #define RST            0x04000000    /* only for RST Mnemomic */
  138. #define JMPREL        0x08000000    /* Jump Offset must be relativ to current position */
  139. #define UNM3        0x10000000    
  140. #define UNM8        0x20000000
  141. #define UNM16        0x40000000    
  142.  
  143. #define NOPAR        0x80000000
  144.  
  145. #define REG8         (REG_A|REG_B|REG_C|REG_D|REG_E|REG_H|REG_L)
  146. #define REG16         (REG_BC|REG_DE|REG_HL|REG_SP)
  147. #define REG            (REG8|REG16|REG_F|REG_I|REG_R|REG_AF|REG_IX|REG_IY)
  148. #define BRANCH4        (BRA_NZ|BRA_Z|BRA_NC|BRA_C)
  149. #define BRANCH8        (BRANCH4|BRA_PO|BRA_PE|BRA_P|BRA_M)
  150. #define UNM            (UNM3|UNM8|UNM16)
  151.  
  152. #define BYTE1        0x00
  153. #define BYTE2        0x01
  154. #define BYTE3        0x02
  155. #define BYTE4        0x03
  156.  
  157. #define BYTE(A)        ((A)&0x03)
  158.  
  159. #define BIT0        0x00
  160. #define BIT1        0x04
  161. #define BIT2        0x08
  162. #define BIT3        0x0C
  163. #define BIT4        0x10
  164. #define BIT5        0x14
  165. #define BIT6        0x18
  166. #define BIT7        0x1C
  167.  
  168. #define BIT(A)        (((A)&0x1C)>>2)
  169.  
  170. #define MNELE1        0x00    /* Length of the Mnemomic */
  171. #define MNELE2        0x20
  172. #define MNELE3        0x40
  173. #define MNELE4        0x60
  174.  
  175. #define MNELEN(A)    ((((A)&0x60)>>5)+1)
  176.  
  177. #define NOE            0x80
  178.  
  179. #define LOBYTE(A)    ((u_char)(A))    
  180. #define HIBYTE(A)    ((u_char)((A)>>8))
  181.  
  182. struct command 
  183. {
  184.     char     *name;        /* name of Mnemomic */
  185.     u_long     pa1,        /* first Parameter */
  186.             pa2;        /* second Parameter */
  187.     u_char    order1,        /* 0,1:Byte Nr / 2,3,4:Bit position/ 5,6:Mnemomic Length */
  188.             order2;        /* 0,1:Byte Nr / 2,3,4:Bit position */
  189.     u_char     obj[4];        /* Object Code */
  190.     u_short    cycle;        /* Number of Clock Cycles */
  191. };
  192.  
  193.