From 1ee5101ba7c580d67c45379fde29579072857cbf Mon Sep 17 00:00:00 2001 From: ceriel Date: Thu, 14 Jan 1988 13:34:42 +0000 Subject: [PATCH] Some corrections to make it work on small machines --- modules/src/em_code/C_out.c | 9 +++++---- modules/src/em_code/Makefile | 4 ++-- modules/src/em_code/insert.c | 30 +++++++++++++++--------------- modules/src/em_code/insert.h | 7 ++++++- modules/src/em_code/io.c | 17 +++++++++-------- modules/src/em_code/msstart.c | 4 ++-- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/modules/src/em_code/C_out.c b/modules/src/em_code/C_out.c index e4963fcef..4313e9868 100644 --- a/modules/src/em_code/C_out.c +++ b/modules/src/em_code/C_out.c @@ -10,6 +10,8 @@ static pseudo(); extern char em_flag[]; +#define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR) + struct e_instr * C_alloc() { @@ -30,12 +32,11 @@ C_out(p) switch(p->em_type) { case EM_MNEM: OP(p->em_opcode); - if (em_flag[p->em_opcode - sp_fmnem] == PAR_B && - p->em_argtype == cst_ptyp) { + if (flags(p) == PAR_B && p->em_argtype == cst_ptyp) { p->em_ilb = p->em_cst; p->em_argtype = ilb_ptyp; } - if (em_flag[p->em_opcode - sp_fmnem] != PAR_NO) arg(p, 0); + if (flags(p) != PAR_NO) arg(p, 0); NL(); break; @@ -86,7 +87,7 @@ arg(p, comma) switch(p->em_argtype) { case 0: - if (p->em_type == EM_MNEM && em_flag[p->em_opcode - sp_fmnem] != PAR_W) { + if (p->em_type == EM_MNEM && flags(p) != PAR_W) { abort(); } CCEND(); diff --git a/modules/src/em_code/Makefile b/modules/src/em_code/Makefile index bb5808811..cea62a176 100644 --- a/modules/src/em_code/Makefile +++ b/modules/src/em_code/Makefile @@ -33,11 +33,11 @@ em_code.3: em_code.3X -sh -c 'if test -s em_code.3 ; then : ; else cp em_code.3X em_code.3 ; fi ' libeme.a: e/em_private.h e/em.c $(OBS) io.c - EMHOME=$(EMHOME); cc="$(CC)"; cflags="-c -Ie $(CFLAGS)" ar="$(AR)"; export EMHOME cc ar cflags; sh make.sh e + EMHOME=$(EMHOME); cc="$(CC)"; cflags="-c -Ie $(CFLAGS)" ar="$(AR)"; export EMHOME cc ar cflags; sh -x make.sh e -sh -c 'ranlib libeme.a' libemk.a: k/em_private.h k/em.c $(OBS) io.c - EMHOME=$(EMHOME); cc="$(CC)"; cflags="-c -Ik $(CFLAGS)" ar="$(AR)"; export EMHOME cc ar cflags; sh make.sh k + EMHOME=$(EMHOME); cc="$(CC)"; cflags="-c -Ik $(CFLAGS)" ar="$(AR)"; export EMHOME cc ar cflags; sh -x make.sh k -sh -c 'ranlib libemk.a' em_codeEK.h: make.em.gen $(ETC)/em_table em.nogen diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index 6e8bbe964..b45afcb33 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -29,21 +29,21 @@ getbyte(b) C_flush(); if (nb != curr_pos) { - if (sys_seek(tfr, nb, 0, &curr_pos) == 0) { + if (sys_seek(C_tfr, nb, 0, &curr_pos) == 0) { C_failed(); } } - if (! ibuf) { - ibuf = Malloc(BUFSIZ); + if (! C_ibuf) { + C_ibuf = Malloc(BUFSIZ); } - if (sys_read(tfr, ibuf, BUFSIZ, &n) == 0) { + if (sys_read(C_tfr, C_ibuf, BUFSIZ, &n) == 0) { C_failed(); } curr_pos += n; start_core = nb; } - return ibuf[(int) (b - start_core)]; + return C_ibuf[(int) (b - start_core)]; } #endif @@ -80,7 +80,7 @@ C_out_parts(pp) while (pp) { if (pp->pp_type == INSERT) { - C_outpart(pp->pp_id); + (*C_outpart)(pp->pp_id); } else { /* copy the chunk to output */ @@ -119,7 +119,7 @@ C_findpart(part) } static -switchtotmp() +swttmp() { #ifndef INCORE if (C_tmpfile == 0) { @@ -128,7 +128,7 @@ switchtotmp() strcpy(p, C_tmpdir); strcat(p, "/CodeXXXXXX"); - tmpfile = mktemp(p); + C_tmpfile = mktemp(p); if (! sys_open(p, OP_WRITE, &C_old_ofp)) { C_failed(); } @@ -161,7 +161,7 @@ switchtotmp() } static -switchtoout() +swtout() { #ifndef INCORE if (C_ontmpfile) { @@ -277,7 +277,7 @@ resume(p) */ register PartOfPart *pp = (PartOfPart *) Malloc(sizeof(PartOfPart)); - switchtotmp(); + swttmp(); C_curr_part = p; pp->pp_next = p->p_parts; p->p_parts = pp; @@ -296,8 +296,8 @@ C_insertpart(part) register PartOfPart *pp; C_outpart = outpart; - C_switchtotmp = switchtotmp; - C_switchtoout = switchtoout; + C_swttmp = swttmp; + C_swtout = swtout; if (C_sequential && available(part)) { outpart(part); return; @@ -333,8 +333,8 @@ C_beginpart(part) register Part *p = mkpart(part); C_outpart = outpart; - C_switchtotmp = switchtotmp; - C_switchtoout = switchtoout; + C_swttmp = swttmp; + C_swtout = swtout; end_partofpart(C_curr_part); @@ -359,6 +359,6 @@ C_endpart(part) if (p->p_prevpart) resume(p->p_prevpart); else { C_curr_part = 0; - switchtoout(); + swtout(); } } diff --git a/modules/src/em_code/insert.h b/modules/src/em_code/insert.h index 37396b667..0884dedad 100644 --- a/modules/src/em_code/insert.h +++ b/modules/src/em_code/insert.h @@ -5,8 +5,11 @@ */ #include +#include +#if BIGMACHINE #define INCORE /* mechanism implemented incore */ +#endif typedef struct partofpart { struct partofpart *pp_next; @@ -49,18 +52,20 @@ extern long extern char *C_opp; #define C_BASE 0 #endif -extern int (*C_outpart)(), (*C_switchtoout)(), (*C_switchtotmp)(); +extern int (*C_outpart)(), (*C_swtout)(), (*C_swttmp)(); extern File *C_ofp; #ifndef INCORE extern File *C_tfr, *C_old_ofp; extern char *C_tmpfile; +extern char *C_tmpdir; #endif extern char *C_top; extern char *C_old_top; extern char *C_old_opp; +extern char *C_ibuf; #define put(c) if (C_opp == C_top) C_flush(); *C_opp++ = (c) diff --git a/modules/src/em_code/io.c b/modules/src/em_code/io.c index 6e48b6f76..042f2d32a 100644 --- a/modules/src/em_code/io.c +++ b/modules/src/em_code/io.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "insert.h" int C_ontmpfile = 0; @@ -14,7 +13,7 @@ int C_sequential = 1; Part *C_curr_part; Part *C_stable[TABSIZ]; char *C_tmpdir = TMP_DIR; -int (*C_outpart)(), (*C_switchtoout)(), (*C_switchtotmp)(); +int (*C_outpart)(), (*C_swtout)(), (*C_swttmp)(); #ifdef INCORE char *C_BASE; @@ -26,7 +25,7 @@ File *C_ofp; File *C_tfr, *C_old_ofp; char *C_tmpfile; char *strcpy(), *strcat(), *mktemp(); -static char *ibuf = 0; +char *C_ibuf = 0; long C_current_out; #endif @@ -42,6 +41,8 @@ char *C_old_top; char *C_old_opp; #ifdef INCORE char *C_current_out = obuf; +#else +char *C_opp = obuf; #endif C_flush() { @@ -109,8 +110,8 @@ C_close() #ifndef INCORE C_flush(); - if (tmpfile) { - (*C_switchtotmp)(); + if (C_tmpfile) { + (*C_swttmp)(); sys_close(C_ofp); #else if (C_BASE) { @@ -118,14 +119,14 @@ C_close() if (C_curr_part) { C_curr_part->p_parts->pp_end = C_current_out - C_BASE; } - (*C_switchtoout)(); + (*C_swtout)(); if (! C_sequential) { (*C_outpart)(0); } #ifndef INCORE sys_close(C_tfr); - sys_remove(tmpfile); - if (ibuf) free(ibuf); + sys_remove(C_tmpfile); + if (C_ibuf) free(C_ibuf); #else free(C_BASE); #endif diff --git a/modules/src/em_code/msstart.c b/modules/src/em_code/msstart.c index 9b55294a9..192e40f78 100644 --- a/modules/src/em_code/msstart.c +++ b/modules/src/em_code/msstart.c @@ -1,10 +1,10 @@ #include "em_private.h" CC_msstart(cst) - arith cst; + int cst; { /* start of message */ PS(ps_mes); - CST(cst); + CST((arith)cst); }