diff --git a/modules/src/em_code/CMakeLists.txt b/modules/src/em_code/CMakeLists.txt new file mode 100644 index 000000000..91761f99e --- /dev/null +++ b/modules/src/em_code/CMakeLists.txt @@ -0,0 +1,99 @@ +cmake_minimum_required (VERSION 2.9) +project(em_code) + +set(SRC + bhcst.c + bhdlb.c + bhdnam.c + bhfcon.c + bhicon.c + bhilb.c + bhpnam.c + bhucon.c + crcst.c + crdlb.c + crdnam.c + crxcon.c + crilb.c + crpnam.c + crscon.c + cst.c + dfdlb.c + dfdnam.c + dfilb.c + dlb.c + dnam.c + end.c + endarg.c + exc.c + fcon.c + getid.c + icon.c + ilb.c + insert.c + internerr.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 + failed.c + em.c + em_codeEK.h + em_code.h + em_codeCE.h + em_codeO.h + em_private.h +) + +set(INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) + + + +add_library(eme ${SRC}) +target_include_directories(eme PUBLIC ${INCLUDE_DIRS}) +target_compile_definitions(eme PRIVATE READABLE_EM) +target_link_libraries(eme em_data alloc print system) + +add_library(emk ${SRC}) +target_include_directories(emk PUBLIC ${INCLUDE_DIRS}) +target_link_libraries(emk em_data alloc print system) + +set_target_properties(eme PROPERTIES PUBLIC_HEADER "em_codeEK.h") +set_target_properties(emk PROPERTIES PUBLIC_HEADER "em_codeEK.h") + +add_custom_command( + OUTPUT em_codeEK.h file1.tmp + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/makeem.sed + ${CMAKE_CURRENT_BINARY_DIR}/makeem.sed + COMMAND sed -f makeem.sed ${CMAKE_CURRENT_SOURCE_DIR}/../../../h/em_table>file1.tmp + COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/em.nogen file1.tmp>em_codeEK.h + COMMENT "Regenerate em_codeEK.h from em_table" +) + +install(TARGETS eme emk + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include +) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/em_code.3X DESTINATION man OPTIONAL) + + diff --git a/modules/src/em_code/C_out.c b/modules/src/em_code/C_out.c index 135934096..f03c10c45 100644 --- a/modules/src/em_code/C_out.c +++ b/modules/src/em_code/C_out.c @@ -9,25 +9,22 @@ /* $Id$ */ -static arg(); -static pseudo(); +static void arg(struct e_instr *p, int comma); +static void pseudo(struct e_instr *p); extern char em_flag[]; char *C_error; #define flags(pp) (em_flag[(pp)->em_opcode - sp_fmnem] & EM_PAR) -struct e_instr * -C_alloc() +struct e_instr *C_alloc(void) { static struct e_instr b; return &b; } -int -C_out(p) - register struct e_instr *p; +int C_out(register struct e_instr *p) { /* Generate EM-code from the e_instr structure "p" */ @@ -82,9 +79,7 @@ C_out(p) return 1; } -static -arg(p, comma) - register struct e_instr *p; +static void arg(register struct e_instr *p, int comma) { /* Output the argument of "p". */ @@ -145,9 +140,7 @@ arg(p, comma) } } -static -pseudo(p) - register struct e_instr *p; +static void pseudo(register struct e_instr *p) { PS(p->em_opcode); diff --git a/modules/src/em_code/bhcst.c b/modules/src/em_code/bhcst.c index a49ab59f0..63edd1b35 100644 --- a/modules/src/em_code/bhcst.c +++ b/modules/src/em_code/bhcst.c @@ -2,11 +2,7 @@ /* $Id$ */ -void -CC_bhcst(op, n, w, i) - arith n; - arith w; - int i; +void CC_bhcst(int op, arith n, arith w, int i) { /* BSS or HOL with size n, initial value a cst w, and flag i */ diff --git a/modules/src/em_code/bhdlb.c b/modules/src/em_code/bhdlb.c index 702960aa0..881331940 100644 --- a/modules/src/em_code/bhdlb.c +++ b/modules/src/em_code/bhdlb.c @@ -2,12 +2,7 @@ /* $Id$ */ -void -CC_bhdlb(op, n, s, off, i) - arith n; - label s; - arith off; - int i; +void CC_bhdlb(int op, arith n, label s, arith off, int i) { /* BSS or HOL with size n, initial value a dlb(s, off), and flag i diff --git a/modules/src/em_code/bhdnam.c b/modules/src/em_code/bhdnam.c index d47465c22..f73f85f36 100644 --- a/modules/src/em_code/bhdnam.c +++ b/modules/src/em_code/bhdnam.c @@ -2,12 +2,7 @@ /* $Id$ */ -void -CC_bhdnam(op, n, s, off, i) - arith n; - char *s; - arith off; - int i; +void CC_bhdnam(int op, arith n, char *s, arith off, int i) { /* BSS or HOL with size n, initial value a dnam(s, off), and flag i diff --git a/modules/src/em_code/bhfcon.c b/modules/src/em_code/bhfcon.c index 9c9284596..3d31be776 100644 --- a/modules/src/em_code/bhfcon.c +++ b/modules/src/em_code/bhfcon.c @@ -2,12 +2,7 @@ /* $Id$ */ -void -CC_bhfcon(op, n, s, sz, i) - arith n; - char *s; - arith sz; - int i; +void CC_bhfcon(int op, arith n, char *s, arith sz, int i) { /* BSS or HOL with size n, initial value an FCON (s, sz), and flag i diff --git a/modules/src/em_code/bhicon.c b/modules/src/em_code/bhicon.c index b6bf6ac82..21dda2aea 100644 --- a/modules/src/em_code/bhicon.c +++ b/modules/src/em_code/bhicon.c @@ -2,12 +2,7 @@ /* $Id$ */ -void -CC_bhicon(op, n, s, sz, i) - arith n; - char *s; - arith sz; - int i; +void CC_bhicon(int op, arith n, char *s, arith sz, int i) { /* BSS or HOL with size n, initial value an ICON (s, sz), and flag i diff --git a/modules/src/em_code/bhilb.c b/modules/src/em_code/bhilb.c index eba7457c6..df03fdb5e 100644 --- a/modules/src/em_code/bhilb.c +++ b/modules/src/em_code/bhilb.c @@ -2,11 +2,7 @@ /* $Id$ */ -void -CC_bhilb(op, n, l, i) - arith n; - label l; - int i; +void CC_bhilb(int op, arith n, label l, int i) { /* BSS or HOL with size n, initial value a ILB(l), and flag i diff --git a/modules/src/em_code/bhpnam.c b/modules/src/em_code/bhpnam.c index 3f9a8d6ad..e3f80e3e9 100644 --- a/modules/src/em_code/bhpnam.c +++ b/modules/src/em_code/bhpnam.c @@ -2,11 +2,7 @@ /* $Id$ */ -void -CC_bhpnam(op, n, p, i) - arith n; - char *p; - int i; +void CC_bhpnam(int op, arith n, char *p, int i) { /* BSS or HOL with size n, initial value a PNAM(p), and flag i diff --git a/modules/src/em_code/bhucon.c b/modules/src/em_code/bhucon.c index de18fe9e4..66716916c 100644 --- a/modules/src/em_code/bhucon.c +++ b/modules/src/em_code/bhucon.c @@ -2,12 +2,7 @@ /* $Id$ */ -void -CC_bhucon(op, n, s, sz, i) - arith n; - char *s; - arith sz; - int i; +void CC_bhucon(int op, arith n, char *s, arith sz, int i) { /* BSS or HOL with size n, initial value an UCON (s, sz), and flag i diff --git a/modules/src/em_code/build.lua b/modules/src/em_code/build.lua index 3a82234cb..b65ce83ca 100644 --- a/modules/src/em_code/build.lua +++ b/modules/src/em_code/build.lua @@ -89,6 +89,7 @@ local function build_variant(code, cflags) "modules+headers", "modules/src/alloc+lib", "modules/src/em_data+lib", + "modules/src/print+lib", "modules/src/system+lib", }, vars = { diff --git a/modules/src/em_code/crcst.c b/modules/src/em_code/crcst.c index 6bacdb312..8e3f59444 100644 --- a/modules/src/em_code/crcst.c +++ b/modules/src/em_code/crcst.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_crcst(op, v) - arith v; +void CC_crcst(int op, arith v) { /* CON or ROM with argument CST(v) */ diff --git a/modules/src/em_code/crdlb.c b/modules/src/em_code/crdlb.c index 0cafe9f3a..032bdd07f 100644 --- a/modules/src/em_code/crdlb.c +++ b/modules/src/em_code/crdlb.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_crdlb(op, v, off) - label v; - arith off; +void CC_crdlb(int op, label v, arith off) { /* CON or ROM with argument DLB(v, off) */ diff --git a/modules/src/em_code/crdnam.c b/modules/src/em_code/crdnam.c index c8ec92da8..d7be5506a 100644 --- a/modules/src/em_code/crdnam.c +++ b/modules/src/em_code/crdnam.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_crdnam(op, s, off) - char *s; - arith off; +void CC_crdnam(int op, char* s, arith off) { /* CON or ROM with argument DNAM(s, off) */ diff --git a/modules/src/em_code/crilb.c b/modules/src/em_code/crilb.c index d0db218ec..cae0774c8 100644 --- a/modules/src/em_code/crilb.c +++ b/modules/src/em_code/crilb.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_crilb(op, l) - label l; +void CC_crilb(int op, label l) { /* CON or ROM with argument ILB(l) */ diff --git a/modules/src/em_code/crpnam.c b/modules/src/em_code/crpnam.c index 24c4c491f..1fdc41d20 100644 --- a/modules/src/em_code/crpnam.c +++ b/modules/src/em_code/crpnam.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_crpnam(op, p) - char *p; +void CC_crpnam(int op, char* p) { /* CON or ROM with argument PNAM(p) */ diff --git a/modules/src/em_code/crscon.c b/modules/src/em_code/crscon.c index eab953ef4..22c0fd809 100644 --- a/modules/src/em_code/crscon.c +++ b/modules/src/em_code/crscon.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_crscon(op, v, s) - char *v; - arith s; +void CC_crscon(int op, char* v, arith s) { /* CON or ROM with argument SCON(v,z) */ diff --git a/modules/src/em_code/crxcon.c b/modules/src/em_code/crxcon.c index 5fc706358..57b579f28 100644 --- a/modules/src/em_code/crxcon.c +++ b/modules/src/em_code/crxcon.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_crxcon(op, spec, v, s) - char *v; - arith s; +void CC_crxcon(int op, int spec, char* v, arith s) { /* CON or ROM with argument ICON(v,z) */ diff --git a/modules/src/em_code/cst.c b/modules/src/em_code/cst.c index 17cfdbc9f..7b81dccf4 100644 --- a/modules/src/em_code/cst.c +++ b/modules/src/em_code/cst.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_cst(l) - arith l; +void CC_cst(arith l) { COMMA(); CST(l); diff --git a/modules/src/em_code/dfdlb.c b/modules/src/em_code/dfdlb.c index eb9fbab09..90452f13e 100644 --- a/modules/src/em_code/dfdlb.c +++ b/modules/src/em_code/dfdlb.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_dfdlb(l) - label l; +void CC_dfdlb(label l) { /* Define numeric data label */ diff --git a/modules/src/em_code/dfdnam.c b/modules/src/em_code/dfdnam.c index 1f1478b73..bfcfbed12 100644 --- a/modules/src/em_code/dfdnam.c +++ b/modules/src/em_code/dfdnam.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_dfdnam(s) - char *s; +void CC_dfdnam(char* s) { /* Define data label */ diff --git a/modules/src/em_code/dfilb.c b/modules/src/em_code/dfilb.c index 4dd88a136..e0f0cb483 100644 --- a/modules/src/em_code/dfilb.c +++ b/modules/src/em_code/dfilb.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_dfilb(l) - label l; +void CC_dfilb(label l) { /* Define instruction label */ diff --git a/modules/src/em_code/dlb.c b/modules/src/em_code/dlb.c index 8f711eb9d..5f0cd288e 100644 --- a/modules/src/em_code/dlb.c +++ b/modules/src/em_code/dlb.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_dlb(l, val) - label l; - arith val; +void CC_dlb(label l, arith val) { COMMA(); DOFF(l, val); diff --git a/modules/src/em_code/dnam.c b/modules/src/em_code/dnam.c index 5c0532198..85ebfa6ad 100644 --- a/modules/src/em_code/dnam.c +++ b/modules/src/em_code/dnam.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_dnam(str, val) - char *str; - arith val; +void CC_dnam(char* str, arith val) { COMMA(); NOFF(str, val); diff --git a/modules/src/em_code/em.c b/modules/src/em_code/em.c index cf6948bff..61d4c70dc 100644 --- a/modules/src/em_code/em.c +++ b/modules/src/em_code/em.c @@ -12,7 +12,9 @@ #include #include #include +#include "system.h" #include "alloc.h" +#include "print.h" #include "em_arith.h" #include "insert.h" #include "em_private.h" @@ -49,8 +51,9 @@ char *C_current_out = obuf; char *C_opp = obuf; #endif -void -C_flush() { +void C_flush(void) +{ + int count; #ifdef INCORE static unsigned int bufsiz; @@ -69,6 +72,7 @@ C_flush() { return; } #endif + count = (int)(C_opp - obuf); if (C_opp != obuf && sys_write(C_ofp, obuf, (int)(C_opp - obuf)) == 0) { C_ofp = 0; C_failed(); @@ -82,9 +86,7 @@ C_flush() { #define Xputbyte(c) put(c) #endif -void -C_putbyte(c) - int c; +void C_putbyte(int c) { Xputbyte(c); } @@ -94,15 +96,11 @@ C_putbyte(c) #endif /*ARGSUSED*/ -void -C_init(w, p) - arith w, p; +void C_init(arith w, arith p) { } -int -C_open(nm) - char *nm; +int C_open(char* nm) { /* Open file "nm" for output */ @@ -110,13 +108,15 @@ C_open(nm) if (nm == 0) C_ofp = STDOUT; /* standard output */ else - if (sys_open(nm, OP_WRITE, &C_ofp) == 0) + { + + if (sys_open(nm, OP_WRITE, &C_ofp) == 0) return 0; + } return 1; } -void -C_close() +void C_close(void) { /* Finish the code-generation. */ @@ -150,8 +150,7 @@ C_close() C_ofp = 0; } -int -C_busy() +int C_busy(void) { return C_ofp != 0; /* true if code is being generated */ } @@ -165,32 +164,27 @@ C_busy() names. */ -void -C_magic() +void C_magic(void) { } /*** the readable code generating routines ***/ -static -wrs(s) - register char *s; +static int wrs(register char *s) { - while (*s) { + while (*s) + { C_putbyte(*s++); } + return 0; } -void -C_pt_dnam(s) - char *s; +void C_pt_dnam(char* s) { wrs(s); } -void -C_pt_ilb(l) - label l; +void C_pt_ilb(label l) { char buf[16]; @@ -201,17 +195,14 @@ C_pt_ilb(l) extern char em_mnem[][4]; extern char em_pseu[][4]; -void -C_pt_op(x) +void C_pt_op(int x) { C_putbyte(' '); wrs(em_mnem[x - sp_fmnem]); C_putbyte(' '); } -void -C_pt_cst(l) - arith l; +void C_pt_cst(arith l) { char buf[16]; @@ -219,10 +210,7 @@ C_pt_cst(l) wrs(buf); } -void -C_pt_scon(x, y) - char *x; - arith y; +void C_pt_scon(char *x, arith y) { char xbuf[1024]; register char *p; @@ -239,17 +227,14 @@ C_pt_scon(x, y) C_putbyte('\''); } -void -C_pt_ps(x) +void C_pt_ps(int x) { C_putbyte(' '); wrs(em_pseu[x - sp_fpseu]); C_putbyte(' '); } -void -C_pt_dlb(l) - label l; +void C_pt_dlb(label l) { char buf[16]; @@ -257,10 +242,7 @@ C_pt_dlb(l) wrs(buf); } -void -C_pt_doff(l, v) - label l; - arith v; +void C_pt_doff(label l, arith v) { char buf[16]; @@ -271,10 +253,7 @@ C_pt_doff(l, v) } } -void -C_pt_noff(s, v) - char *s; - arith v; +void C_pt_noff(char *s, arith v) { char buf[16]; @@ -285,17 +264,13 @@ C_pt_noff(s, v) } } -void -C_pt_pnam(s) - char *s; +void C_pt_pnam(char *s) { C_putbyte('$'); wrs(s); } -void -C_pt_dfilb(l) - label l; +void C_pt_dfilb(label l) { char buf[16]; @@ -303,11 +278,7 @@ C_pt_dfilb(l) wrs(buf); } -void -C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ - int sp; - char *v; - arith sz; +void C_pt_wcon(int sp, char *v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ { int ch = sp == sp_icon ? 'I' : sp == sp_ucon ? 'U' : 'F'; @@ -316,18 +287,18 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ C_pt_cst(sz); } -void -C_pt_nl() { +void C_pt_nl(void) +{ C_putbyte('\n'); } -void -C_pt_comma() { +void C_pt_comma(void) +{ C_putbyte(','); } -void -C_pt_ccend() { +void C_pt_ccend(void) +{ C_putbyte('?'); } @@ -345,8 +316,7 @@ C_pt_ccend() { names. */ -void -C_magic() +void C_magic(void) { put16(sp_magic); } @@ -355,9 +325,7 @@ C_magic() #define fit16i(x) ((x) >= (long)(-0x8000) && (x) <= (long)0x7FFF) #define fit8u(x) ((x) <= 0xFF) /* x is already unsigned */ -void -C_pt_ilb(l) - register label l; +void C_pt_ilb(register label l) { if (fit8u(l)) { put8(sp_ilb1); @@ -369,9 +337,7 @@ C_pt_ilb(l) } } -void -C_pt_dlb(l) - register label l; +void C_pt_dlb(register label l) { if (fit8u(l)) { put8(sp_dlb1); @@ -383,9 +349,7 @@ C_pt_dlb(l) } } -void -C_pt_cst(l) - register arith l; +void C_pt_cst(register arith l) { if (l >= (arith) -sp_zcst0 && l < (arith) (sp_ncst0 - sp_zcst0)) { /* we can convert 'l' to an int because its value @@ -404,10 +368,7 @@ C_pt_cst(l) } } -void -C_pt_doff(l, v) - label l; - arith v; +void C_pt_doff(label l, arith v) { if (v == 0) { C_pt_dlb(l); @@ -419,9 +380,7 @@ C_pt_doff(l, v) } } -void -C_pt_str(s) - register char *s; +void C_pt_str(register char *s) { register int len; @@ -431,18 +390,13 @@ C_pt_str(s) } } -void -C_pt_dnam(s) - char *s; +void C_pt_dnam(char* s) { put8(sp_dnam); C_pt_str(s); } -void -C_pt_noff(s, v) - char *s; - arith v; +void C_pt_noff(char* s, arith v) { if (v == 0) { C_pt_dnam(s); @@ -454,19 +408,13 @@ C_pt_noff(s, v) } } -void -C_pt_pnam(s) - char *s; +void C_pt_pnam(char* s) { put8(sp_pnam); C_pt_str(s); } -void -C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ - int sp; - char *v; - arith sz; +void C_pt_wcon(int sp, char* v, arith sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ { /* how 'bout signextension int --> long ??? */ put8(sp); @@ -474,10 +422,7 @@ C_pt_wcon(sp, v, sz) /* sp_icon, sp_ucon or sp_fcon with int repr */ C_pt_str(v); } -void -C_pt_scon(b, n) - register char *b; - register arith n; +void C_pt_scon(register char *b, register arith n) { put8(sp_scon); C_pt_cst(n); diff --git a/modules/src/em_code/em_code.h b/modules/src/em_code/em_code.h index 26a3251a5..028e5ba14 100644 --- a/modules/src/em_code/em_code.h +++ b/modules/src/em_code/em_code.h @@ -5,6 +5,7 @@ */ #include "em_mesX.h" +#include "em_arith.h" #include "ansi.h" _PROTOTYPE(void C_ms_com, (char *)); @@ -24,6 +25,8 @@ _PROTOTYPE(void C_ms_stb_ilb, (char *, int, int, label)); _PROTOTYPE(void C_ms_stb_pnam, (char *, int, int, char *)); _PROTOTYPE(void C_ms_std, (char *, int, int)); + + #ifdef PEEPHOLE #include "em_codeO.h" #include "emO_code.h" diff --git a/modules/src/em_code/em_private.h b/modules/src/em_code/em_private.h index 45b80f572..b706d9bf5 100644 --- a/modules/src/em_code/em_private.h +++ b/modules/src/em_code/em_private.h @@ -5,16 +5,16 @@ */ /* private inclusion file */ -#include -#include +#include "em_arith.h" +#include "em_label.h" /* include the EM description files */ -#include -#include -#include -#include +#include "em_spec.h" +#include "em_pseu.h" +#include "em_mnem.h" +#include "em_reg.h" -#include +#include "ansi.h" #include "em_codeEK.h" @@ -79,6 +79,10 @@ _PROTOTYPE(void C_pt_noff, (char *, arith)); _PROTOTYPE(void C_pt_pnam, (char *)); _PROTOTYPE(void C_pt_dfilb, (label)); _PROTOTYPE(void C_pt_wcon, (int, char *, arith)); +_PROTOTYPE(void C_failed, (void)); +_PROTOTYPE(void C_flush, (void)); +_PROTOTYPE(void C_internal_error, (void)); +_PROTOTYPE(void C_putbyte, (int)); #ifdef READABLE_EM _PROTOTYPE(void C_pt_ps, (int)); _PROTOTYPE(void C_pt_op, (int)); diff --git a/modules/src/em_code/end.c b/modules/src/em_code/end.c index b5ac6496b..580751a25 100644 --- a/modules/src/em_code/end.c +++ b/modules/src/em_code/end.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_end(l) - arith l; +void CC_end(arith l) { /* END pseudo of procedure with l locals */ diff --git a/modules/src/em_code/endarg.c b/modules/src/em_code/endarg.c index 510fc48a2..f2b6320b4 100644 --- a/modules/src/em_code/endarg.c +++ b/modules/src/em_code/endarg.c @@ -2,8 +2,7 @@ /* $Id$ */ -void -CC_endnarg() +void CC_endnarg() { /* END pseudo of procedure with unknown # of locals */ diff --git a/modules/src/em_code/exc.c b/modules/src/em_code/exc.c index 3fe2b2568..905a902fb 100644 --- a/modules/src/em_code/exc.c +++ b/modules/src/em_code/exc.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_exc(c1,c2) - arith c1,c2; +void CC_exc(arith c1,arith c2) { PS(ps_exc); CST(c1); diff --git a/modules/src/em_code/fcon.c b/modules/src/em_code/fcon.c index c33731fbb..bdd9f9ea0 100644 --- a/modules/src/em_code/fcon.c +++ b/modules/src/em_code/fcon.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_fcon(val, siz) - char *val; - arith siz; +void CC_fcon(char* val, arith siz) { COMMA(); WCON(sp_fcon, val, siz); diff --git a/modules/src/em_code/getid.c b/modules/src/em_code/getid.c index 157b7e8c6..f8fb1f5fc 100644 --- a/modules/src/em_code/getid.c +++ b/modules/src/em_code/getid.c @@ -3,8 +3,7 @@ /* Get a unique id for C_insertpart, etc. */ -int -C_getid() +int C_getid(void) { static int id = 0; diff --git a/modules/src/em_code/icon.c b/modules/src/em_code/icon.c index bed0886e0..488382939 100644 --- a/modules/src/em_code/icon.c +++ b/modules/src/em_code/icon.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_icon(val, siz) - char *val; - arith siz; +void CC_icon(char* val, arith siz) { COMMA(); WCON(sp_icon, val, siz); diff --git a/modules/src/em_code/ilb.c b/modules/src/em_code/ilb.c index 6c4168075..b54c4bdb8 100644 --- a/modules/src/em_code/ilb.c +++ b/modules/src/em_code/ilb.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_ilb(l) - label l; +void CC_ilb(label l) { COMMA(); ILB(l); diff --git a/modules/src/em_code/insert.c b/modules/src/em_code/insert.c index 00c628dcb..2048d0414 100644 --- a/modules/src/em_code/insert.c +++ b/modules/src/em_code/insert.c @@ -11,11 +11,18 @@ #include #include -#include -#include +#include +#include +#include "em_private.h" +#include "system.h" +/*#include "em_path.h"*/ +#include "alloc.h" #include "insert.h" -char *C_tmpdir = TMP_DIR; +/* To make this portable, the initial value here is NULL + * and system is used to retrieve the correct directory + */ +char *C_tmpdir = NULL; static Part *C_stable[TABSIZ]; static char *C_old_top; @@ -58,12 +65,10 @@ getbyte(b) } #endif -static C_out_parts(); -static Part *C_findpart(); +static void C_out_parts(register PartOfPart *pp); +static Part *C_findpart(int part); -static -outpart(id) - int id; +static int outpart(int id) { /* Output part "id", if present. */ @@ -73,11 +78,10 @@ outpart(id) C_out_parts(p->p_parts); p->p_parts = 0; } + return 0; } -static -C_out_parts(pp) - register PartOfPart *pp; +static void C_out_parts(register PartOfPart *pp) { /* Output the list of chunks started by "pp". The list is build in reverse order, so this routine is @@ -119,9 +123,7 @@ C_out_parts(pp) } } -static Part * -C_findpart(part) - int part; +static Part *C_findpart(int part) { /* Look for part "part" in the table. Return 0 if not present, @@ -134,14 +136,22 @@ C_findpart(part) return p; } -static -swttmp() + + + +static int swttmp(void) { #ifndef INCORE - if (C_tmpfile == 0) { - static char tmpbuf[64]; + if (C_tmpfile == NULL) { + + static char tmpbuf[FILENAME_MAX]; register char *p = tmpbuf; + if (C_tmpdir == NULL) + { + C_tmpdir = sys_gettmpdir(); + assert(C_tmpdir != NULL); + } strcpy(p, C_tmpdir); strcat(p, "/CodeXXXXXX"); close(mkstemp(p)); @@ -175,10 +185,10 @@ swttmp() C_ontmpfile = 1; } #endif + return 0; } -static -swtout() +static int swtout(void) { #ifndef INCORE if (C_ontmpfile) { @@ -203,11 +213,10 @@ swtout() C_ontmpfile = 0; } #endif + return 0; } -static int -available(part) - int part; +static int available(int part) { /* See if part "part", and all the parts it consists of, are available. Return 1 if they are, 0 otherwize @@ -240,9 +249,7 @@ available(part) return retval; } -static Part * -mkpart(part) - int part; +static Part *mkpart(int part) { /* Create a Part structure with id "part", and return a pointer to it, after checking that is does not exist @@ -266,9 +273,7 @@ mkpart(part) return p; } -static -end_partofpart(p) - register Part *p; +static void end_partofpart(register Part *p) { /* End the current chunk of part *p. */ @@ -285,9 +290,7 @@ end_partofpart(p) } } -static -resume(p) - register Part *p; +static void resume(register Part *p) { /* Resume part "p", by creating a new PartOfPart structure for it. @@ -302,9 +305,7 @@ resume(p) pp->pp_begin = C_current_out - C_BASE; } -void -C_insertpart(part) - int part; +void C_insertpart(int part) { /* Insert part "part" in the current part. If C_sequential is still set and the part to be inserted is available now, @@ -341,9 +342,7 @@ C_insertpart(part) resume(p); } -void -C_beginpart(part) - int part; +void C_beginpart(int part) { /* Now follows the definition for part "part". Suspend the current part, and add part "part" to the @@ -361,9 +360,7 @@ C_beginpart(part) resume(p); } -void -C_endpart(part) - int part; +void C_endpart(int part) { /* End the current part. The parameter "part" is just there for the checking. Do we really need it ??? diff --git a/modules/src/em_code/internerr.c b/modules/src/em_code/internerr.c index 19bd6538a..f77aadfc8 100644 --- a/modules/src/em_code/internerr.c +++ b/modules/src/em_code/internerr.c @@ -3,10 +3,11 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ -#include +#include +#include +#include "system.h" -void -C_internal_error() +void C_internal_error(void) { sys_write(STDERR,"internal error\n",15); sys_stop(S_EXIT); diff --git a/modules/src/em_code/makeem.sed b/modules/src/em_code/makeem.sed new file mode 100644 index 000000000..8db5d8cc9 --- /dev/null +++ b/modules/src/em_code/makeem.sed @@ -0,0 +1,18 @@ +1i\ +/* this part is generated from em_table */ +# Remove pseudo instructions +/^\(...\) \([0-9]\).*/d +# Remove opcode constant categories/count +/^\(....\) \([0-9]\).*/d +/^\(.....\) \([0-9]\).*/d +# Below are the actual replacement of opcodes. +s/^\(...\) \(d\).*/#define C_\1(c) CC_opcst(op_\1, c)/ +s/^\(...\) \([cslnfzor]\).*/#define C_\1(c) CC_opcst(op_\1, c)/ +s/^\(...\) \(w\).*/#define C_\1(w) CC_opcst(op_\1, w)\ +#define C_\1_narg() CC_opnarg(op_\1)/ +s/^\(...\) \(g\).*/#define C_\1(g) CC_opcst(op_\1, g)\ +#define C_\1_dnam(g, o) CC_opdnam(op_\1, g, o)\ +#define C_\1_dlb(g, o) CC_opdlb(op_\1, g, o)/ +s/^\(...\) \(p\).*/#define C_\1(p) CC_oppnam(op_\1, p)/ +s/^\(...\) \(b\).*/#define C_\1(b) CC_opilb(op_\1, b)/ +s/^\(...\) \(-\).*/#define C_\1() CC_op(op_\1)/ diff --git a/modules/src/em_code/msend.c b/modules/src/em_code/msend.c index f78dcae81..01745946d 100644 --- a/modules/src/em_code/msend.c +++ b/modules/src/em_code/msend.c @@ -2,8 +2,7 @@ /* $Id$ */ -void -CC_msend() +void CC_msend(void) { CEND(); NL(); diff --git a/modules/src/em_code/msstart.c b/modules/src/em_code/msstart.c index 82bc13670..edc5027fd 100644 --- a/modules/src/em_code/msstart.c +++ b/modules/src/em_code/msstart.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_msstart(cst) - int cst; +void CC_msstart(int cst) { /* start of message */ diff --git a/modules/src/em_code/op.c b/modules/src/em_code/op.c index ac03706b8..df98c8fd2 100644 --- a/modules/src/em_code/op.c +++ b/modules/src/em_code/op.c @@ -2,8 +2,7 @@ /* $Id$ */ -void -CC_op(opcode) +void CC_op(int opcode) { /* Instruction that never has an argument Argument types: - diff --git a/modules/src/em_code/opcst.c b/modules/src/em_code/opcst.c index 782f15c74..8f6dab35d 100644 --- a/modules/src/em_code/opcst.c +++ b/modules/src/em_code/opcst.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_opcst(opcode, cst) - arith cst; +void CC_opcst(int opcode, arith cst) { /* Instruction with a constant argument Argument types: c, d, l, g, f, n, s, z, o, w, r diff --git a/modules/src/em_code/opdlb.c b/modules/src/em_code/opdlb.c index 59c8ed5d6..7df00960c 100644 --- a/modules/src/em_code/opdlb.c +++ b/modules/src/em_code/opdlb.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_opdlb(opcode, dlb, offset) - label dlb; - arith offset; +void CC_opdlb(int opcode, label dlb, arith offset) { /* Instruction that as a numeric datalabel + offset as argument Argument types: g diff --git a/modules/src/em_code/opdnam.c b/modules/src/em_code/opdnam.c index 84fd207a9..640a52945 100644 --- a/modules/src/em_code/opdnam.c +++ b/modules/src/em_code/opdnam.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_opdnam(opcode, dnam, offset) - char *dnam; - arith offset; +void CC_opdnam(int opcode, char* dnam, arith offset) { /* Instruction that has a datalabel + offset as argument Argument types: g diff --git a/modules/src/em_code/opilb.c b/modules/src/em_code/opilb.c index 8cecaece8..637811dc0 100644 --- a/modules/src/em_code/opilb.c +++ b/modules/src/em_code/opilb.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_opilb(opcode, ilb) - label ilb; +void CC_opilb(int opcode, label ilb) { /* Instruction with instruction label argument Argument types: b diff --git a/modules/src/em_code/opnarg.c b/modules/src/em_code/opnarg.c index 241cc0002..e6fada6b1 100644 --- a/modules/src/em_code/opnarg.c +++ b/modules/src/em_code/opnarg.c @@ -2,8 +2,7 @@ /* $Id$ */ -void -CC_opnarg(opcode) +void CC_opnarg(int opcode) { /* Instruction with optional argument, but now without one Argument types: w diff --git a/modules/src/em_code/oppnam.c b/modules/src/em_code/oppnam.c index d799772fd..20e203836 100644 --- a/modules/src/em_code/oppnam.c +++ b/modules/src/em_code/oppnam.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_oppnam(opcode, pnam) - char *pnam; +void CC_oppnam(int opcode, char* pnam) { /* Instruction that has a procedure name as argument Argument types: p diff --git a/modules/src/em_code/pnam.c b/modules/src/em_code/pnam.c index 5e21a2a9c..e5efbfa7f 100644 --- a/modules/src/em_code/pnam.c +++ b/modules/src/em_code/pnam.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_pnam(str) - char *str; +void CC_pnam(char* str) { COMMA(); PNAM(str); diff --git a/modules/src/em_code/pro.c b/modules/src/em_code/pro.c index 5829a4b6d..20c9e2513 100644 --- a/modules/src/em_code/pro.c +++ b/modules/src/em_code/pro.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_pro(pnam, l) - char *pnam; - arith l; +void CC_pro(char* pnam, arith l) { /* PRO pseudo with procedure name pnam and # of locals l */ diff --git a/modules/src/em_code/pronarg.c b/modules/src/em_code/pronarg.c index 2204f04ae..9f714a439 100644 --- a/modules/src/em_code/pronarg.c +++ b/modules/src/em_code/pronarg.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_pronarg(pnam) - char *pnam; +void CC_pronarg(char* pnam) { /* PRO pseudo with procedure name pnam and unknown # of locals */ diff --git a/modules/src/em_code/psdlb.c b/modules/src/em_code/psdlb.c index 73d674d6e..a006ab950 100644 --- a/modules/src/em_code/psdlb.c +++ b/modules/src/em_code/psdlb.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_psdlb(op, dlb) - label dlb; +void CC_psdlb(int op, label dlb) { /* Pseudo with numeric datalabel */ diff --git a/modules/src/em_code/psdnam.c b/modules/src/em_code/psdnam.c index 5acf6971e..05815921a 100644 --- a/modules/src/em_code/psdnam.c +++ b/modules/src/em_code/psdnam.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_psdnam(op, dnam) - char *dnam; +void CC_psdnam(int op, char* dnam) { /* Pseudo with data label */ diff --git a/modules/src/em_code/pspnam.c b/modules/src/em_code/pspnam.c index 283fce43e..cf364ffe9 100644 --- a/modules/src/em_code/pspnam.c +++ b/modules/src/em_code/pspnam.c @@ -2,9 +2,7 @@ /* $Id$ */ -void -CC_pspnam(op, pnam) - char *pnam; +void CC_pspnam(int op, char* pnam) { /* Pseudo with procedure name */ diff --git a/modules/src/em_code/scon.c b/modules/src/em_code/scon.c index 5c204dbbf..b421b4746 100644 --- a/modules/src/em_code/scon.c +++ b/modules/src/em_code/scon.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_scon(str, siz) - char *str; - arith siz; +void CC_scon(char* str, arith siz) { COMMA(); SCON(str, siz); diff --git a/modules/src/em_code/ucon.c b/modules/src/em_code/ucon.c index 4520c80dd..71ed04557 100644 --- a/modules/src/em_code/ucon.c +++ b/modules/src/em_code/ucon.c @@ -2,10 +2,7 @@ /* $Id$ */ -void -CC_ucon(val,siz) - char *val; - arith siz; +void CC_ucon(char* val,arith siz) { COMMA(); WCON(sp_ucon, val, siz);