home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume10 / asm.8051 / as31.h next >
Encoding:
C/C++ Source or Header  |  1990-02-13  |  3.5 KB  |  141 lines

  1. /* ----------------------------------------------------------------------
  2.  * FILE: as31.h
  3.  * PACKAGE: as31 - 8031/8051 Assembler.
  4.  *
  5.  * DESCRIPTION:
  6.  *    The sole header file for the 8031/8051 assembler package.
  7.  *    It defines several structures used by the yacc stack.
  8.  *    It defines several macros for testing the bitsize of numeric
  9.  *    quantities.
  10.  *
  11.  *    Some macros to extract information from the mode structure.
  12.  *
  13.  * REVISION HISTORY:
  14.  *    Jan. 19, 1990 - Created. (Ken Stauffer)
  15.  *
  16.  * AUTHOR:
  17.  *    All code in this file written by Ken Stauffer (University of Calgary).
  18.  *    January, 1990.
  19.  *
  20.  */
  21.  
  22. /* ----------------------------------------------------------------------
  23.  * user / keyword symbol structures:
  24.  */
  25.  
  26. struct opcode {
  27.     char *name;
  28.     int type;
  29.     unsigned char *bytes;
  30. };
  31.  
  32. struct symbol {
  33.     char *name;
  34.     int type;
  35.     long value;
  36.     struct symbol *next;
  37. };
  38.  
  39. #define UNDEF    0
  40. #define LABEL    1
  41.  
  42. /* ----------------------------------------------------------------------
  43.  * addressing mode stuff:
  44.  */
  45.  
  46. struct mode {
  47.     unsigned char mode;        /* value to index with */
  48.     unsigned char size;        /* # of bytes used */
  49.     unsigned char orval;        /* value OR'd to obcode */
  50.     unsigned char byte1;        /* extra byte 1 */
  51.     unsigned char byte2;        /* extra byte 2 */
  52. };
  53.  
  54. #define set_md(m,a)    ((m).mode=(a))
  55. #define set_sz(m,a)    ((m).size=(a))
  56. #define set_ov(m,a)    ((m).orval=(a))
  57. #define set_b1(m,a)    ((m).byte1=(a))
  58. #define set_b2(m,a)    ((m).byte2=(a))
  59.  
  60. #define get_md(m)    ((m).mode)
  61. #define get_sz(m)    ((m).size)
  62. #define get_ov(m)    ((m).orval)
  63. #define get_b1(m)    ((m).byte1)
  64. #define get_b2(m)    ((m).byte2)
  65.  
  66. /* ----------------------------------------------------------------------
  67.  * yacc stack stuff:
  68.  */
  69.  
  70. struct value {
  71.     long v;
  72.     unsigned char d;        /* expression defined flag */
  73. };
  74.  
  75. union ystack {
  76.     long value;
  77.     struct value val;
  78.     struct opcode *op;
  79.     struct symbol *sym;
  80.     struct mode mode;
  81.     char *str;
  82. };
  83.  
  84. /* ----------------------------------------------------------------------
  85.  * IS_BIT_MAPPED_RAM:
  86.  *    True is the byte 'a' is the byte address of a bit mapped
  87.  *    RAM location.
  88.  */
  89. #define isbmram(a)    (((a)&0xf0)==0x20)
  90.  
  91. /* ----------------------------------------------------------------------
  92.  * IS_BIT_MAPPED_SFR:
  93.  *    True is the byte 'a' is the byte address of a bit mapped
  94.  *    SPECIAL FUCTION REGISTER.
  95.  */
  96. #define isbmsfr(a)    (((a)&0x80) && !((a) & 0x07))
  97.  
  98. /* ----------------------------------------------------------------------
  99.  * isbit8, ...
  100.  *    Macros to check the sizes of values and to convert
  101.  *    a value to a certain, size.
  102.  *
  103.  */
  104. #define size8        (~0x00ff)
  105. #define size11        (~0x07ff)
  106. #define size13        (~0x1fff)
  107. #define size16        (~0xffff)
  108.  
  109. #define size10        (~0x03ff)
  110. #define size12        (~0x0fff)
  111. #define size15        (~0x7fff)
  112.  
  113. #define isbit8(v)    ( !( ((v)>=0) ? (v)&size8 : -(v)>=128) )
  114. #define isbit11(v)    ( !( ((v)>=0) ? (v)&size11 : (-(v))&size10 ) )
  115. #define isbit13(v)    ( !( ((v)>=0) ? (v)&size13 : (-(v))&size12 ) )
  116. #define isbit16(v)    ( !( ((v)>=0) ? (v)&size16 : (-(v))&size15 ) )
  117.  
  118. /* ----------------------------------------------------------------------
  119.  * Size of user hash table.
  120.  */
  121. #define HASHTABSIZE        1000
  122.  
  123. /* ----------------------------------------------------------------------
  124.  * Macros to nicely test which pass we are in.
  125.  */
  126. #define pass1            (!pass)
  127. #define pass2            (pass)
  128.  
  129. /* -------- TOKENS ------------------------------------------------------
  130.  *
  131.  * This includes the header file generated by yacc -d.
  132.  * NOPE is defined inside of as31.y, which does not
  133.  * need to re-include the tokens twice, thus NOPE prevents this.
  134.  *
  135.  */
  136. #ifdef NOPE
  137. #else
  138. #include "y.tab.h"
  139. #endif
  140.  
  141.