/* This subroutine implements the EXTERN assembler directive which enters
 * the symbols in the operand into the ESD directory to be imported from other
 * object files.
 *
 * $Log: extern.c,v $
 * Revision 1.3  1997/06/04 01:09:16  david
 * ANSI-fied the program.
 *
 */

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

static char *RcsID = "$Id: extern.c,v 1.3 1997/06/04 01:09:16 david Exp $";

void external( char *label, char *opcode, char *operand, char *lptr )
{
char temp[81], *lptr1 = operand, muldef;
WORD value;

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

if ( pass != 1 )
   {
   printl( (long) -1, NULL, 1, lptr );
   return;
   }

while ( *lptr1 != '\0' )
   {
   if ( parse( &lptr1, temp, sizeof(temp) - 1, ',' ) )
      xerror ( "external: Invalid Operand." );

   if ( (muldef = symfind( temp, &value, 1 )) != ' ' )
      xerror( "external: Symbol already defined." );

   symins( temp, 0, muldef == ' ' ? 'D' : ' ' );
#ifdef ESD
   esdins( temp, 'E', 0 );
#endif /* ESD */
   if ( *lptr != '\0' )
      lptr1++;
   }
}
