/*
 * This subroutine sets symbols equ to a certain value only during pass
 * number 1.
 *
 * $Log: equ.c,v $
 * Revision 1.2  1997/06/04 01:07:38  david
 * ANSI-fied the program.
 *
 */
 
#include <stdio.h>
#include "xasm.h"

static char *RcsId = "$Id: equ.c,v 1.2 1997/06/04 01:07:38 david Exp $";

void equ( char *label, char *opcode, char *operand, char *lptr )
{
WORD value;
char *opercode, muldef;
static char *Error = "equ: No label.";
	
labproc( label );

if ( pass == 2 )
   if ( strcmp( opcode, "equ" ) == 0 )
      {
      value = 0;
      if ( symfind( label, &value, 0 ) != 'D' ) /* Don't reference Xref */
         xerror( "equ: Undefined Symbol." );
      printl( (long) value, NULL, 0, lptr );
      return;
      }

if ( label == NULL || *label == '\0' )
   {
   xerror( Error );
   return;
   }

muldef = symfind( label, &value, 0 ); /* Don't reference Xref Table */

if ( muldef == 'M' )
   if ( strcmp( opcode, "equ" ) == 0 )
      {
      xerror( "equ: Label Already Defined." );
      return;
      }
   
if ( *operand )
   {
   if ( !(opercode = proper( label, opcode, operand, NULL ) ) )
      xerror( "equ: No Operand Code." );
   symins( label, atoh( opercode ), 'D' ); /* label is defined here */
   }
 else
   xerror( "equ: No Operand" );
}
