/* This subroutine implements the PUBLIC assembler directive which enters
 * the symbols in the operand into the ESD directory to be exported to other
 * object files.
 *
 * $Log: public.c,v $
 * Revision 1.3  1997/06/04 01:18:52  david
 * ANSI-fied the program.
 *
 */

#include <stdio.h>
#include "xasm.h"

static char *RcsId = "$Id: public.c,v 1.3 1997/06/04 01:18:52 david Exp $";

void public( char *label, char *opcode, char *operand, char *lptr )
{
char temp[80], *lptr1 = operand;
WORD value;

if ( label != NULL && *label != '\0' )
   {
   xerror( "public: No label allowed." );
   printl( (long) -1, NULL, 1, lptr );
   return;
   }

if ( pass != 2 )
   return;

while ( *lptr1 != '\0' )
   {
   if ( parse( &lptr1, temp, sizeof(temp) - 1, ',' ) )
      {
      xerror( "public: Invalid Operand." );
      printl( (long) -1, NULL, 1, lptr );
      }

   if ( symfind( temp, &value, 1 ) != 'D' )
      xerror( "public: Symbol not defined." );

#ifdef ESD
   esdins( temp, 'P', value ); /* Insert Name, Type, and Value into ESD */
#endif /* ESD */
   if ( *lptr1 == ',' )
      lptr1++;
   }

printl( (long) -1, NULL, 1, lptr );
}
