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

  1. /* ---------------------------------------------------------------------- */
  2. /*                   Copyright (C) 1991 by Natürlich!                     */
  3. /*                      This file is copyrighted!                         */
  4. /*                Refer to the documentation for details.                 */
  5. /* ---------------------------------------------------------------------- */
  6. #include "defines.h"
  7. #include "nasm.h"
  8. #include "debug.h"
  9. #include "labels.h"
  10. #include OSBIND
  11. #include NMALLOC_H
  12.  
  13. label huge  *h_macro[SEP],  huge *t_macro[SEP],  huge *l_macro,
  14.       huge  *h_local[SEP],  huge *t_local[SEP],  huge *l_local,
  15.       huge  *h_global[SEP], huge *t_global[SEP], huge *l_global;
  16. int         u_local, u_macro, u_global;
  17. lword       l_hash;
  18.  
  19. char  err_defined[] = "label already defined",
  20.       warn_0fwd[]   = "assumed 2-byte fwd address was i.e. zeropage",
  21.       warn_equfwd[] = ".= label was fwd referenced";
  22.  
  23. #undef  X
  24. #if LINKER
  25. #define X 0
  26. #else
  27. #define X 30
  28. #endif
  29.  
  30. /* This is a conversion table to extract a more or less significant */
  31. /* 5 bit hash value out of a 7 bit ascii char. this will be stored  *
  32. /* into ->hash as .aaaaabbbbbccccc .dddddeeeefffff                  */
  33.  
  34. char  hash_tab[] =
  35. {
  36.     0, 1, 2, 3,   4, 5, 6, 7,   8, 9,10,11,  12,13,14,15, /* $ 0 */
  37.    16,17,18,19,  20,21,22,23,  24,25,26,27,  28,29,30,31, /* $10 */
  38.    27,28,29,30,  31,17,22,10,  23,26,31,30,  29,28,27,26, /* $20 */
  39.    25,24,23,22,  21,20,19,18,  17,16,15,14,  13,12,11,10, /* $30 */
  40.  
  41.     9, 1, 2, 3,   4, 5, 6, 7,   8, 9,10,11,  12,13,14,15, /* $40 */
  42.    16,17,18,19,  20,21,22,23,  24,25,26, 8,   7, 6, 5, 4, /* $50 */
  43.     3, 2, 1, 2,   3, 4, 5, 6,   7, 8, 9,10,  11,12,13,14, /* $60 */
  44.    15,16,17,18,  18,20,21,22,  23,24,25,26,  27,28,29,30, /* $70 */
  45. };
  46.  
  47. /* if you change the is_where order for some reason, you'd need  */
  48. /* to look at VfL variables (probably) and at  "clean_mats"      */    
  49.  
  50. char  is_where[] =
  51. {
  52.     0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0, /* $ 0 */
  53.     0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0, /* $10 */
  54.     0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 2, 0, /* $20 */
  55.     0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0, /* $30 */
  56.  
  57.     1, 3, 4, 5,   6, 7, 8, 9,  10,11,12,13,  14,15,16,17, /* $40 */
  58.    18,19,20,21,  22,23,24,25,  26,27,28, 0,   0, 0, 0,29, /* $50 */
  59.     0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0, /* $60 */
  60.     0, 0, 0, 0,   0, 0, 0, 0,   0, 0, 0, 0,   X, 0, 0, 0  /* $70 */
  61. };
  62. #undef X
  63.  
  64. /* ---------------------------------------------------------- */
  65. /*                Mallocer for the labelstructure             */
  66. /*                                                            */
  67. /*   (Keeping the fingers crossed that this is faster than a) */
  68. /*                       (simple malloc)                      */
  69. /*                Mallocer for the local labels               */
  70. /* Hold on. I don't get it. Why TWO mallocers for labels?     */
  71. /* The point is that global label space is never freed until  */
  72. /* assembly is completed, whereas local label space is freed  */
  73. /* whenever a .LOCAL appears. Since we like to reclaim memory */
  74. /* We need a different mallocer (+ freeer)                    */
  75. /* ---------------------------------------------------------- */
  76. make_mallocer( label, LABMAX, lab_alloc)
  77.  
  78. dup_mallocer( label, LLABMAX, llab_alloc, l)
  79.  
  80.  
  81. void llab_free()
  82. {
  83.    register label_m huge   *p = llabel_h,
  84.                     huge   *q;               /* q for multitaskin' (har) */
  85.  
  86.    ENTER("llab_free");
  87.    if( p)
  88.       for(;;)
  89.       {
  90.          if( ! p->before)
  91.          {
  92.             p->free  = LLABMAX;
  93.             p->tab   = (label *) ((char huge *) p + sizeof( label_m));
  94.             llabel_h = p;
  95.             LEAVE();
  96.             return;
  97.          }
  98.          q = p;
  99.          p = p->before;
  100.          nfree( (void *) q);
  101.       }
  102.    LEAVE();
  103. }
  104.