/* This subroutine prints a line of output for the assembler.
 *
 * $Log: printl.c,v $
 * Revision 1.2  1997/06/04 01:15:46  david
 * ANSI-fied the program.
 *
 */

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

static char *RcsId = "$Id: printl.c,v 1.2 1997/06/04 01:15:46 david Exp $";

/* cloc = Current Location (Or value of EQU) */
/* objcode = Pointer to objcode string */
/* comment = True if this is a comment */
/* lptr =  Pointer to original line of code */
void printl( long cloc, char *objcode, char comment, char *lptr )
{
char temp, *tptr, sloc[5];
	
if ( pass != 2 )
   return;

sprintf( sloc, "%04x", cloc );
for ( tptr = sloc; *tptr != '\0'; tptr++ )
   if ( *tptr >= 'a' && *tptr <= 'z' )
      *tptr -= 0x20;
	   
if ( objcode != NULL )
   {
   temp = objcode[10]; /* Force objcode output to 10 characters */
   objcode[10] = '\0';
   for ( tptr = objcode; *tptr != '\0'; tptr++ )
      if ( *tptr >= 'a' && *tptr <= 'z' )
	 *tptr -= 0x20;
   }

if ( comment ) /* Do we want to print a line with only a comment? */
   if ( cloc == -1 )
      printf( "                  %s\n", lptr ); /* Comment */
    else
      printf( "%s              %s\n", sloc, lptr ); /* +LOC*/
 else
   if ( objcode == NULL )
	    /* Print psuedo operation code line */
      printf( "%s              %s\n", sloc, lptr );
    else
      if ( cloc == -1 )
	 printf( "      %-10s\n", objcode ); /* String Overflow format */
       else /* Print regular format */
         printf( "%s  %-10s  %s\n", sloc, objcode, lptr );
	 
if ( objcode != NULL )
   objcode[10] = temp;
}
