Initial revision
This commit is contained in:
parent
1d66c1aa53
commit
61c04182b8
32
doc/em/int/Makefile
Normal file
32
doc/em/int/Makefile
Normal file
|
@ -0,0 +1,32 @@
|
|||
CFLAGS=-O
|
||||
HOME=../../..
|
||||
|
||||
install \
|
||||
all: em emdmp tables
|
||||
|
||||
tables: mktables $(HOME)/util/ass/ip_spec.t
|
||||
mktables $(HOME)/util/ass/ip_spec.t tables
|
||||
|
||||
mktables: mktables.c $(HOME)/h/em_spec.h $(HOME)/h/em_flag.h \
|
||||
$(HOME)/util/data/em_data.a $(HOME)/util/ass/ip_spec.h
|
||||
cc -O -o mktables mktables.c $(HOME)/util/data/em_data.a
|
||||
|
||||
em.out: em.p
|
||||
apc -mint -O em.p >emerrs ; mv e.out em.out
|
||||
|
||||
em: em.p
|
||||
apc -O -i em.p >emerrs ; mv a.out em
|
||||
|
||||
nem.p: em.p
|
||||
sed -e '/maxadr = t16/s//maxadr =t15/' -e '/maxdata = 8191; /s//maxdata = 14335;/' -e '/ adr=.*long/s// adr= 0..maxadr/' <em.p >nem.p
|
||||
|
||||
nem: nem.p
|
||||
apc -O -i nem.p >emerrs ; mv a.out nem
|
||||
|
||||
emdmp: emdmp.c
|
||||
cc -o emdmp -O emdmp.c
|
||||
|
||||
cmp:
|
||||
|
||||
pr:
|
||||
@pr em.p mktables.c emdmp.c
|
5
doc/em/int/READ_ME
Normal file
5
doc/em/int/READ_ME
Normal file
|
@ -0,0 +1,5 @@
|
|||
This interpreter is meant for inclusion in the EM manual.
|
||||
Although slow, it showed decent behaviour on several tests.
|
||||
The only monitor calls implemented are exit, read(untested),
|
||||
write and ioctl - just reurns the correct code for telling it's
|
||||
a terminal -
|
1767
doc/em/int/em.p
Normal file
1767
doc/em/int/em.p
Normal file
File diff suppressed because it is too large
Load diff
210
doc/em/int/emdmp.c
Normal file
210
doc/em/int/emdmp.c
Normal file
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
* This product is part of the Amsterdam Compiler Kit.
|
||||
*
|
||||
* Permission to use, sell, duplicate or disclose this software must be
|
||||
* obtained in writing. Requests for such permissions may be sent to
|
||||
*
|
||||
* Dr. Andrew S. Tanenbaum
|
||||
* Wiskundig Seminarium
|
||||
* Vrije Universiteit
|
||||
* Postbox 7161
|
||||
* 1007 MC Amsterdam
|
||||
* The Netherlands
|
||||
*
|
||||
*/
|
||||
|
||||
/* Author: E.G. Keizer */
|
||||
|
||||
/* Print a readable version of the data in the post mortem dump */
|
||||
/* dmpc [-s] [-dn,m] [file] */
|
||||
|
||||
#include "/usr/em/h/local.h"
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int dflag = 0 ;
|
||||
long l_low,l_high;
|
||||
|
||||
int sflag;
|
||||
|
||||
int wsize,asize;
|
||||
long tsize,dsize;
|
||||
long ignmask,uerrorproc,cause;
|
||||
long pc,sp,lb,hp,pd,pb;
|
||||
|
||||
char *cstr[] = {
|
||||
"Array bound error",
|
||||
"Range bound error",
|
||||
"Set error",
|
||||
"Integer overflow",
|
||||
"Float overflow",
|
||||
"Float underflow",
|
||||
"Divide by 0",
|
||||
"Divide by 0.0",
|
||||
"Integer undefined",
|
||||
"Float undefined",
|
||||
"Conversion error",
|
||||
"User error 11",
|
||||
"User error 12",
|
||||
"User error 13",
|
||||
"User error 14",
|
||||
"User error 15",
|
||||
"Stack overflow",
|
||||
"Heap overflow",
|
||||
"Illegal instruction",
|
||||
"Illegal size parameter",
|
||||
"Case error",
|
||||
"Memory fault",
|
||||
"Illegal pointer",
|
||||
"Illegal pc",
|
||||
"Bad argument of LAE",
|
||||
"Bad monitor call",
|
||||
"Bad line number",
|
||||
"GTO descriptor error"
|
||||
};
|
||||
|
||||
FILE *fcore;
|
||||
char *core = "core" ;
|
||||
int nbyte=0;
|
||||
|
||||
char *pname;
|
||||
|
||||
int readbyte();
|
||||
int read2();
|
||||
long readaddr();
|
||||
long readword();
|
||||
unsigned getbyte();
|
||||
long getword();
|
||||
long getaddr();
|
||||
|
||||
main(argc,argv) char **argv;
|
||||
{
|
||||
register i ;
|
||||
long line,fileaddr;
|
||||
char tok ;
|
||||
|
||||
scanargs(argc,argv); fcore=fopen(core,"r") ;
|
||||
if ( fcore==NULL ) fatal("Can't open %s",core) ;
|
||||
|
||||
if ( read2()!=010255 ) fatal("not a post mortem dump");
|
||||
if ( read2()!=VERSION ) fatal("wrong version dump file");
|
||||
wsize=read2(); asize=read2();
|
||||
if ( wsize>4 ) fatal("cannot handle word size %d",wsize) ;
|
||||
if ( asize>4 ) fatal("cannot handle pointer size %d",asize) ;
|
||||
tsize=readaddr(); dsize=readaddr();
|
||||
ignmask=readaddr(); uerrorproc=readaddr(); cause=readaddr();
|
||||
pc=readaddr(); sp=readaddr(); lb=readaddr(); hp=readaddr();
|
||||
pd=readaddr(); pb=readaddr();
|
||||
if ( sflag==0 ) {
|
||||
line=getword(0L);
|
||||
fileaddr=getaddr(4L);
|
||||
if ( fileaddr ) {
|
||||
for ( i=0 ; i<40 ; i++ ) {
|
||||
tok=getbyte(fileaddr++) ;
|
||||
if ( !isprint(tok) ) break ;
|
||||
putc(tok,stdout);
|
||||
}
|
||||
printf(" ");
|
||||
}
|
||||
if ( line ) {
|
||||
printf("line %D",line) ;
|
||||
}
|
||||
if ( fileaddr || line ) printf(", ");
|
||||
fseek(fcore,512L,0);
|
||||
|
||||
if ( cause>27 ) {
|
||||
printn("cause",cause) ;
|
||||
} else {
|
||||
prints("cause",cstr[(int)cause]);
|
||||
}
|
||||
printn("pc",pc);printn("sp",sp);printn("lb",lb);
|
||||
printn("hp",hp);
|
||||
if ( pd ) printn("pd",pd) ;
|
||||
if ( pb ) printn("pb",pb) ;
|
||||
printn("errproc",uerrorproc) ;
|
||||
printn("ignmask",ignmask) ;
|
||||
if ( tsize ) printn("Text size",tsize) ;
|
||||
if ( dsize ) printn("Data size",dsize) ;
|
||||
}
|
||||
if ( dflag==0 ) return 0;
|
||||
fatal("d-flag not implemeted (yet)");
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
scanargs(argc,argv) char **argv ; {
|
||||
pname=argv[0];
|
||||
while ( argv++, argc-- > 1 ) {
|
||||
switch( argv[0][0] ) {
|
||||
case '-': switch( argv[0][1] ) {
|
||||
case 's': sflag++ ; break ;
|
||||
case 'l': dflag++ ; break ;
|
||||
default : fatal(": [-s] [-ln.m] [file]") ;
|
||||
} ;
|
||||
break ;
|
||||
default :core=argv[0] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prints(s1,s2) char *s1,*s2; {
|
||||
printf("%-15s %s\n",s1,s2);
|
||||
}
|
||||
|
||||
printn(s1,d) char *s1; long d; {
|
||||
printf("%-15s %15ld\n",s1,d);
|
||||
}
|
||||
|
||||
/* VARARGS1 */
|
||||
fatal(s1,p1,p2,p3,p4,p5) char *s1 ; {
|
||||
fprintf(stderr,"%s: ",pname);
|
||||
fprintf(stderr,s1,p1,p2,p3,p4,p5) ;
|
||||
fprintf(stderr,"\n") ;
|
||||
exit(1) ;
|
||||
}
|
||||
|
||||
int getb() {
|
||||
int i ;
|
||||
i=getc(fcore) ;
|
||||
if ( i==EOF ) fatal("Premature EOF");
|
||||
return i&0377 ;
|
||||
}
|
||||
|
||||
int read2() {
|
||||
int i ;
|
||||
i=getb() ; return getb()*256 + i ;
|
||||
}
|
||||
|
||||
long readaddr() {
|
||||
long res ;
|
||||
register int i ;
|
||||
|
||||
res=0 ;
|
||||
for (i=0 ; i<asize ; i++ ) res |= getb()<<(8*i) ;
|
||||
return res ;
|
||||
}
|
||||
|
||||
long readword() {
|
||||
long res ;
|
||||
register int i ;
|
||||
|
||||
res=0 ;
|
||||
for (i=0 ; i<wsize ; i++ ) res |= getb()<<(8*i) ;
|
||||
return res ;
|
||||
}
|
||||
|
||||
unsigned getbyte(a) long a ; {
|
||||
fseek(fcore,a+512,0) ;
|
||||
return getb() ;
|
||||
}
|
||||
|
||||
long getword(a) long a ; {
|
||||
fseek(fcore,a+512,0) ;
|
||||
return readword() ;
|
||||
}
|
||||
|
||||
long getaddr(a) long a ; {
|
||||
fseek(fcore,a+512,0) ;
|
||||
return readaddr() ;
|
||||
}
|
244
doc/em/int/mktables.c
Normal file
244
doc/em/int/mktables.c
Normal file
|
@ -0,0 +1,244 @@
|
|||
/*
|
||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||
*
|
||||
* This product is part of the Amsterdam Compiler Kit.
|
||||
*
|
||||
* Permission to use, sell, duplicate or disclose this software must be
|
||||
* obtained in writing. Requests for such permissions may be sent to
|
||||
*
|
||||
* Dr. Andrew S. Tanenbaum
|
||||
* Wiskundig Seminarium
|
||||
* Vrije Universiteit
|
||||
* Postbox 7161
|
||||
* 1007 MC Amsterdam
|
||||
* The Netherlands
|
||||
*
|
||||
*/
|
||||
|
||||
/* Author: E.G. Keizer */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "/usr/em/util/ass/ip_spec.h"
|
||||
#include "/usr/em/h/em_spec.h"
|
||||
#include "/usr/em/h/em_flag.h"
|
||||
|
||||
/* This program reads the human readable interpreter specification
|
||||
and produces a efficient machine representation that can be
|
||||
translated by a C-compiler.
|
||||
*/
|
||||
|
||||
#define ESCAP 256
|
||||
|
||||
int nerror = 0 ;
|
||||
int atend = 0 ;
|
||||
int line = 1 ;
|
||||
int maxinsl= 0 ;
|
||||
|
||||
extern char em_mnem[][4] ;
|
||||
char esca[] = "escape" ;
|
||||
#define ename(no) ((no)==ESCAP?esca:em_mnem[(no)])
|
||||
|
||||
extern char em_flag[] ;
|
||||
|
||||
main(argc,argv) char **argv ; {
|
||||
if ( argc>1 ) {
|
||||
if ( freopen(argv[1],"r",stdin)==NULL) {
|
||||
fatal("Cannot open %s",argv[1]) ;
|
||||
}
|
||||
}
|
||||
if ( argc>2 ) {
|
||||
if ( freopen(argv[2],"w",stdout)==NULL) {
|
||||
fatal("Cannot create %s",argv[2]) ;
|
||||
}
|
||||
}
|
||||
if ( argc>3 ) {
|
||||
fatal("%s [ file [ file ] ]",argv[0]) ;
|
||||
}
|
||||
atend=0 ;
|
||||
readin();
|
||||
atend=1 ;
|
||||
return nerror ;
|
||||
}
|
||||
|
||||
readin() {
|
||||
char *ident();
|
||||
char *firstid ;
|
||||
int opcode,flags;
|
||||
int c;
|
||||
|
||||
while ( !feof(stdin) ) {
|
||||
firstid=ident() ;
|
||||
if ( *firstid=='\n' || feof(stdin) ) continue ;
|
||||
opcode = getmnem(firstid) ;
|
||||
printf("%d ",opcode+1) ;
|
||||
flags = decflag(ident(),opcode) ;
|
||||
switch(em_flag[opcode]&EM_PAR) {
|
||||
case PAR_D: case PAR_F: case PAR_B: case PAR_L: case PAR_C:
|
||||
putchar('S') ;
|
||||
}
|
||||
putchar(' ');
|
||||
while ( (c=readchar())!='\n' && c!=EOF ) putchar(c) ;
|
||||
putchar('\n') ;
|
||||
}
|
||||
}
|
||||
|
||||
char *ident() {
|
||||
/* skip spaces and tabs, anything up to space,tab or eof is
|
||||
a identifier.
|
||||
Anything from # to end-of-line is an end-of-line.
|
||||
End-of-line is an identifier all by itself.
|
||||
*/
|
||||
|
||||
static char array[200] ;
|
||||
register int c ;
|
||||
register char *cc ;
|
||||
|
||||
do {
|
||||
c=readchar() ;
|
||||
} while ( c==' ' || c=='\t' ) ;
|
||||
for ( cc=array ; cc<&array[(sizeof array) - 1] ; cc++ ) {
|
||||
if ( c=='#' ) {
|
||||
do {
|
||||
c=readchar();
|
||||
} while ( c!='\n' && c!=EOF ) ;
|
||||
}
|
||||
*cc = c ;
|
||||
if ( c=='\n' && cc==array ) break ;
|
||||
c=readchar() ;
|
||||
if ( c=='\n' ) {
|
||||
pushback(c) ;
|
||||
break ;
|
||||
}
|
||||
if ( c==' ' || c=='\t' || c==EOF ) break ;
|
||||
}
|
||||
*++cc=0 ;
|
||||
return array ;
|
||||
}
|
||||
|
||||
int getmnem(str) char *str ; {
|
||||
char (*ptr)[4] ;
|
||||
|
||||
for ( ptr = em_mnem ; *ptr<= &em_mnem[sp_lmnem][0] ; ptr++ ) {
|
||||
if ( strcmp(*ptr,str)==0 ) return (ptr-em_mnem) ;
|
||||
}
|
||||
error("Illegal mnemonic") ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
error(str,a1,a2,a3,a4,a5,a6) /* VARARGS1 */ char *str ; {
|
||||
if ( !atend ) fprintf(stderr,"line %d: ",line) ;
|
||||
fprintf(stderr,str,a1,a2,a3,a4,a5,a6) ;
|
||||
fprintf(stderr,"\n");
|
||||
nerror++ ;
|
||||
}
|
||||
|
||||
mess(str,a1,a2,a3,a4,a5,a6) /* VARARGS1 */ char *str ; {
|
||||
if ( !atend ) fprintf(stderr,"line %d: ",line) ;
|
||||
fprintf(stderr,str,a1,a2,a3,a4,a5,a6) ;
|
||||
fprintf(stderr,"\n");
|
||||
}
|
||||
|
||||
fatal(str,a1,a2,a3,a4,a5,a6) /* VARARGS1 */ char *str ; {
|
||||
error(str,a1,a2,a3,a4,a5,a6) ;
|
||||
exit(1) ;
|
||||
}
|
||||
|
||||
#define ILLGL -1
|
||||
|
||||
check(val) int val ; {
|
||||
if ( val!=ILLGL ) error("Illegal flag combination") ;
|
||||
}
|
||||
|
||||
int decflag(str,opc) char *str ; {
|
||||
int type ;
|
||||
int escape ;
|
||||
int range ;
|
||||
int wordm ;
|
||||
int notzero ;
|
||||
char c;
|
||||
|
||||
type=escape=range=wordm=notzero= ILLGL ;
|
||||
while ( c= *str++ ) {
|
||||
switch ( c ) {
|
||||
case 'm' :
|
||||
check(type) ; type=OPMINI ; break ;
|
||||
case 's' :
|
||||
check(type) ; type=OPSHORT ; break ;
|
||||
case '-' :
|
||||
check(type) ; type=OPNO ;
|
||||
if ( (em_flag[opc]&EM_PAR)==PAR_W ) c='i' ;
|
||||
break ;
|
||||
case '1' :
|
||||
check(type) ; type=OP8 ; break ;
|
||||
case '2' :
|
||||
check(type) ; type=OP16 ; break ;
|
||||
case '4' :
|
||||
check(type) ; type=OP32 ; break ;
|
||||
case '8' :
|
||||
check(type) ; type=OP64 ; break ;
|
||||
case 'e' :
|
||||
check(escape) ; escape=0 ; break ;
|
||||
case 'N' :
|
||||
check(range) ; range= 2 ; break ;
|
||||
case 'P' :
|
||||
check(range) ; range= 1 ; break ;
|
||||
case 'w' :
|
||||
check(wordm) ; wordm=0 ; break ;
|
||||
case 'o' :
|
||||
check(notzero) ; notzero=0 ; break ;
|
||||
default :
|
||||
error("Unknown flag") ;
|
||||
}
|
||||
putchar(c);
|
||||
}
|
||||
if ( type==ILLGL ) error("Type must be specified") ;
|
||||
switch ( type ) {
|
||||
case OP64 :
|
||||
case OP32 :
|
||||
if ( escape!=ILLGL ) error("Conflicting escapes") ;
|
||||
escape=ILLGL ;
|
||||
case OP16 :
|
||||
case OP8 :
|
||||
case OPSHORT :
|
||||
case OPNO :
|
||||
if ( notzero!=ILLGL ) mess("Improbable OPNZ") ;
|
||||
if ( type==OPNO && range!=ILLGL ) {
|
||||
mess("No operand in range") ;
|
||||
}
|
||||
}
|
||||
if ( escape!=ILLGL ) type|=OPESC ;
|
||||
if ( wordm!=ILLGL ) type|=OPWORD ;
|
||||
switch ( range) {
|
||||
case ILLGL : type|=OP_BOTH ; break ;
|
||||
case 1 : type|=OP_POS ; break ;
|
||||
case 2 : type|=OP_NEG ; break ;
|
||||
}
|
||||
if ( notzero!=ILLGL ) type|=OPNZ ;
|
||||
return type ;
|
||||
}
|
||||
|
||||
static int pushchar ;
|
||||
static int pushf ;
|
||||
|
||||
int readchar() {
|
||||
int c ;
|
||||
|
||||
if ( pushf ) {
|
||||
pushf=0 ;
|
||||
c = pushchar ;
|
||||
} else {
|
||||
if ( feof(stdin) ) return EOF ;
|
||||
c=getc(stdin) ;
|
||||
}
|
||||
if ( c=='\n' ) line++ ;
|
||||
return c ;
|
||||
}
|
||||
|
||||
pushback(c) {
|
||||
if ( pushf ) {
|
||||
fatal("Double pushback") ;
|
||||
}
|
||||
pushf++ ;
|
||||
pushchar=c ;
|
||||
if ( c=='\n' ) line-- ;
|
||||
}
|
Loading…
Reference in a new issue