+\f
+/*
+ * listnames outputs a list of enumerated type names which
+ * can then be selected from to output a TSCAL
+ * a pointer to the address in the code of the namelist
+ * is kept in value[ NL_ELABEL ].
+ */
+listnames(ap)
+
+ register struct nl *ap;
+{
+ struct nl *next;
+ register int oldlc, len;
+ register unsigned w;
+ register char *strptr;
+
+ if (cgenflg < 0)
+ /* code is off - do nothing */
+ return(NIL);
+ if (ap->class != TYPE)
+ ap = ap->type;
+ if (ap->value[ NL_ELABEL ] != 0) {
+ /* the list already exists */
+ return( ap -> value[ NL_ELABEL ] );
+ }
+# ifdef OBJ
+ oldlc = lc;
+ put(2, O_TRA, lc);
+ ap->value[ NL_ELABEL ] = lc;
+# endif OBJ
+# ifdef PC
+ putprintf( " .data" , 0 );
+ putprintf( " .align 1" , 0 );
+ ap -> value[ NL_ELABEL ] = getlab();
+ putlab( ap -> value[ NL_ELABEL ] );
+# endif PC
+ /* number of scalars */
+ next = ap->type;
+ len = next->range[1]-next->range[0]+1;
+# ifdef OBJ
+ put(2, O_CASE2, len);
+# endif OBJ
+# ifdef PC
+ putprintf( " .word %d" , 0 , len );
+# endif PC
+ /* offsets of each scalar name */
+ len = (len+1)*sizeof(short);
+# ifdef OBJ
+ put(2, O_CASE2, len);
+# endif OBJ
+# ifdef PC
+ putprintf( " .word %d" , 0 , len );
+# endif PC
+ next = ap->chain;
+ do {
+ for(strptr = next->symbol; *strptr++; len++)
+ continue;
+ len++;
+# ifdef OBJ
+ put(2, O_CASE2, len);
+# endif OBJ
+# ifdef PC
+ putprintf( " .word %d" , 0 , len );
+# endif PC
+ } while (next = next->chain);
+ /* list of scalar names */
+ strptr = getnext(ap, &next);
+# ifdef OBJ
+ do {
+ w = (unsigned) *strptr;
+ if (!*strptr++)
+ strptr = getnext(next, &next);
+ w |= *strptr << 8;
+ if (!*strptr++)
+ strptr = getnext(next, &next);
+ word(w);
+ } while (next);
+ /* jump over the mess */
+ patch(oldlc);
+# endif OBJ
+# ifdef PC
+ while ( next ) {
+ while ( *strptr ) {
+ putprintf( " .byte 0%o" , 1 , *strptr++ );
+ for ( w = 2 ; ( w <= 8 ) && *strptr ; w ++ ) {
+ putprintf( ",0%o" , 1 , *strptr++ );
+ }
+ putprintf( "" , 0 );
+ }
+ putprintf( " .byte 0" , 0 );
+ strptr = getnext( next , &next );
+ }
+ putprintf( " .text" , 0 );
+# endif PC
+ return( ap -> value[ NL_ELABEL ] );
+}
+
+getnext(next, new)