/* This subroutine defines bytes in memory. It also recognizes strings. */

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

void db( char *label, char *opcode, char *operand, char *lptr )
{
static char *Error = "db: No Operand.\n";
char *objcode;

labproc( label );

if ( operand == NULL || *operand == '\0' )
   {
   xerror( Error );
   return;
   }
   
while ( *operand != '\0' )
   {
   if ( *operand == '\'' )
      {
      objcode = proper( label, opcode, operand, NULL );
      do {
	 operand++;
	 } while ( *operand != '\'' && *operand != '\0' );
      if ( *operand != '\0' )
	 operand++;
      printl( (long) loc, objcode, 0, lptr );
      if ( objcode != NULL )
	 genobj( objcode );
      continue;
      }
   objcode = proper( label, opcode, operand, NULL );
   sprintf( objcode, "%02x", atoh( objcode ) );
   printl( (long) loc, objcode, 0, lptr );
   if ( objcode != NULL )
      genobj( objcode );
   locinc = 1;
   while( *operand != ',' && *operand != '\0' )
      operand++; /* Advance to next item */
   }
}
