1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1987-03-09 19:15:41 +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-26 15:04:22 +00:00
|
|
|
/* S H A R E D F I L E
|
|
|
|
*
|
|
|
|
* D E B U G . C
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
#include <stdarg.h>
|
1984-11-26 15:04:22 +00:00
|
|
|
#include <stdio.h>
|
2017-11-15 21:29:27 +00:00
|
|
|
#include <stdlib.h>
|
1991-03-05 12:44:05 +00:00
|
|
|
#include <em_spec.h>
|
1984-11-26 15:04:22 +00:00
|
|
|
#include "types.h"
|
|
|
|
#include "def.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int linecount; /* # lines in this file */
|
|
|
|
bool verbose_flag = FALSE; /* generate verbose output ? */
|
|
|
|
|
|
|
|
/* VARARGS1 */
|
2017-11-15 21:29:27 +00:00
|
|
|
void error(const char *s, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
1984-11-26 15:04:22 +00:00
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
va_start(ap, s);
|
1984-11-26 15:04:22 +00:00
|
|
|
fprintf(stderr,"error on line %u",linecount);
|
|
|
|
if (filename != (char *) 0) {
|
|
|
|
fprintf(stderr," file %s",filename);
|
|
|
|
}
|
|
|
|
fprintf(stderr,": ");
|
2017-11-15 21:29:27 +00:00
|
|
|
vfprintf(stderr,s,ap);
|
1984-11-26 15:04:22 +00:00
|
|
|
fprintf(stderr,"\n");
|
|
|
|
abort();
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef TRACE
|
|
|
|
/* VARARGS1 */
|
2017-11-15 21:29:27 +00:00
|
|
|
void OUTTRACE(const char *s, int n)
|
1984-11-26 15:04:22 +00:00
|
|
|
{
|
|
|
|
fprintf(stderr,"> ");
|
2018-03-01 18:19:38 +00:00
|
|
|
fprintf(stderr,s,n);
|
1984-11-26 15:04:22 +00:00
|
|
|
fprintf(stderr,"\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef VERBOSE
|
|
|
|
/* VARARGS1 */
|
2017-11-15 21:29:27 +00:00
|
|
|
void OUTVERBOSE(const char *s, int n1, int n2)
|
1984-11-26 15:04:22 +00:00
|
|
|
{
|
|
|
|
if (verbose_flag) {
|
|
|
|
fprintf(stderr,"optimization: ");
|
|
|
|
fprintf(stderr,s,n1,n2);
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
/* Valid Address */
|
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
void VA(short *a) {
|
1984-11-26 15:04:22 +00:00
|
|
|
if (a == (short *) 0) error("VA: 0 argument");
|
|
|
|
if ( ((unsigned) a & 01) == 01) {
|
|
|
|
/* MACHINE DEPENDENT TEST */
|
|
|
|
error("VA: odd argument");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Valid Instruction code */
|
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
void VI(short i) {
|
1984-11-26 15:04:22 +00:00
|
|
|
if (i > ps_last) error("VI: illegal instr: %d", i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Valid Line */
|
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
void VL(line_p l) {
|
1984-11-26 15:04:22 +00:00
|
|
|
byte instr, optype;
|
|
|
|
|
|
|
|
VA((short *) l);
|
|
|
|
instr = l->l_instr;
|
|
|
|
VI(instr);
|
|
|
|
optype = TYPE(l);
|
|
|
|
if (optype < OP_FIRST || optype > OP_LAST) {
|
|
|
|
error("VL: illegal optype: %d", optype);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Valid Data block */
|
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
void VD(dblock_p d) {
|
1984-11-26 15:04:22 +00:00
|
|
|
byte pseudo;
|
|
|
|
|
|
|
|
VA((short *) d);
|
|
|
|
pseudo = d->d_pseudo;
|
|
|
|
if (pseudo < D_FIRST || pseudo > D_LAST) {
|
|
|
|
error("VD: illegal pseudo: %d",pseudo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Valid Object */
|
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
void VO(obj_p o) {
|
1984-11-26 15:04:22 +00:00
|
|
|
offset off;
|
|
|
|
|
|
|
|
VA((short *) o);
|
|
|
|
off = o->o_off;
|
|
|
|
if (off < 0 || off > 10000) {
|
|
|
|
error("VO: unlikely offset: %d", off);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Valid Proc */
|
|
|
|
|
2017-11-15 21:29:27 +00:00
|
|
|
void VP(proc_p p) {
|
1984-11-26 15:04:22 +00:00
|
|
|
proc_id pid;
|
|
|
|
int nrlabs;
|
|
|
|
|
|
|
|
VA((short *) p);
|
|
|
|
pid = p->p_id;
|
|
|
|
if (pid <0 || pid > 1000) {
|
|
|
|
error("VP: unlikely proc_id: %d", (int) pid);
|
|
|
|
}
|
|
|
|
nrlabs = p->p_nrlabels;
|
|
|
|
if (nrlabs < 0 || nrlabs > 500) {
|
|
|
|
error("VP: unlikely p_nrlabels: %d", nrlabs);
|
|
|
|
}
|
|
|
|
}
|
1988-09-02 13:55:54 +00:00
|
|
|
#endif
|