1987-03-09 15:15:03 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1984-11-27 22:11:59 +00:00
|
|
|
#include "bem.h"
|
|
|
|
|
1984-11-27 23:13:28 +00:00
|
|
|
#ifndef NORSCID
|
|
|
|
static char rcs_id[] = "$Header$" ;
|
|
|
|
#endif
|
|
|
|
|
1984-11-27 22:11:59 +00:00
|
|
|
#define abs(X) (X>=0?X:-X)
|
|
|
|
/* Miscelaneous routines can be found here */
|
|
|
|
|
|
|
|
int errorcnt;
|
|
|
|
|
|
|
|
warning(str)
|
|
|
|
char *str;
|
|
|
|
{
|
1987-02-11 14:29:27 +00:00
|
|
|
if (! wflag) Xerror("WARNING",str);
|
1984-11-27 22:11:59 +00:00
|
|
|
}
|
|
|
|
error(str)
|
|
|
|
char *str;
|
|
|
|
{
|
1987-02-11 14:29:27 +00:00
|
|
|
Xerror("ERROR",str);
|
1984-11-27 22:11:59 +00:00
|
|
|
errorcnt++;
|
|
|
|
}
|
1987-02-11 14:29:27 +00:00
|
|
|
Xerror(type,str)
|
|
|
|
char *str;
|
|
|
|
char *type;
|
|
|
|
{
|
|
|
|
extern int listing,yylineno;
|
|
|
|
if( !listing) fprintf(stderr,"LINE %d:",yylineno);
|
|
|
|
fprintf(stderr,"%s:%s\n",type,str);
|
|
|
|
}
|
1984-11-27 22:11:59 +00:00
|
|
|
fatal(str)
|
|
|
|
char *str;
|
|
|
|
{
|
1987-02-11 14:29:27 +00:00
|
|
|
Xerror("FATAL",str);
|
1987-02-22 15:56:31 +00:00
|
|
|
unlink(tmpfname);
|
1984-11-27 22:11:59 +00:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
notyetimpl()
|
|
|
|
{
|
1987-02-11 14:29:27 +00:00
|
|
|
warning("not yet implemented");
|
1984-11-27 22:11:59 +00:00
|
|
|
}
|
|
|
|
illegalcmd()
|
|
|
|
{
|
1987-02-11 14:29:27 +00:00
|
|
|
warning("illegal command");
|
1984-11-27 22:11:59 +00:00
|
|
|
}
|
|
|
|
char *itoa(i)
|
|
|
|
int i;
|
|
|
|
{
|
|
|
|
static char buf[30];
|
|
|
|
sprintf(buf,"%d",i);
|
|
|
|
return(buf);
|
|
|
|
}
|
|
|
|
char *instrlabel(i)
|
|
|
|
int i;
|
|
|
|
{
|
|
|
|
static char buf[30];
|
|
|
|
sprintf(buf,"*%d",i);
|
|
|
|
return(buf);
|
|
|
|
}
|
|
|
|
char *datalabel(i)
|
|
|
|
int i;
|
|
|
|
{
|
|
|
|
static char buf[30];
|
|
|
|
if( i>0)
|
|
|
|
sprintf(buf,"l%d",i);
|
|
|
|
else sprintf(buf,"%d",-i);
|
|
|
|
return(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *salloc(length)
|
1985-01-21 14:22:07 +00:00
|
|
|
unsigned length;
|
1984-11-27 22:11:59 +00:00
|
|
|
{
|
|
|
|
char *s,*c;
|
1984-11-30 00:16:29 +00:00
|
|
|
extern char *malloc() ;
|
|
|
|
s=c= malloc(length);
|
1985-01-21 23:48:06 +00:00
|
|
|
if ( !s ) fatal("Out of memory") ;
|
1985-01-21 14:22:07 +00:00
|
|
|
while(length--)*c++ =0;
|
1984-11-27 22:11:59 +00:00
|
|
|
return(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
char * proclabel(str)
|
|
|
|
char *str;
|
|
|
|
{
|
|
|
|
static char buf[50];
|
|
|
|
sprintf(buf,"$%s",str);
|
|
|
|
return(buf);
|
|
|
|
}
|