completely new version

This commit is contained in:
ceriel 1987-11-12 11:59:31 +00:00
parent f9281be252
commit 0baf75f779
52 changed files with 975 additions and 116 deletions

View file

@ -1,13 +1,61 @@
Makefile Makefile
C_out.c
bhcst.c
bhdlb.c
bhdnam.c
bhfcon.c
bhicon.c
bhilb.c
bhpnam.c
bhucon.c
convert.c
crcst.c
crdlb.c
crdnam.c
crfcon.c
cricon.c
crilb.c
crpnam.c
crscon.c
crucon.c
cst.c
dfdlb.c
dfdnam.c
dfilb.c
dlb.c
dnam.c
e e
em.nogen em.nogen
em_code.3X end.c
k endarg.c
make.em.gen exc.c
make.fun
failed.c failed.c
fcon.c
getid.c getid.c
icon.c
ilb.c
insert.c insert.c
insert.h
internerr.c internerr.c
io.c io.c
insert.h k
make.em.gen
make.sh
msend.c
msstart.c
op.c
opcst.c
opdlb.c
opdnam.c
opilb.c
opnarg.c
oppnam.c
pnam.c
pro.c
pronarg.c
psdlb.c
psdnam.c
pspnam.c
scon.c
ucon.c
em_code.3X

173
modules/src/em_code/C_out.c Normal file
View file

@ -0,0 +1,173 @@
#include <em.h>
#include <em_comp.h>
#include <em_pseu.h>
#include <em_flag.h>
#include <em_ptyp.h>
#include <em_private.h>
static arg();
static pseudo();
extern char em_flag[];
struct e_instr *
C_alloc()
{
static struct e_instr b;
return &b;
}
C_out(p)
register struct e_instr *p;
{
/* Generate EM-code from the e_instr structure "p"
*/
switch(p->em_type) {
case EM_MNEM:
OP(p->em_opcode);
if (em_flag[p->em_opcode] == PAR_B) {
p->em_argtype = ilb_ptyp;
p->em_ilb = p->em_cst;
}
if (em_flag[p->em_opcode] != PAR_NO) arg(p, 0);
NL();
break;
case EM_PSEU:
pseudo(p);
break;
case EM_STARTMES:
PS(ps_mes);
CST(p->em_cst);
break;
case EM_MESARG:
arg(p, 1);
break;
case EM_ENDMES:
CEND();
NL();
break;
case EM_DEFILB:
DFILB(p->em_ilb);
NL();
break;
case EM_DEFDLB:
DFDLB(p->em_dlb);
NL();
break;
case EM_DEFDNAM:
DFDNAM(p->em_dnam);
NL();
break;
}
}
static
arg(p, comma)
register struct e_instr *p;
{
/* Output the argument of "p".
*/
if (comma) COMMA();
switch(p->em_argtype) {
case 0:
CCEND();
break;
case ilb_ptyp:
ILB(p->em_ilb);
break;
case nof_ptyp:
DOFF(p->em_dlb, p->em_off);
break;
case sof_ptyp:
NOFF(p->em_dnam, p->em_off);
break;
case cst_ptyp:
CST(p->em_cst);
break;
case pro_ptyp:
PNAM(p->em_pnam);
break;
case str_ptyp:
SCON(p->em_string, p->em_size);
break;
case ico_ptyp:
WCON(sp_icon, p->em_string, p->em_size);
break;
case uco_ptyp:
WCON(sp_ucon, p->em_string, p->em_size);
break;
case fco_ptyp:
WCON(sp_fcon, p->em_string, p->em_size);
break;
}
}
static
pseudo(p)
register struct e_instr *p;
{
PS(p->em_opcode);
switch(p->em_opcode) {
case ps_exc:
CST(p->em_exc1);
COMMA();
CST(p->em_exc2);
break;
case ps_rom:
case ps_con:
arg(p, 0);
CEND();
break;
case ps_bss:
case ps_hol:
CST(EM_holsize);
arg(p, 1);
COMMA();
CST((arith) EM_holinit);
break;
case ps_pro:
arg(p, 0);
COMMA();
if (p->em_nlocals != -1) CST(p->em_nlocals);
else CCEND();
break;
case ps_end:
if (p->em_argtype == 0) CCEND();
else CST(p->em_cst);
break;
default:
arg(p, 0);
break;
}
NL();
}

