From 4ba971e1cb4dc48c5e7c39a1f2190b01c6ca98fb Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Fri, 19 Apr 2019 16:41:37 +1000 Subject: [PATCH] Add em22 compile, change EM machine executable format to put proc table in text --- INSTALL | 4 +-- bin/lint-lib.ack | 2 ++ env.sh | 4 +-- h/as_spec.h | 2 +- n.sh | 2 +- util/ass/ass00.h | 3 +- util/ass/ass50.c | 1 - util/ass/assci.c | 2 ++ util/ass/assda.c | 1 + util/ass/assex.h | 1 + util/ass/assrl.c | 24 +++++++++------ util/ego/share/proto.make | 2 +- util/int/disassemble.c | 9 +++--- util/int/do_misc.c | 2 ++ util/int/do_proc.c | 9 +++--- util/int/dump.c | 5 ++- util/int/init.c | 1 - util/int/proctab.c | 65 +++++++++++---------------------------- util/int/proctab.h | 2 +- util/int/read.c | 17 ++-------- util/int/rsb.c | 3 +- util/int/text.c | 4 +-- 22 files changed, 69 insertions(+), 96 deletions(-) diff --git a/INSTALL b/INSTALL index 050333e..04ec9bb 100755 --- a/INSTALL +++ b/INSTALL @@ -1,14 +1,14 @@ TARGET_HOME="/home/nick/src/Ack-5.5/stage"; export TARGET_HOME UTIL_HOME="/home/nick/src/Ack-5.5/stage"; export UTIL_HOME SRC_HOME="/home/nick/src/Ack-5.5"; export SRC_HOME -SYSNAME=""; export SYSNAME +SYSNAME="ANY"; export SYSNAME ACM="z80"; export ACM CURRENT="y"; export CURRENT SYS="V7"; export SYS LIMIT="y"; export LIMIT CONFIG="/home/nick/src/Ack-5.5/build"; export CONFIG DISABLE_LANG=" Modula-2 Pascal Occam Basic Fortran"; export DISABLE_LANG -DISABLE_SUP=" i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z8000 arm"; export DISABLE_SUP +DISABLE_SUP=" i86 xenix3 minix i386 6500 6800 6805 6809 i80 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z8000 arm"; export DISABLE_SUP DO_MACHINE_INDEP="y"; export DO_MACHINE_INDEP MACH_LIST="i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z80 z8000 arm"; export MACH_LIST SYSVAX=""; export SYSVAX diff --git a/bin/lint-lib.ack b/bin/lint-lib.ack index 8c0a24a..ab6f47d 100755 --- a/bin/lint-lib.ack +++ b/bin/lint-lib.ack @@ -1,3 +1,5 @@ +#!/bin/sh + : '$Id: lint-lib.ack,v 1.2 1994/06/23 13:46:53 ceriel Exp $' : Create a lint library file. The name of the library file is constructed diff --git a/env.sh b/env.sh index 87f1205..723a1ba 100644 --- a/env.sh +++ b/env.sh @@ -1,14 +1,14 @@ TARGET_HOME="/home/nick/src/Ack-5.5/stage"; export TARGET_HOME UTIL_HOME="/home/nick/src/Ack-5.5/stage"; export UTIL_HOME SRC_HOME="/home/nick/src/Ack-5.5"; export SRC_HOME -SYSNAME=""; export SYSNAME +SYSNAME="ANY"; export SYSNAME ACM="z80"; export ACM CURRENT="y"; export CURRENT SYS="V7"; export SYS LIMIT="y"; export LIMIT CONFIG="/home/nick/src/Ack-5.5/build"; export CONFIG DISABLE_LANG=" Modula-2 Pascal Occam Basic Fortran"; export DISABLE_LANG -DISABLE_SUP=" i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z8000 arm"; export DISABLE_SUP +DISABLE_SUP=" i86 xenix3 minix i386 6500 6800 6805 6809 i80 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z8000 arm"; export DISABLE_SUP DO_MACHINE_INDEP="y"; export DO_MACHINE_INDEP MACH_LIST="i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z80 z8000 arm"; export MACH_LIST SYSVAX=""; export SYSVAX diff --git a/h/as_spec.h b/h/as_spec.h index df6c428..97f0871 100644 --- a/h/as_spec.h +++ b/h/as_spec.h @@ -3,4 +3,4 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#define as_magic (sp_magic|(14<<8)) +#define as_magic (sp_magic|(15<<8)) diff --git a/n.sh b/n.sh index d121ebb..e99f585 100755 --- a/n.sh +++ b/n.sh @@ -1,4 +1,4 @@ #!/bin/sh -#sudo apt-get install groff +#sudo apt-get install groff catdoc rm -rf build stage sh INSTALL diff --git a/util/ass/ass00.h b/util/ass/ass00.h index be58d52..09e877d 100644 --- a/util/ass/ass00.h +++ b/util/ass/ass00.h @@ -248,6 +248,7 @@ struct procs { /* format of mprocs[] and xprocs[] */ }; struct proctab { - cons_t pr_off; /* distance from pb */ cons_t pr_loc; /* number of bytes locals */ + cons_t pr_off; /* distance from pb */ + cons_t pr_len; }; diff --git a/util/ass/ass50.c b/util/ass/ass50.c index 2d7c8be..e255093 100644 --- a/util/ass/ass50.c +++ b/util/ass/ass50.c @@ -172,7 +172,6 @@ patchcase() { } for( ; r ; r= r->r_next ) { if (r->r_typ == RELLOC) { - r->r_typ = RELADR; k = r->r_val.rel_lp; if (k->l_defined==YES) r->r_val.rel_i = k->l_min + textbytes; diff --git a/util/ass/assci.c b/util/ass/assci.c index 352039a..94ce019 100644 --- a/util/ass/assci.c +++ b/util/ass/assci.c @@ -448,6 +448,8 @@ inpseudo(instr_no) { } setline(); do_proc(); + proctab[prptr->p_num].pr_len = + textbytes - proctab[prptr->p_num].pr_off; break; case ps_mes: switch( int_cast getint() ) { diff --git a/util/ass/assda.c b/util/ass/assda.c index d229aa3..cbb9cba 100644 --- a/util/ass/assda.c +++ b/util/ass/assda.c @@ -74,6 +74,7 @@ int pass; int line_num; /* line number for error messages */ int nerrors; /* number of nonfatal errors */ cons_t consiz; /* size of U,I or F value */ +cons_t procbytes; /* size of process table */ cons_t textbytes; /* size of code file */ cons_t databytes; /* highwater mark in data */ FOFFSET dataoff; /* size of data file */ diff --git a/util/ass/assex.h b/util/ass/assex.h index 1317b3b..0509de7 100644 --- a/util/ass/assex.h +++ b/util/ass/assex.h @@ -69,6 +69,7 @@ extern int max_bytes; extern int pass; extern int line_num; extern int nerrors; +extern cons_t procbytes; extern cons_t textbytes; extern cons_t databytes; extern FOFFSET dataoff; diff --git a/util/ass/assrl.c b/util/ass/assrl.c index 4d0f27e..e63197a 100644 --- a/util/ass/assrl.c +++ b/util/ass/assrl.c @@ -98,6 +98,10 @@ copyout() { * | | / * |________________________| * | | + * | PROCTABLE | + * | | + * |_ _ _ _ _ _ _ _ _ _ _ _ | + * | | * | TEXT | zero filled * | | if not word multiple * |________________________| @@ -105,14 +109,11 @@ copyout() { * | DATA | * | | * |________________________| - * | | - * | PROCTABLE | - * | | - * |________________________| * * */ + procbytes = procnum * 3 * ptrsize; remtext = textbytes%wordsize ; if ( remtext != 0 ) remtext = wordsize-remtext ; @@ -133,7 +134,7 @@ copyout() { xput16(ptrsize,ifile); xput16(0,ifile); xput16(0,ifile); - xputa(textbytes+remtext ,ifile); + xputa(procbytes+textbytes+remtext,ifile); xputa((cons_t)datablocks,ifile); xputa((cons_t)procnum,ifile); xputa((cons_t)searchproc(MAIN,xprocs,oursize->n_xproc)->p_num, @@ -143,14 +144,16 @@ copyout() { xputa((cons_t)0,ifile); xputa((cons_t)0,ifile); + for (i=0;i classdefs.h + ./makeclassdef $(EMH)/em_mnem.h $(SRC_DIR)/cldefs.src > classdefs.h makeclassdef: \ $(SRC_DIR)/makecldef.c diff --git a/util/int/disassemble.c b/util/int/disassemble.c index 23a7448..63d6f7c 100644 --- a/util/int/disassemble.c +++ b/util/int/disassemble.c @@ -1706,11 +1706,12 @@ disassemble() ep = (struct ep *)Malloc((size)(NProc * sizeof (struct ep)), "entry points"); for (idf = 0; idf < NProc; idf++) { - register struct proc *pr = &proctab[idf]; - + struct proc pt; + + read_proctab(idf, &pt); ep[idf].ep_idf = idf; - ep[idf].ep_ep = pr->pr_ep; - ep[idf].ep_nloc = pr->pr_nloc; + ep[idf].ep_ep = pt.pr_ep; + ep[idf].ep_nloc = pt.pr_nloc; } /* a very naive sorting algorithm */ diff --git a/util/int/do_misc.c b/util/int/do_misc.c index 8573fd5..3b45f2c 100644 --- a/util/int/do_misc.c +++ b/util/int/do_misc.c @@ -18,6 +18,7 @@ #include "fra.h" #include "rsb.h" #include "linfil.h" +#include "proctab.h" extern int running; /* from main.c */ @@ -384,6 +385,7 @@ PRIVATE gto(p) if (old_LB != new_LB) { wtrap(WGTORSB, EBADGTO); } + read_proctab(PI, &proctab); newLB(new_LB); pop_frames(); diff --git a/util/int/do_proc.c b/util/int/do_proc.c index ff2a39b..0d24494 100644 --- a/util/int/do_proc.c +++ b/util/int/do_proc.c @@ -68,19 +68,18 @@ call(new_PI, rsbcode) int rsbcode; { /* legality of new_PI has already been checked */ - register size nloc = proctab[new_PI].pr_nloc; - register ptr ep = proctab[new_PI].pr_ep; push_frame(SP); /* remember AB */ pushrsb(rsbcode); /* do the call */ PI = new_PI; - st_inc(nloc); - newPC(ep); + read_proctab(new_PI, &proctab); + st_inc(proctab.pr_nloc); + newPC(proctab.pr_ep); spoilFRA(); LOG(("@p5 call: new_PI = %lu, nloc = %lu, ep = %lu", - new_PI, nloc, ep)); + new_PI, proctab.pr_nloc, proctab.pr_ep)); } /************************************************************************ diff --git a/util/int/dump.c b/util/int/dump.c index a444c2e..7cd504c 100644 --- a/util/int/dump.c +++ b/util/int/dump.c @@ -181,8 +181,11 @@ std_rsb(addr) } else if (pi < NProc) { + struct proc pt; + + read_proctab(pi, &pt); sprintf(pr_descr, "(%ld,%ld)", - pi, (long)proctab[pi].pr_nloc); + pi, (long)pt.pr_nloc); } else { sprintf(pr_descr, "%ld >>>> ILLEGAL <<<<", pi); diff --git a/util/int/init.c b/util/int/init.c index 7395e1f..9eb25ef 100644 --- a/util/int/init.c +++ b/util/int/init.c @@ -108,7 +108,6 @@ init(ac, av) rd_text(); rd_gda(); - rd_proctab(); rd_close(); diff --git a/util/int/proctab.c b/util/int/proctab.c index 24ff249..4c18ec0 100644 --- a/util/int/proctab.c +++ b/util/int/proctab.c @@ -7,68 +7,39 @@ #include "logging.h" #include "global.h" #include "log.h" -#include "alloc.h" +#include "memdirect.h" +#include "text.h" #include "proctab.h" -struct proc *proctab; -PRIVATE long pr_cnt; +struct proc proctab; /* changes when PI changes */ -init_proctab() +read_proctab(p, pt) + register ptr p; + register struct proc *pt; { - proctab = (struct proc *) - Malloc(NProc * sizeof (struct proc), "proctable"); - pr_cnt = 0; + p *= psize * 3; + pt->pr_nloc = p_in_text(p); + p += psize; + pt->pr_ep = p_in_text(p); + p += psize; + pt->pr_ff = pt->pr_ep + p_in_text(p); } -add_proc(nloc, ep) - size nloc; - ptr ep; -{ - register struct proc *pr = &proctab[pr_cnt++]; - register struct proc *p; - register ptr ff = DB; - - LOG((" r6 add_proc: pr_cnt = %ld, nloc = %lu, ep = %lu", - pr_cnt-1, nloc, ep)); - if (ep > DB) - fatal("procedure entry point outside text segment"); - - pr->pr_nloc = nloc; - pr->pr_ep = ep; - /* examine all old proc descriptors */ - for (p = &proctab[0]; p < pr; p++) { - if ( /* the old one starts earlier */ - p->pr_ep < pr->pr_ep - && /* it seems to end later */ - p->pr_ff > pr->pr_ep - ) { /* update its limit */ - p->pr_ff = pr->pr_ep; - } - if ( /* the old one starts later */ - p->pr_ep > pr->pr_ep - && /* our limit is beyond the old procedure entry point*/ - ff > p->pr_ep - ) { /* update our limit */ - ff = p->pr_ep; - } - } - pr->pr_ff = ff; -} - -end_init_proctab() -{ #ifdef LOGGING +dump_proctab() +{ register long p; if (!check_log(" r6")) return; for (p = 0; p < NProc; p++) { - register struct proc *pr = &proctab[p]; + struct proc pt; + read_proctab(p, &pt); LOG((" r5: proctab[%ld]: nloc = %d, ep = %lu, ff = %lu", - p, pr->pr_nloc, pr->pr_ep, pr->pr_ff)); + p, pt.pr_nloc, pt.pr_ep, pt.pr_ff)); } -#endif /* LOGGING */ } +#endif /* LOGGING */ diff --git a/util/int/proctab.h b/util/int/proctab.h index dc286b1..2fe0033 100644 --- a/util/int/proctab.h +++ b/util/int/proctab.h @@ -10,4 +10,4 @@ struct proc { ptr pr_ff; /* first address not in proc */ }; -extern struct proc *proctab; +extern struct proc proctab; diff --git a/util/int/read.c b/util/int/read.c index dbc0bdc..a0367b3 100644 --- a/util/int/read.c +++ b/util/int/read.c @@ -31,7 +31,6 @@ extern double str2double(); * rd_header() - read object file header. * * rd_text() - read program text. * * rd_gda() - read global data area. * - * rd_proctab() - read procedure descriptors, * * rd_close() - close object file. * * * ************************************************************************/ @@ -102,6 +101,8 @@ rd_header() NTEXT = rd_int(psize); NDATA = rd_int(psize); NPROC = rd_int(psize); + if (NPROC < 0 || NPROC * psize * 3 > NTEXT) + fatal("Bad proc table"); ENTRY = rd_int(psize); if (ENTRY < 0 || ENTRY >= NPROC) fatal("Bad entry point"); @@ -160,20 +161,6 @@ rd_gda() dt_prot(i2p(4), psize); } -rd_proctab() -{ - register long p; - - init_proctab(); - for (p = 0; p < NPROC; p++) { - register long nloc = rd_int(psize); - register ptr ep = i2p(rd_int(psize)); - - add_proc(nloc, ep); - } - end_init_proctab(); -} - rd_close() { fclose(load_fp); diff --git a/util/int/rsb.c b/util/int/rsb.c index 9b381c6..fcc3ca3 100644 --- a/util/int/rsb.c +++ b/util/int/rsb.c @@ -70,7 +70,7 @@ int poprsb(rtt) #ifdef LOGGING { /* check SP */ - register ptr properSP = LB - proctab[PI].pr_nloc; + register ptr properSP = LB - proctab.pr_nloc; if (SP < properSP) warning(rtt ? WRTTSTL : WRETSTL); @@ -92,6 +92,7 @@ int poprsb(rtt) from Return Status Block */ PI = st_lds(SP + rsb_PI, psize); + read_proctab(PI, &proctab); newPC(st_ldip(SP + rsb_PC)); newLB(st_lddp(SP + rsb_LB)); putLIN((long) st_ldu(SP + rsb_LIN, LINSIZE)); diff --git a/util/int/text.c b/util/int/text.c index f3f83d8..b051e1c 100644 --- a/util/int/text.c +++ b/util/int/text.c @@ -34,12 +34,10 @@ init_text() { newPC(p) register ptr p; { - register struct proc *pr = &proctab[PI]; - if (p >= DB) { wtrap(WPCOVFL, EBADPC); } - if (p < pr->pr_ep || p >= pr->pr_ff) { + if (p < proctab.pr_ep || p >= proctab.pr_ff) { wtrap(WPCPROC, EBADPC); } PC = p; -- 2.34.1