extnd.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #include <system.h>
  2. #include <out.h>
  3. #include <em.h>
  4. #include "header.h"
  5. #include "back.h"
  6. #include "mach.h"
  7. #if __STDC__
  8. #include <stdarg.h>
  9. #else
  10. #include <varargs.h>
  11. #endif
  12. /* Mysprint() stores the string directly in the string_arae. This saves
  13. * a copy action. It is assumed that the strings stored in the string-table
  14. * are never longer than MAXSTRLEN bytes.
  15. */
  16. #define MAXSTRLEN 1024
  17. #if __STDC__
  18. /*VARARGS*/
  19. static int mysprint(char *fmt, ...)
  20. {
  21. va_list args;
  22. int retval;
  23. va_start(args, fmt);
  24. while (string + MAXSTRLEN - string_area > size_string)
  25. mem_string();
  26. retval = _format(string, fmt, args);
  27. string[retval] = '\0';
  28. va_end(args);
  29. return retval;
  30. }
  31. #else
  32. /*VARARGS*/
  33. static int mysprint(va_alist)
  34. va_dcl
  35. {
  36. char *fmt;
  37. va_list args;
  38. int retval;
  39. va_start(args);
  40. fmt = va_arg(args, char *);
  41. while (string + MAXSTRLEN - string_area > size_string)
  42. mem_string();
  43. retval = _format(string, fmt, args);
  44. string[retval] = '\0';
  45. va_end(args);
  46. return retval;
  47. }
  48. #endif
  49. /* The extnd_*()s make a name unique. The resulting string is directly stored
  50. * in the symbol_table (by mysprint()). Later additional fields in the
  51. * symbol_table are filled. For these actions the values of the index in
  52. * the symbol_table and the length of the string are stored.
  53. */
  54. extern int string_lengte, index_symbol_table;
  55. char *extnd_pro( prcno)
  56. int prcno;
  57. {
  58. string_lengte = mysprint( "%cprc%d", GENLAB, prcno);
  59. index_symbol_table = find_sym( string, STORE_STRING);
  60. return( symbol_table[ index_symbol_table].on_foff + string_area);
  61. }
  62. char *extnd_start( prcno)
  63. int prcno;
  64. {
  65. string_lengte = mysprint( "%cstrt%d", GENLAB, prcno);
  66. index_symbol_table = find_sym( string, STORE_STRING);
  67. return( symbol_table[ index_symbol_table].on_foff + string_area);
  68. }
  69. char *extnd_name( s)
  70. char *s;
  71. {
  72. string_lengte = mysprint( NAME_FMT, s);
  73. index_symbol_table = find_sym( string, STORE_STRING);
  74. return( string_area + symbol_table[ index_symbol_table].on_foff);
  75. }
  76. char *extnd_dnam( s)
  77. char *s;
  78. {
  79. string_lengte = mysprint( DNAM_FMT, s);
  80. index_symbol_table = find_sym( string, STORE_STRING);
  81. return( symbol_table[ index_symbol_table].on_foff + string_area);
  82. }
  83. char *extnd_dlb( g)
  84. label g;
  85. {
  86. string_lengte = mysprint( DLB_FMT, (long)g);
  87. index_symbol_table = find_sym( string, STORE_STRING);
  88. return( symbol_table[ index_symbol_table].on_foff + string_area);
  89. }
  90. char *extnd_ilb( l, prcno)
  91. arith l;
  92. {
  93. string_lengte = mysprint( ILB_FMT, prcno, (long) l);
  94. index_symbol_table = find_sym( string, STORE_STRING);
  95. return( symbol_table[ index_symbol_table].on_foff + string_area);
  96. }
  97. char *extnd_hol( hol)
  98. int hol;
  99. {
  100. string_lengte = mysprint( HOL_FMT, hol);
  101. index_symbol_table = find_sym( string, STORE_STRING);
  102. return( symbol_table[ index_symbol_table].on_foff + string_area);
  103. }
  104. char *extnd_part( d)
  105. int d;
  106. {
  107. string_lengte = mysprint( "%cprt%x", GENLAB, d);
  108. index_symbol_table = find_sym( string, STORE_STRING);
  109. return( symbol_table[ index_symbol_table].on_foff + string_area);
  110. }
  111. char *extnd_cont( d)
  112. int d;
  113. {
  114. string_lengte = mysprint( "%ccnt%x", GENLAB, d);
  115. index_symbol_table = find_sym( string, STORE_STRING);
  116. return( symbol_table[ index_symbol_table].on_foff + string_area);
  117. }
  118. char *extnd_main( d)
  119. int d;
  120. {
  121. string_lengte = mysprint( "%cmcnt%x", GENLAB, d);
  122. index_symbol_table = find_sym( string, STORE_STRING);
  123. return( symbol_table[ index_symbol_table].on_foff + string_area);
  124. }