Some corrections to make it work on small machines

This commit is contained in:
ceriel 1988-01-14 13:34:42 +00:00
parent 629fc3f824
commit 1ee5101ba7
6 changed files with 39 additions and 32 deletions

View file

@ -10,6 +10,8 @@ static pseudo();
extern char em_flag[]; extern char em_flag[];
#define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR)
struct e_instr * struct e_instr *
C_alloc() C_alloc()
{ {
@ -30,12 +32,11 @@ C_out(p)
switch(p->em_type) { switch(p->em_type) {
case EM_MNEM: case EM_MNEM:
OP(p->em_opcode); OP(p->em_opcode);
if (em_flag[p->em_opcode - sp_fmnem] == PAR_B && if (flags(p) == PAR_B && p->em_argtype == cst_ptyp) {
p->em_argtype == cst_ptyp) {
p->em_ilb = p->em_cst; p->em_ilb = p->em_cst;
p->em_argtype = ilb_ptyp; 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(); NL();
break; break;
@ -86,7 +87,7 @@ arg(p, comma)
switch(p->em_argtype) { switch(p->em_argtype) {
case 0: 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(); abort();
} }
CCEND(); CCEND();

View file

@ -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 ' -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 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' -sh -c 'ranlib libeme.a'
libemk.a: k/em_private.h k/em.c $(OBS) io.c 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' -sh -c 'ranlib libemk.a'
em_codeEK.h: make.em.gen $(ETC)/em_table em.nogen em_codeEK.h: make.em.gen $(ETC)/em_table em.nogen

View file

@ -29,21 +29,21 @@ getbyte(b)
C_flush(); C_flush();
if (nb != curr_pos) { 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(); C_failed();
} }
} }
if (! ibuf) { if (! C_ibuf) {
ibuf = Malloc(BUFSIZ); C_ibuf = Malloc(BUFSIZ);
} }
if (sys_read(tfr, ibuf, BUFSIZ, &n) == 0) { if (sys_read(C_tfr, C_ibuf, BUFSIZ, &n) == 0) {
C_failed(); C_failed();
} }
curr_pos += n; curr_pos += n;
start_core = nb; start_core = nb;
} }
return ibuf[(int) (b - start_core)]; return C_ibuf[(int) (b - start_core)];
} }
#endif #endif
@ -80,7 +80,7 @@ C_out_parts(pp)
while (pp) { while (pp) {
if (pp->pp_type == INSERT) { if (pp->pp_type == INSERT) {
C_outpart(pp->pp_id); (*C_outpart)(pp->pp_id);
} }
else { else {
/* copy the chunk to output */ /* copy the chunk to output */
@ -119,7 +119,7 @@ C_findpart(part)
} }
static static
switchtotmp() swttmp()
{ {
#ifndef INCORE #ifndef INCORE
if (C_tmpfile == 0) { if (C_tmpfile == 0) {
@ -128,7 +128,7 @@ switchtotmp()
strcpy(p, C_tmpdir); strcpy(p, C_tmpdir);
strcat(p, "/CodeXXXXXX"); strcat(p, "/CodeXXXXXX");
tmpfile = mktemp(p); C_tmpfile = mktemp(p);
if (! sys_open(p, OP_WRITE, &C_old_ofp)) { if (! sys_open(p, OP_WRITE, &C_old_ofp)) {
C_failed(); C_failed();
} }
@ -161,7 +161,7 @@ switchtotmp()
} }
static static
switchtoout() swtout()
{ {
#ifndef INCORE #ifndef INCORE
if (C_ontmpfile) { if (C_ontmpfile) {
@ -277,7 +277,7 @@ resume(p)
*/ */
register PartOfPart *pp = (PartOfPart *) Malloc(sizeof(PartOfPart)); register PartOfPart *pp = (PartOfPart *) Malloc(sizeof(PartOfPart));
switchtotmp(); swttmp();
C_curr_part = p; C_curr_part = p;
pp->pp_next = p->p_parts; pp->pp_next = p->p_parts;
p->p_parts = pp; p->p_parts = pp;
@ -296,8 +296,8 @@ C_insertpart(part)
register PartOfPart *pp; register PartOfPart *pp;
C_outpart = outpart; C_outpart = outpart;
C_switchtotmp = switchtotmp; C_swttmp = swttmp;
C_switchtoout = switchtoout; C_swtout = swtout;
if (C_sequential && available(part)) { if (C_sequential && available(part)) {
outpart(part); outpart(part);
return; return;
@ -333,8 +333,8 @@ C_beginpart(part)
register Part *p = mkpart(part); register Part *p = mkpart(part);
C_outpart = outpart; C_outpart = outpart;
C_switchtotmp = switchtotmp; C_swttmp = swttmp;
C_switchtoout = switchtoout; C_swtout = swtout;
end_partofpart(C_curr_part); end_partofpart(C_curr_part);
@ -359,6 +359,6 @@ C_endpart(part)
if (p->p_prevpart) resume(p->p_prevpart); if (p->p_prevpart) resume(p->p_prevpart);
else { else {
C_curr_part = 0; C_curr_part = 0;
switchtoout(); swtout();
} }
} }

View file

@ -5,8 +5,11 @@
*/ */
#include <system.h> #include <system.h>
#include <local.h>
#if BIGMACHINE
#define INCORE /* mechanism implemented incore */ #define INCORE /* mechanism implemented incore */
#endif
typedef struct partofpart { typedef struct partofpart {
struct partofpart *pp_next; struct partofpart *pp_next;
@ -49,18 +52,20 @@ extern long
extern char *C_opp; extern char *C_opp;
#define C_BASE 0 #define C_BASE 0
#endif #endif
extern int (*C_outpart)(), (*C_switchtoout)(), (*C_switchtotmp)(); extern int (*C_outpart)(), (*C_swtout)(), (*C_swttmp)();
extern File *C_ofp; extern File *C_ofp;
#ifndef INCORE #ifndef INCORE
extern File *C_tfr, *C_old_ofp; extern File *C_tfr, *C_old_ofp;
extern char *C_tmpfile; extern char *C_tmpfile;
extern char *C_tmpdir;
#endif #endif
extern char *C_top; extern char *C_top;
extern char *C_old_top; extern char *C_old_top;
extern char *C_old_opp; extern char *C_old_opp;
extern char *C_ibuf;
#define put(c) if (C_opp == C_top) C_flush(); *C_opp++ = (c) #define put(c) if (C_opp == C_top) C_flush(); *C_opp++ = (c)

View file

@ -6,7 +6,6 @@
#include <alloc.h> #include <alloc.h>
#include <em_path.h> #include <em_path.h>
#include <em_arith.h> #include <em_arith.h>
#include <local.h>
#include "insert.h" #include "insert.h"
int C_ontmpfile = 0; int C_ontmpfile = 0;
@ -14,7 +13,7 @@ int C_sequential = 1;
Part *C_curr_part; Part *C_curr_part;
Part *C_stable[TABSIZ]; Part *C_stable[TABSIZ];
char *C_tmpdir = TMP_DIR; char *C_tmpdir = TMP_DIR;
int (*C_outpart)(), (*C_switchtoout)(), (*C_switchtotmp)(); int (*C_outpart)(), (*C_swtout)(), (*C_swttmp)();
#ifdef INCORE #ifdef INCORE
char *C_BASE; char *C_BASE;
@ -26,7 +25,7 @@ File *C_ofp;
File *C_tfr, *C_old_ofp; File *C_tfr, *C_old_ofp;
char *C_tmpfile; char *C_tmpfile;
char *strcpy(), *strcat(), *mktemp(); char *strcpy(), *strcat(), *mktemp();
static char *ibuf = 0; char *C_ibuf = 0;
long C_current_out; long C_current_out;
#endif #endif
@ -42,6 +41,8 @@ char *C_old_top;
char *C_old_opp; char *C_old_opp;
#ifdef INCORE #ifdef INCORE
char *C_current_out = obuf; char *C_current_out = obuf;
#else
char *C_opp = obuf;
#endif #endif
C_flush() { C_flush() {
@ -109,8 +110,8 @@ C_close()
#ifndef INCORE #ifndef INCORE
C_flush(); C_flush();
if (tmpfile) { if (C_tmpfile) {
(*C_switchtotmp)(); (*C_swttmp)();
sys_close(C_ofp); sys_close(C_ofp);
#else #else
if (C_BASE) { if (C_BASE) {
@ -118,14 +119,14 @@ C_close()
if (C_curr_part) { if (C_curr_part) {
C_curr_part->p_parts->pp_end = C_current_out - C_BASE; C_curr_part->p_parts->pp_end = C_current_out - C_BASE;
} }
(*C_switchtoout)(); (*C_swtout)();
if (! C_sequential) { if (! C_sequential) {
(*C_outpart)(0); (*C_outpart)(0);
} }
#ifndef INCORE #ifndef INCORE
sys_close(C_tfr); sys_close(C_tfr);
sys_remove(tmpfile); sys_remove(C_tmpfile);
if (ibuf) free(ibuf); if (C_ibuf) free(C_ibuf);
#else #else
free(C_BASE); free(C_BASE);
#endif #endif

View file

@ -1,10 +1,10 @@
#include "em_private.h" #include "em_private.h"
CC_msstart(cst) CC_msstart(cst)
arith cst; int cst;
{ {
/* start of message /* start of message
*/ */
PS(ps_mes); PS(ps_mes);
CST(cst); CST((arith)cst);
} }