View file

@ -1,43 +1,52 @@
EMHOME = ../../.. EMHOME = ../../..
ETC = $(EMHOME)/etc
INSTALL = $(EMHOME)/modules/install INSTALL = $(EMHOME)/modules/install
COMPARE = $(EMHOME)/modules/compare COMPARE = $(EMHOME)/modules/compare
CFLAGS = -I$(EMHOME)/h -I$(EMHOME)/modules/h -O CFLAGS = -I$(EMHOME)/h -I$(EMHOME)/modules/h -I. -O
SRC = failed.c insert.c internerr.c getid.c AR = ar
SRC = bhcst.c bhdlb.c bhdnam.c bhfcon.c bhicon.c bhilb.c bhpnam.c bhucon.c \
crcst.c crdlb.c crdnam.c crfcon.c cricon.c crilb.c crpnam.c crscon.c \
crucon.c cst.c dfdlb.c dfdnam.c dfilb.c dlb.c dnam.c end.c endarg.c \
exc.c failed.c fcon.c getid.c icon.c ilb.c insert.c internerr.c io.c \
msend.c op.c opcst.c opdlb.c opdnam.c opilb.c opnarg.c oppnam.c pnam.c \
pro.c pronarg.c msstart.c psdlb.c psdnam.c pspnam.c scon.c ucon.c \
C_out.c
OBS = failed.o insert.o internerr.o getid.o OBS = failed.o insert.o internerr.o getid.o
all: libeme.a libemk.a em_code.3 all: libeme.a libemk.a em_code.3 em_codeEK.h
rm -f C_*.c rm -f C_*.c
install: all install: all
$(INSTALL) lib/libeme.a $(INSTALL) lib/libeme.a
$(INSTALL) lib/libemk.a $(INSTALL) lib/libemk.a
$(INSTALL) man/em_code.3 $(INSTALL) man/em_code.3
$(INSTALL) h/em_codeEK.h
compare: all compare: all
$(COMPARE) lib/libeme.a $(COMPARE) lib/libeme.a
$(COMPARE) lib/libemk.a $(COMPARE) lib/libemk.a
$(COMPARE) man/em_code.3 $(COMPARE) man/em_code.3
$(COMPARE) h/em_codeEK.h
em_code.3: em_code.3X em_code.3: em_code.3X
-sh -c 'tbl < em_code.3X > em_code.3' -sh -c 'tbl < em_code.3X > em_code.3'
-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: make.sh e/em_private.h e/em.c $(OBS) io.c libeme.a: e/em_private.h e/em.c $(OBS) io.c
EMHOME=$(EMHOME); export EMHOME; sh make.sh e EMHOME=$(EMHOME); cc="$(CC)"; cflags="-c -Ie $(CFLAGS)" ar="$(AR)"; export EMHOME cc ar cflags; sh make.sh e
-sh -c 'ranlib libeme.a' -sh -c 'ranlib libeme.a'
libemk.a: make.sh k/em_private.h k/em.c $(OBS) io.c libemk.a: k/em_private.h k/em.c $(OBS) io.c
EMHOME=$(EMHOME); export EMHOME; sh make.sh k EMHOME=$(EMHOME); cc="$(CC)"; cflags="-c -Ik $(CFLAGS)" ar="$(AR)"; export EMHOME cc ar cflags; sh make.sh k
-sh -c 'ranlib libemk.a' -sh -c 'ranlib libemk.a'
make.sh: em.gen em.nogen make.fun em_codeEK.h: make.em.gen $(ETC)/em_table em.nogen
make.fun em.gen em.nogen | sh make.em.gen $(ETC)/em_table > em_codeEK.h
cat em.nogen >> em_codeEK.h
em.gen: make.em.gen $(EMHOME)/etc/em_table
make.em.gen $(EMHOME)/etc/em_table > em.gen
pr: pr:
@pr Makefile make.em.gen make.fun em.nogen insert.h $(SRC) e/em_private.h e/em.c k/em_private.h k/em.c @pr Makefile em.nogen make.em.gen make.sh insert.h $(SRC) e/em_private.h e/em.c k/em_private.h k/em.c
opr: opr:
make pr | opr make pr | opr
@ -45,9 +54,7 @@ opr:
# don't put the next "rm"s all on one line. the argument list then # don't put the next "rm"s all on one line. the argument list then
# becomes too long for some systems # becomes too long for some systems
clean: clean:
rm -f *.o rm -f *.o *.a em_code.3
rm -f C_*.c
rm -f *.a em_code.3 em.gen make.sh
lintlib: make.sh lintlib: make.sh
lint -I. -I../../h -I../../../h -Ie -Ceme $(SRC) e/*.c lint -I. -I../../h -I../../../h -Ie -Ceme $(SRC) e/*.c

View file

@ -0,0 +1,17 @@
#include "em_private.h"
CC_bhcst(op, n, w, i)
arith n;
arith w;
int i;
{
/* BSS or HOL with size n, initial value a cst w, and flag i
*/
PS(op);
CST(n);
COMMA();
CST(w);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,19 @@
#include "em_private.h"
CC_bhdlb(op, n, s, off, i)
arith n;
label s;
arith off;
int i;
{
/* BSS or HOL with size n, initial value a dlb(s, off),
and flag i
*/
PS(op);
CST(n);
COMMA();
DOFF(s, off);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,19 @@
#include "em_private.h"
CC_bhdnam(op, n, s, off, i)
arith n;
char *s;
arith off;
int i;
{
/* BSS or HOL with size n, initial value a dnam(s, off),
and flag i
*/
PS(op);
CST(n);
COMMA();
NOFF(s, off);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,19 @@
#include "em_private.h"
CC_bhfcon(op, n, s, sz, i)
arith n;
char *s;
arith sz;
int i;
{
/* BSS or HOL with size n, initial value an FCON (s, sz),
and flag i
*/
PS(op);
CST(n);
COMMA();
WCON(sp_fcon, s, sz);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,19 @@
#include "em_private.h"
CC_bhicon(op, n, s, sz, i)
arith n;
char *s;
arith sz;
int i;
{
/* BSS or HOL with size n, initial value an ICON (s, sz),
and flag i
*/
PS(op);
CST(n);
COMMA();
WCON(sp_icon, s, sz);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,18 @@
#include "em_private.h"
CC_bhilb(op, n, l, i)
arith n;
label l;
int i;
{
/* BSS or HOL with size n, initial value a ILB(l),
and flag i
*/
PS(op);
CST(n);
COMMA();
ILB(l);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,18 @@
#include "em_private.h"
CC_bhpnam(op, n, p, i)
arith n;
char *p;
int i;
{
/* BSS or HOL with size n, initial value a PNAM(p),
and flag i
*/
PS(op);
CST(n);
COMMA();
PNAM(p);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,19 @@
#include "em_private.h"
CC_bhucon(op, n, s, sz, i)
arith n;
char *s;
arith sz;
int i;
{
/* BSS or HOL with size n, initial value an UCON (s, sz),
and flag i
*/
PS(op);
CST(n);
COMMA();
WCON(sp_ucon, s, sz);
COMMA();
CST((arith) i);
NL();
}

View file

@ -0,0 +1,89 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
/* This program converts either human-readable or compact EM
assembly code to calls of the procedure-interface.
It must be linked with two libraries:
- a library to read EM code, according to read_em(3)
- a library implementing the em_code(3) interface.
Thus, this program could serve as an EM_encoder, an
EM_decoder, or some code generator, depending on how it is
linked.
*/
#include <system.h>
#include <em_pseu.h>
#include <em_mnem.h>
#include <em_spec.h>
#include <em_flag.h>
#include <em_ptyp.h>
#include <em.h>
#include <em_comp.h>
char *filename; /* Name of input file */
int errors; /* Number of errors */
main(argc,argv)
char **argv;
{
struct e_instr buf;
register struct e_instr *p = &buf;
if (argc >= 2) {
filename = argv[1];
}
else filename = 0;
if (!EM_open(filename)) {
fatal(EM_error);
}
EM_getinstr(p);
C_init((arith) EM_wordsize, (arith) EM_pointersize);
if (argc >= 3) {
if (!C_open(argv[2])) {
fatal("C_open failed");
}
}
else if (!C_open( (char *) 0)) fatal("C_open failed");
C_magic();
while (p->em_type != EM_EOF) {
if (p->em_type == EM_FATAL) {
fatal("%s", EM_error);
}
if (EM_error) {
error("%s", EM_error);
}
if (p->em_type != EM_ERROR) {
EM_mkcalls(p);
}
EM_getinstr(p);
}
C_close();
EM_close();
exit(errors);
}
/* VARARGS */
error(s,a1,a2,a3,a4)
char *s;
{
fprint(STDERR,
"%s, line %d: ",
filename ? filename : "standard input",
EM_lineno);
fprint(STDERR,s,a1,a2,a3,a4);
fprint(STDERR, "\n");
errors++;
}
/* VARARGS */
fatal(s,a1,a2,a3,a4)
char *s;
{
error(s,a1,a2,a3,a4);
exit(1);
}

View file

@ -0,0 +1,12 @@
#include "em_private.h"
CC_crcst(op, v)
arith v;
{
/* CON or ROM with argument CST(v)
*/
PS(op);
CST(v);
CEND();
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_crdlb(op, v, off)
label v;
arith off;
{
/* CON or ROM with argument DLB(v, off)
*/
PS(op);
DOFF(v, off);
CEND();
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_crdnam(op, s, off)
char *s;
arith off;
{
/* CON or ROM with argument DNAM(s, off)
*/
PS(op);
NOFF(s, off);
CEND();
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_crfcon(op, v, s)
char *v;
arith s;
{
/* CON or ROM with argument FCON(v,z)
*/
PS(op);
WCON(sp_fcon, v, s);
CEND();
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_cricon(op, v, s)
char *v;
arith s;
{
/* CON or ROM with argument ICON(v,z)
*/
PS(op);
WCON(sp_icon, v, s);
CEND();
NL();
}

View file

@ -0,0 +1,12 @@
#include "em_private.h"
CC_crilb(op, l)
label l;
{
/* CON or ROM with argument ILB(l)
*/
PS(op);
ILB(l);
CEND();
NL();
}

View file

@ -0,0 +1,12 @@
#include "em_private.h"
CC_crpnam(op, p)
char *p;
{
/* CON or ROM with argument PNAM(p)
*/
PS(op);
PNAM(p);
CEND();
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_crscon(op, v, s)
char *v;
arith s;
{
/* CON or ROM with argument SCON(v,z)
*/
PS(op);
SCON(v, s);
CEND();
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_crucon(op, v, s)
char *v;
arith s;
{
/* CON or ROM with argument UCON(v,z)
*/
PS(op);
WCON(sp_ucon, v, s);
CEND();
NL();
}

View file

@ -0,0 +1,8 @@
#include "em_private.h"
CC_cst(l)
arith l;
{
COMMA();
CST(l);
}

View file

@ -0,0 +1,10 @@
#include "em_private.h"
CC_dfdlb(l)
label l;
{
/* Define numeric data label
*/
DFDLB(l);
NL();
}

View file

@ -0,0 +1,10 @@
#include "em_private.h"
CC_dfdnam(s)
char *s;
{
/* Define data label
*/
DFDNAM(s);
NL();
}

View file

@ -0,0 +1,10 @@
#include "em_private.h"
CC_dfilb(l)
label l;
{
/* Define instruction label
*/
DFILB(l);
NL();
}

View file

@ -0,0 +1,9 @@
#include "em_private.h"
CC_dlb(l, val)
label l;
arith val;
{
COMMA();
DOFF(l, val);
}

View file

@ -0,0 +1,9 @@
#include "em_private.h"
CC_dnam(str, val)
char *str;
arith val;
{
COMMA();
NOFF(str, val);
}

View file

@ -1,106 +1,83 @@
% Definition of EM procedural interface: hand-written definitions /* Definition of EM procedural interface: hand-written definitions
% C_open | char *:filename | <hand-written> C_open | char *:filename | <hand-written>
% C_busy | | <hand-written> C_busy | | <hand-written>
% C_close | | <hand-written> C_close | | <hand-written>
% C_magic | | <hand-written> C_magic | | <hand-written>
*/
C_df_dlb | label:l | DFDLB(l); NL() #define C_df_dlb(l) CC_dfdlb(l)
C_df_dnam | char *:s | DFDNAM(s); NL() #define C_df_dnam(s) CC_dfdnam(s)
C_df_ilb | label:l | DFILB(l); NL() #define C_df_ilb(l) CC_dfilb(l)
C_pro | char *:s arith:l | #define C_pro(s,l) CC_pro(s, l)
PS(ps_pro); PNAM(s); COMMA(); CST(l); NL() #define C_pro_narg(s) CC_pronarg(s)
C_pro_narg | char *:s | #define C_end(l) CC_end(l)
PS(ps_pro); PNAM(s); COMMA(); CCEND(); NL() #define C_end_narg() CC_endnarg()
C_end | arith:l | PS(ps_end); CST(l); NL()
C_end_narg | | PS(ps_end); CCEND(); NL()
C_exa_dnam | char *:s | PS(ps_exa); DNAM(s); NL() #define C_exa_dnam(s) CC_psdnam(ps_exa, s)
C_exa_dlb | label:l | PS(ps_exa); DLB(l); NL() #define C_exa_dlb(l) CC_psdlb(ps_exa, l)
C_exp | char *:s | PS(ps_exp); PNAM(s); NL() #define C_ina_dnam(s) CC_psdnam(ps_ina, s)
C_ina_dnam | char *:s | PS(ps_ina); DNAM(s); NL() #define C_ina_dlb(l) CC_psdlb(ps_ina, l)
C_ina_dlb | label:l | PS(ps_ina); DLB(l); NL() #define C_exp(s) CC_pspnam(ps_exp, s)
C_inp | char *:s | PS(ps_inp); PNAM(s); NL() #define C_inp(s) CC_pspnam(ps_inp, s)
C_bss_cst | arith:n arith:w int:i | #define C_bss_cst(n,w,i) CC_bhcst(ps_bss, n, w, i)
PS(ps_bss); CST(n); COMMA(); CST(w); COMMA(); CST((arith) i); NL() #define C_hol_cst(n,w,i) CC_bhcst(ps_hol, n, w, i)
C_bss_icon | arith:n char *:s arith:sz int:i | #define C_bss_icon(n,s,sz,i) CC_bhicon(ps_bss,n,s,sz,i)
PS(ps_bss); CST(n); COMMA(); WCON(sp_icon, s, sz); COMMA(); CST((arith) i); NL() #define C_hol_icon(n,s,sz,i) CC_bhicon(ps_hol,n,s,sz,i)
C_bss_ucon | arith:n char *:s arith:sz int:i | #define C_bss_ucon(n,s,sz,i) CC_bhucon(ps_bss,n,s,sz,i)
PS(ps_bss); CST(n); COMMA(); WCON(sp_ucon, s, sz); COMMA(); CST((arith) i); NL() #define C_hol_ucon(n,s,sz,i) CC_bhucon(ps_hol,n,s,sz,i)
C_bss_fcon | arith:n char *:s arith:sz int:i | #define C_bss_fcon(n,s,sz,i) CC_bhfcon(ps_bss,n,s,sz,i)
PS(ps_bss); CST(n); COMMA(); WCON(sp_fcon, s, sz); COMMA(); CST((arith) i); NL() #define C_hol_fcon(n,s,sz,i) CC_bhfcon(ps_hol,n,s,sz,i)
C_bss_dnam | arith:n char *:s arith:offs int:i | #define C_bss_dnam(n,s,off,i) CC_bhdnam(ps_bss,n,s,off,i)
PS(ps_bss); CST(n); COMMA(); NOFF(s, offs); COMMA(); CST((arith) i); NL() #define C_hol_dnam(n,s,off,i) CC_bhdnam(ps_hol,n,s,off,i)
C_bss_dlb | arith:n label:l arith:offs int:i | #define C_bss_dlb(n,l,off,i) CC_bhdlb(ps_bss,n,l,off,i)
PS(ps_bss); CST(n); COMMA(); DOFF(l, offs); COMMA(); CST((arith) i); NL() #define C_hol_dlb(n,l,off,i) CC_bhdlb(ps_hol,n,l,off,i)
C_bss_ilb | arith:n label:l int:i | #define C_bss_ilb(n,l,i) CC_bhilb(ps_bss,n,l,i)
PS(ps_bss); CST(n); COMMA(); ILB(l); COMMA(); CST((arith) i); NL() #define C_hol_ilb(n,l,i) CC_bhilb(ps_hol,n,l,i)
C_bss_pnam | arith:n char *:s int:i | #define C_bss_pnam(n,s,i) CC_bhpnam(ps_bss,n,s,i)
PS(ps_bss); CST(n); COMMA(); PNAM(s); COMMA(); CST((arith) i); NL() #define C_hol_pnam(n,s,i) CC_bhpnam(ps_hol,n,s,i)
C_hol_cst | arith:n arith:w int:i | #define C_con_cst(v) CC_crcst(ps_con,v)
PS(ps_hol); CST(n); COMMA(); CST(w); COMMA(); CST((arith) i); NL() #define C_con_icon(v,s) CC_cricon(ps_con,v,s)
C_hol_icon | arith:n char *:s arith:sz int:i | #define C_con_ucon(v,s) CC_crucon(ps_con,v,s)
PS(ps_hol); CST(n); COMMA(); WCON(sp_icon, s, sz); COMMA(); CST((arith) i); NL() #define C_con_fcon(v,s) CC_crfcon(ps_con,v,s)
C_hol_ucon | arith:n char *:s arith:sz int:i | #define C_con_scon(v,s) CC_crscon(ps_con,v,s)
PS(ps_hol); CST(n); COMMA(); WCON(sp_ucon, s, sz); COMMA(); CST((arith) i); NL() #define C_con_dnam(v,s) CC_crdnam(ps_con,v,s)
C_hol_fcon | arith:n char *:s arith:sz int:i | #define C_con_dlb(v,s) CC_crdlb(ps_con,v,s)
PS(ps_hol); CST(n); COMMA(); WCON(sp_fcon, s, sz); COMMA(); CST((arith) i); NL() #define C_con_ilb(v) CC_crilb(ps_con,v)
C_hol_dnam | arith:n char *:s arith:offs int:i | #define C_con_pnam(v) CC_crpnam(ps_con,v)
PS(ps_hol); CST(n); COMMA(); NOFF(s, offs); COMMA(); CST((arith) i); NL()
C_hol_dlb | arith:n label:l arith:offs int:i |
PS(ps_hol); CST(n); COMMA(); DOFF(l, offs); COMMA(); CST((arith) i); NL()
C_hol_ilb | arith:n label:l int:i |
PS(ps_hol); CST(n); COMMA(); ILB(l); COMMA(); CST((arith) i); NL()
C_hol_pnam | arith:n char *:s int:i |
PS(ps_hol); CST(n); COMMA(); PNAM(s); COMMA(); CST((arith) i); NL()
C_con_cst | arith:l | PS(ps_con); CST(l); CEND(); NL() #define C_rom_cst(v) CC_crcst(ps_rom,v)
C_con_icon | char *:val arith:siz | #define C_rom_icon(v,s) CC_cricon(ps_rom,v,s)
PS(ps_con); WCON(sp_icon, val, siz); CEND(); NL() #define C_rom_ucon(v,s) CC_crucon(ps_rom,v,s)
C_con_ucon | char *:val arith:siz | #define C_rom_fcon(v,s) CC_crfcon(ps_rom,v,s)
PS(ps_con); WCON(sp_ucon, val, siz); CEND(); NL() #define C_rom_scon(v,s) CC_crscon(ps_rom,v,s)
C_con_fcon | char *:val arith:siz | #define C_rom_dnam(v,s) CC_crdnam(ps_rom,v,s)
PS(ps_con); WCON(sp_fcon, val, siz); CEND(); NL() #define C_rom_dlb(v,s) CC_crdlb(ps_rom,v,s)
C_con_scon | char *:str arith:siz | #define C_rom_ilb(v) CC_crilb(ps_rom,v)
PS(ps_con); SCON(str, siz); CEND(); NL() #define C_rom_pnam(v) CC_crpnam(ps_rom,v)
C_con_dnam | char *:str arith:val |
PS(ps_con); NOFF(str, val); CEND(); NL()
C_con_dlb | label:l arith:val |
PS(ps_con); DOFF(l, val); CEND(); NL()
C_con_ilb | label:l | PS(ps_con); ILB(l); CEND(); NL()
C_con_pnam | char *:str | PS(ps_con); PNAM(str); CEND(); NL()
C_rom_cst | arith:l | PS(ps_rom); CST(l); CEND(); NL() #define C_cst(l) CC_cst(l)
C_rom_icon | char *:val arith:siz | #define C_icon(v,s) CC_icon(v,s)
PS(ps_rom); WCON(sp_icon, val, siz); CEND(); NL() #define C_ucon(v,s) CC_ucon(v,s)
C_rom_ucon | char *:val arith:siz | #define C_fcon(v,s) CC_fcon(v,s)
PS(ps_rom); WCON(sp_ucon, val, siz); CEND(); NL() #define C_scon(v,s) CC_scon(v,s)
C_rom_fcon | char *:val arith:siz | #define C_dnam(v,s) CC_dnam(v,s)
PS(ps_rom); WCON(sp_fcon, val, siz); CEND(); NL() #define C_dlb(v,s) CC_dlb(v,s)
C_rom_scon | char *:str arith:siz | #define C_ilb(l) CC_ilb(l)
PS(ps_rom); SCON(str, siz); CEND(); NL() #define C_pnam(s) CC_pnam(s)
C_rom_dnam | char *:str arith:val |
PS(ps_rom); NOFF(str, val); CEND(); NL()
C_rom_dlb | label:l arith:val |
PS(ps_rom); DOFF(l, val); CEND(); NL()
C_rom_ilb | label:l | PS(ps_rom); ILB(l); CEND(); NL()
C_rom_pnam | char *:str | PS(ps_rom); PNAM(str); CEND(); NL()
C_cst | arith:l | COMMA(); CST(l) #define C_mes_begin(ms) CC_msstart(ms)
C_icon | char *:val arith:siz | COMMA(); WCON(sp_icon, val, siz) #define C_mes_end() CC_msend()
C_ucon | char *:val arith:siz | COMMA(); WCON(sp_ucon, val, siz)
C_fcon | char *:val arith:siz | COMMA(); WCON(sp_fcon, val, siz)
C_scon | char *:str arith:siz | COMMA(); SCON(str, siz)
C_dnam | char *:str arith:val | COMMA(); NOFF(str, val)
C_dlb | label:l arith:val | COMMA(); DOFF(l, val)
C_ilb | label:l | COMMA(); ILB(l)
C_pnam | char *:str | COMMA(); PNAM(str)
C_mes_begin | int:ms | PS(ps_mes); CST((arith)ms) #define C_exc(c1,c2) CC_exc(c1,c2)
C_mes_end | | CEND(); NL()
% Yes, there really is a C_exc routine... #ifndef ps_rom
C_exc | arith:c1 arith:c2 | PS(ps_exc); CST(c1); COMMA(); CST(c2); NL() #include <em_pseu.h>
#endif
#ifndef op_lol
#include <em_mnem.h>
#endif

View file

@ -472,6 +472,9 @@ mechanism, the routine
.I C_internal_error .I C_internal_error
is called. Again, the user can override its default definition by supplying his is called. Again, the user can override its default definition by supplying his
own. Such errors, however, are caused by a programming error of the user. own. Such errors, however, are caused by a programming error of the user.
.SH REMARKS
Some of the routines in this module may be implemented as macros. So,
do not try to take the address of these functions.
.SH BUGS .SH BUGS
It is not possible to indicate that the argument of It is not possible to indicate that the argument of
.B C_con_cst () .B C_con_cst ()

11
modules/src/em_code/end.c Normal file
View file

@ -0,0 +1,11 @@
#include "em_private.h"
CC_end(l)
arith l;
{
/* END pseudo of procedure with l locals
*/
PS(ps_end);
CST(l);
NL();
}

View file

@ -0,0 +1,10 @@
#include "em_private.h"
CC_endnarg()
{
/* END pseudo of procedure with unknown # of locals
*/
PS(ps_end);
CCEND();
NL();
}

11
modules/src/em_code/exc.c Normal file
View file

@ -0,0 +1,11 @@
#include "em_private.h"
CC_exc(c1,c2)
arith c1,c2;
{
PS(ps_exc);
CST(c1);
COMMA();
CST(c2);
NL();
}

View file

@ -0,0 +1,9 @@
#include "em_private.h"
CC_fcon(val, siz)
char *val;
arith siz;
{
COMMA();
WCON(sp_fcon, val, siz);
}

View file

@ -0,0 +1,9 @@
#include "em_private.h"
CC_icon(val, siz)
char *val;
arith siz;
{
COMMA();
WCON(sp_icon, val, siz);
}

View file

@ -0,0 +1,8 @@
#include "em_private.h"
CC_ilb(l)
label l;
{
COMMA();
ILB(l);
}

View file

@ -0,0 +1,7 @@
#include "em_private.h"
CC_msend()
{
CEND();
NL();
}

View file

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

10
modules/src/em_code/op.c Normal file
View file

@ -0,0 +1,10 @@
#include "em_private.h"
CC_op(opcode)
{
/* Instruction that never has an argument
Argument types: -
*/
OP(opcode);
NL();
}

View file

@ -0,0 +1,12 @@
#include "em_private.h"
CC_opcst(opcode, cst)
arith cst;
{
/* Instruction with a constant argument
Argument types: c, d, l, g, f, n, s, z, o, w, r
*/
OP(opcode);
CST(cst);
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_opdlb(opcode, dlb, offset)
label dlb;
arith offset;
{
/* Instruction that as a numeric datalabel + offset as argument
Argument types: g
*/
OP(opcode);
DOFF(dlb, offset);
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_opdnam(opcode, dnam, offset)
char *dnam;
arith offset;
{
/* Instruction that has a datalabel + offset as argument
Argument types: g
*/
OP(opcode);
NOFF(dnam, offset);
NL();
}

View file

@ -0,0 +1,12 @@
#include "em_private.h"
CC_opilb(opcode, ilb)
label ilb;
{
/* Instruction with instruction label argument
Argument types: b
*/
OP(opcode);
CILB(ilb);
NL();
}

View file

@ -0,0 +1,11 @@
#include "em_private.h"
CC_opnarg(opcode)
{
/* Instruction with optional argument, but now without one
Argument types: w
*/
OP(opcode);
CCEND();
NL();
}

View file

@ -0,0 +1,12 @@
#include "em_private.h"
CC_oppnam(opcode, pnam)
char *pnam;
{
/* Instruction that has a procedure name as argument
Argument types: p
*/
OP(opcode);
PNAM(pnam);
NL();
}

View file

@ -0,0 +1,8 @@
#include "em_private.h"
CC_pnam(str)
char *str;
{
COMMA();
PNAM(str);
}

14
modules/src/em_code/pro.c Normal file
View file

@ -0,0 +1,14 @@
#include "em_private.h"
CC_pro(pnam, l)
char *pnam;
arith l;
{
/* PRO pseudo with procedure name pnam and # of locals l
*/
PS(ps_pro);
PNAM(pnam);
COMMA();
CST(l);
NL();
}

View file

@ -0,0 +1,13 @@
#include "em_private.h"
CC_pronarg(pnam)
char *pnam;
{
/* PRO pseudo with procedure name pnam and unknown # of locals
*/
PS(ps_pro);
PNAM(pnam);
COMMA();
CCEND();
NL();
}

View file

@ -0,0 +1,11 @@
#include "em_private.h"
CC_psdlb(op, dlb)
label dlb;
{
/* Pseudo with numeric datalabel
*/
PS(op);
DLB(dlb);
NL();
}

View file

@ -0,0 +1,11 @@
#include "em_private.h"
CC_psdnam(op, dnam)
char *dnam;
{
/* Pseudo with data label
*/
PS(op);
DNAM(dnam);
NL();
}

View file

@ -0,0 +1,11 @@
#include "em_private.h"
CC_pspnam(op, pnam)
char *pnam;
{
/* Pseudo with procedure name
*/
PS(op);
PNAM(pnam);
NL();
}

View file

@ -0,0 +1,9 @@
#include "em_private.h"
CC_scon(str, siz)
char *str;
arith siz;
{
COMMA();
SCON(str, siz);
}

View file

@ -0,0 +1,9 @@
#include "em_private.h"
CC_ucon(val,siz)
char *val;
arith siz;
{
COMMA();
WCON(sp_ucon, val, siz);
}