home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / nasm20b / nasm_src / labels.h < prev    next >
C/C++ Source or Header  |  1993-01-19  |  5KB  |  101 lines

  1. /* ---------------------------------------------------------------------- */
  2. /*                   Copyright (C) 1991 by Natürlich!                     */
  3. /*                      This file is copyrighted!                         */
  4. /*                Refer to the documentation for details.                 */
  5. /* ---------------------------------------------------------------------- */
  6. #ifndef _LABELS_
  7. #define _LABELS_
  8.  
  9. #if LINKER || LIBRARIAN
  10. #define SEP  31
  11. #else
  12. #define SEP  30
  13. #endif
  14.  
  15. /* number of different symbol tables */
  16.  
  17. #define L_NORMAL     0x0            /* Like FOO = $4000 */
  18. #define L_ZERO       0x1            /* Like FOO = $40   */
  19. #define L_EQU        0x2            /* Like FOO .= $4   */
  20. #define L_SPECIAL    0x8            /* LIKE __RUN       */
  21. #define L_LINKZERO   0x10           /* Like FOO == $40  */
  22. #define L_REF        0x40
  23. #define L_PC         0x8000         /* is label PC-relative ?? */
  24. #define L_MASK1      (L_PC  | L_LINKZERO)
  25. #define L_MASK2      (L_EQU | L_SPECIAL)
  26. #define q_pcrel( p)  ((sword)((p)->type) < 0)
  27. #define dumpable( x) (((x)->type & L_MASK1) && ! ((x)->type & L_MASK2))
  28.  
  29. #define FIX_WCODE    0x1       /* Fix 6502 word */
  30. #define FIX_ZCODE    0x2       /* Fix 6502 byte */
  31. #define FIX_SZCODE   0x3       /* Fix ATARI screen character */
  32. #define FIX_BRANCH   0x4       /* Fix a 6502 branch byte */
  33. #define FIX_DCODE    0x5       /* Fix 68000 word */
  34. #define FIX_NOTHING  0x6       /* Fix nothing (for copexpr f.i.) */
  35. #define FIX_LABEL    0x10      /* Fix a label */
  36. #define FIX_NOTYET   0x20      /* For linker (obsolete) */
  37.  
  38. #define unvalued( x)   ((x)->l || (x)->label)      /* for expressions */
  39. #define valued( x)     (! unvalued( x))
  40. #define e_pcrel( p)    ((signed char)((p)->op) < 0)
  41. #define is_msb( p)     (((p)->op & O_BITS) == O_MSB)  
  42. /* ----------------------------------------------------- */
  43. /*      Search for a label that fits the description     */
  44. /* ----------------------------------------------------- */
  45. #define found( p, x)  (p && p->hash == x)
  46.  
  47. #define einlinker( head, tail, last, used, p)            \
  48.    if( last)                                             \
  49.    {                                                     \
  50.       MESS("last was there");                            \
  51.       if( last->before)                                  \
  52.       {                                                  \
  53.          MESS("last->before exists");                    \
  54.          last->before->next = p;                         \
  55.          p->before = last->before;                       \
  56.          p->next   = last;                               \
  57.       }                                                  \
  58.       else                                               \
  59.       {                                                  \
  60.          MESS("last->before does not exist");            \
  61.          p->before = 0;                                  \
  62.          p->next   = head[used];                         \
  63.          head[ used] = p;                                \
  64.       }                                                  \
  65.       p->next->before = p;                               \
  66.    }                                                     \
  67.    else                                                  \
  68.       if( tail[used])                                    \
  69.       {                                                  \
  70.          MESS("tail exists");                            \
  71.          tail[used]->next = p;                           \
  72.          p->before  = tail[used];                        \
  73.          p->next    = 0;                                 \
  74.          tail[used] = p;                                 \
  75.       }                                                  \
  76.       else                                               \
  77.       {                                                  \
  78.          MESS("head & tail created");                    \
  79.          head[used] = tail[used] = p;                    \
  80.          p->next = p->before = 0;                        \
  81.       }
  82.  
  83. #define auslinker( head, tail, last, used, p)            \
  84.    if( head[ used] == p)                                 \
  85.    {                                                     \
  86.       if( head[ used] = p->next)                         \
  87.          p->next->before = 0;                            \
  88.    }                                                     \
  89.    else                                                  \
  90.       p->before->next = p->next;                         \
  91.    if( tail[ used] == p)                                 \
  92.    {                                                     \
  93.       if( tail[ used] = p->before)                       \
  94.          tail[ used]->next = 0;                          \
  95.    }                                                     \
  96.    else                                                  \
  97.       p->next->before = p->before
  98.  
  99. #endif
  100.  
  101.