/* Copyright (c) 1979 Regents of the University of California */
static char sccsid
[] = "@(#)int.c 1.8 %G%";
* px - interpreter for Berkeley Pascal
* Version 3.0 Winter 1979
* Original version for the PDP 11/70 authored by:
* Bill Joy, Charles Haley, Ken Thompson
* Rewritten for VAX 11/780 by Kirk McKusick
union progcntr
*pcaddrp
; /* address of interpreter frame address */
register char *objprog
, *file
;
register long bytesread
, bytestoread
, block
;
* Determine how PX was invoked, and how to process the program
if (!strcmp(_argv
[0], "pdx")) {
} else if (!strcmp(_argv
[0], "pix")) {
} else if (!strcmp(_argv
[0], "pipe")) {
* kludge to check for old style objs.
if (_mode
== PX
&& !strcmp(file
, "-")) {
fprintf(stderr
, "%s is obsolete and must be recompiled\n",
* Process program header information
read(pipe
,&pxhd
,sizeof(struct pxhdr
));
fread(&pxhd
,sizeof(struct pxhdr
),1,prog
);
if (pxhd
.magicnum
!= MAGICNUM
) {
fseek(prog
,(long)(HEADER_BYTES
-sizeof(struct pxhdr
)),0);
fread(&pxhd
,sizeof(struct pxhdr
),1,prog
);
if (pxhd
.magicnum
!= MAGICNUM
) {
fprintf(stderr
,"%s is not a Pascal interpreter file\n",name
);
if (pxhd
.maketime
< createtime
) {
fprintf(stderr
,"%s is obsolete and must be recompiled\n",name
);
* Load program into memory
objprog
= malloc((int)pxhd
.objsize
);
bytestoread
= pxhd
.objsize
;
block
= read(pipe
,(int)(objprog
+bytesread
),bytestoread
);
bytesread
= fread(objprog
,1,(int)pxhd
.objsize
,prog
);
if (bytesread
!= pxhd
.objsize
) {
fprintf(stderr
,"Read error occurred while loading %s\n",file
);
fputs("Execution begins...\n",stderr
);
* set interpreter to catch expected signals and begin interpretation
if (signal(SIGINT
,SIG_IGN
) != SIG_IGN
)
* See if we're being watched by the debugger, if so set a trap.
if (_mode
== PDX
|| (_mode
== PIX
&& pxhd
.symtabsize
> 0)) {
inittrap(&_display
, &_dp
, objprog
, &pcaddrp
, loopaddr
);
* reset signals, deallocate memory, and exit normally
* Generate an IOT trap to tell the debugger that the object code
* has been read in. Parameters are there for debugger to look at,
static inittrap(dispaddr
, dpaddr
, endaddr
, pcaddrp
, loopaddrp
)
union progcntr
**pcaddrp
;