From 9947059dcc01b2d8c612a8a68b6fbd8d202781ef Mon Sep 17 00:00:00 2001 From: kaashoek Date: Fri, 20 Nov 1987 10:41:03 +0000 Subject: [PATCH] Initial revision --- util/ceg/ce_back/as_back/Makefile | 93 ++++++++ util/ceg/ce_back/as_back/back.h | 18 ++ util/ceg/ce_back/as_back/bottom.c | 96 ++++++++ util/ceg/ce_back/as_back/bss.c | 7 + util/ceg/ce_back/as_back/con1.c | 7 + util/ceg/ce_back/as_back/con2.c | 7 + util/ceg/ce_back/as_back/con4.c | 7 + util/ceg/ce_back/as_back/const.h | 2 + util/ceg/ce_back/as_back/do_close.c | 6 + util/ceg/ce_back/as_back/do_open.c | 10 + util/ceg/ce_back/as_back/end_back.c | 5 + util/ceg/ce_back/as_back/gen1.c | 17 ++ util/ceg/ce_back/as_back/gen2.c | 17 ++ util/ceg/ce_back/as_back/gen4.c | 17 ++ util/ceg/ce_back/as_back/header.h | 7 + util/ceg/ce_back/as_back/init_back.c | 5 + util/ceg/ce_back/as_back/reloc1.c | 9 + util/ceg/ce_back/as_back/reloc2.c | 9 + util/ceg/ce_back/as_back/reloc4.c | 9 + util/ceg/ce_back/as_back/rom1.c | 7 + util/ceg/ce_back/as_back/rom2.c | 7 + util/ceg/ce_back/as_back/rom4.c | 7 + util/ceg/ce_back/as_back/set_global.c | 7 + util/ceg/ce_back/as_back/set_local.c | 7 + util/ceg/ce_back/as_back/switchseg.c | 25 ++ util/ceg/ce_back/as_back/symboldef.c | 7 + util/ceg/ce_back/as_back/text1.c | 7 + util/ceg/ce_back/as_back/text2.c | 7 + util/ceg/ce_back/as_back/text4.c | 7 + util/ceg/ce_back/obj_back/Makefile | 107 +++++++++ util/ceg/ce_back/obj_back/back.h | 27 +++ util/ceg/ce_back/obj_back/con2.c | 15 ++ util/ceg/ce_back/obj_back/con4.c | 15 ++ util/ceg/ce_back/obj_back/data.c | 97 ++++++++ util/ceg/ce_back/obj_back/data.h | 13 ++ util/ceg/ce_back/obj_back/do_close.c | 10 + util/ceg/ce_back/obj_back/do_open.c | 14 ++ util/ceg/ce_back/obj_back/end_back.c | 41 ++++ util/ceg/ce_back/obj_back/extnd.c | 77 +++++++ util/ceg/ce_back/obj_back/gen1.c | 21 ++ util/ceg/ce_back/obj_back/gen2.c | 15 ++ util/ceg/ce_back/obj_back/gen4.c | 14 ++ util/ceg/ce_back/obj_back/hash.h | 6 + util/ceg/ce_back/obj_back/header.h | 5 + util/ceg/ce_back/obj_back/init_back.c | 27 +++ util/ceg/ce_back/obj_back/label.c | 24 ++ util/ceg/ce_back/obj_back/memory.c | 64 ++++++ util/ceg/ce_back/obj_back/misc.c | 39 ++++ util/ceg/ce_back/obj_back/mysprint.c | 122 ++++++++++ util/ceg/ce_back/obj_back/output.c | 89 +++++++ util/ceg/ce_back/obj_back/reloc1.c | 29 +++ util/ceg/ce_back/obj_back/reloc2.c | 29 +++ util/ceg/ce_back/obj_back/reloc4.c | 35 +++ util/ceg/ce_back/obj_back/relocation.c | 91 ++++++++ util/ceg/ce_back/obj_back/rom2.c | 16 ++ util/ceg/ce_back/obj_back/rom4.c | 15 ++ util/ceg/ce_back/obj_back/set_global.c | 14 ++ util/ceg/ce_back/obj_back/set_local.c | 14 ++ util/ceg/ce_back/obj_back/switchseg.c | 14 ++ util/ceg/ce_back/obj_back/symboldef.c | 18 ++ util/ceg/ce_back/obj_back/symtable.c | 99 ++++++++ util/ceg/ce_back/obj_back/text2.c | 15 ++ util/ceg/defaults/message/C_cst.c | 6 + util/ceg/defaults/message/C_dlb.c | 7 + util/ceg/defaults/message/C_dnam.c | 7 + util/ceg/defaults/message/C_fcon.c | 7 + util/ceg/defaults/message/C_icon.c | 7 + util/ceg/defaults/message/C_ilb.c | 6 + util/ceg/defaults/message/C_mes_begin.c | 6 + util/ceg/defaults/message/C_mes_end.c | 5 + util/ceg/defaults/message/C_pnam.c | 6 + util/ceg/defaults/message/C_scon.c | 7 + util/ceg/defaults/message/C_ucon.c | 7 + util/ceg/defaults/not_impl/not_impl.c | 7 + util/ceg/defaults/not_impl/not_impl_table | 268 ++++++++++++++++++++++ util/ceg/defaults/pseudo/C_busy.c | 6 + util/ceg/defaults/pseudo/C_close.c | 12 + util/ceg/defaults/pseudo/C_df_dlb.c | 13 ++ util/ceg/defaults/pseudo/C_df_dnam.c | 8 + util/ceg/defaults/pseudo/C_df_ilb.c | 9 + util/ceg/defaults/pseudo/C_end.c | 21 ++ util/ceg/defaults/pseudo/C_end_narg.c | 8 + util/ceg/defaults/pseudo/C_exa_dlb.c | 8 + util/ceg/defaults/pseudo/C_exa_dnam.c | 8 + util/ceg/defaults/pseudo/C_exp.c | 8 + util/ceg/defaults/pseudo/C_ina_dlb.c | 8 + util/ceg/defaults/pseudo/C_ina_dnam.c | 8 + util/ceg/defaults/pseudo/C_init.c | 18 ++ util/ceg/defaults/pseudo/C_inp.c | 8 + util/ceg/defaults/pseudo/C_magic.c | 3 + util/ceg/defaults/pseudo/C_open.c | 17 ++ util/ceg/defaults/pseudo/C_pro.c | 17 ++ util/ceg/defaults/pseudo/C_pro_narg.c | 24 ++ util/ceg/defaults/pseudo_vars.c | 1 + util/ceg/defaults/storage/C_bss_cst.c | 48 ++++ util/ceg/defaults/storage/C_bss_dlb.c | 49 ++++ util/ceg/defaults/storage/C_bss_dnam.c | 49 ++++ util/ceg/defaults/storage/C_bss_ilb.c | 49 ++++ util/ceg/defaults/storage/C_bss_pnam.c | 49 ++++ util/ceg/defaults/storage/C_con_cst.c | 39 ++++ util/ceg/defaults/storage/C_con_dlb.c | 39 ++++ util/ceg/defaults/storage/C_con_dnam.c | 39 ++++ util/ceg/defaults/storage/C_con_ilb.c | 38 +++ util/ceg/defaults/storage/C_con_pnam.c | 38 +++ util/ceg/defaults/storage/C_con_scon.c | 40 ++++ util/ceg/defaults/storage/C_hol_cst.c | 50 ++++ util/ceg/defaults/storage/C_hol_dlb.c | 51 ++++ util/ceg/defaults/storage/C_hol_dnam.c | 51 ++++ util/ceg/defaults/storage/C_hol_ilb.c | 51 ++++ util/ceg/defaults/storage/C_hol_pnam.c | 51 ++++ util/ceg/defaults/storage/C_rom_cst.c | 38 +++ util/ceg/defaults/storage/C_rom_dlb.c | 39 ++++ util/ceg/defaults/storage/C_rom_dnam.c | 39 ++++ util/ceg/defaults/storage/C_rom_ilb.c | 38 +++ util/ceg/defaults/storage/C_rom_pnam.c | 38 +++ util/ceg/defaults/storage/C_rom_scon.c | 40 ++++ util/ceg/util/create_ofiles | 9 + util/ceg/util/install_ceg | 16 ++ util/ceg/util/make_as | 70 ++++++ util/ceg/util/make_obj | 77 +++++++ util/ceg/util/make_own | 69 ++++++ util/ceg/util/preproc | 1 + util/ceg/util/update | 28 +++ 123 files changed, 3451 insertions(+) create mode 100644 util/ceg/ce_back/as_back/Makefile create mode 100644 util/ceg/ce_back/as_back/back.h create mode 100644 util/ceg/ce_back/as_back/bottom.c create mode 100644 util/ceg/ce_back/as_back/bss.c create mode 100644 util/ceg/ce_back/as_back/con1.c create mode 100644 util/ceg/ce_back/as_back/con2.c create mode 100644 util/ceg/ce_back/as_back/con4.c create mode 100644 util/ceg/ce_back/as_back/const.h create mode 100644 util/ceg/ce_back/as_back/do_close.c create mode 100644 util/ceg/ce_back/as_back/do_open.c create mode 100644 util/ceg/ce_back/as_back/end_back.c create mode 100644 util/ceg/ce_back/as_back/gen1.c create mode 100644 util/ceg/ce_back/as_back/gen2.c create mode 100644 util/ceg/ce_back/as_back/gen4.c create mode 100644 util/ceg/ce_back/as_back/header.h create mode 100644 util/ceg/ce_back/as_back/init_back.c create mode 100644 util/ceg/ce_back/as_back/reloc1.c create mode 100644 util/ceg/ce_back/as_back/reloc2.c create mode 100644 util/ceg/ce_back/as_back/reloc4.c create mode 100644 util/ceg/ce_back/as_back/rom1.c create mode 100644 util/ceg/ce_back/as_back/rom2.c create mode 100644 util/ceg/ce_back/as_back/rom4.c create mode 100644 util/ceg/ce_back/as_back/set_global.c create mode 100644 util/ceg/ce_back/as_back/set_local.c create mode 100644 util/ceg/ce_back/as_back/switchseg.c create mode 100644 util/ceg/ce_back/as_back/symboldef.c create mode 100644 util/ceg/ce_back/as_back/text1.c create mode 100644 util/ceg/ce_back/as_back/text2.c create mode 100644 util/ceg/ce_back/as_back/text4.c create mode 100644 util/ceg/ce_back/obj_back/Makefile create mode 100644 util/ceg/ce_back/obj_back/back.h create mode 100644 util/ceg/ce_back/obj_back/con2.c create mode 100644 util/ceg/ce_back/obj_back/con4.c create mode 100644 util/ceg/ce_back/obj_back/data.c create mode 100644 util/ceg/ce_back/obj_back/data.h create mode 100644 util/ceg/ce_back/obj_back/do_close.c create mode 100644 util/ceg/ce_back/obj_back/do_open.c create mode 100644 util/ceg/ce_back/obj_back/end_back.c create mode 100644 util/ceg/ce_back/obj_back/extnd.c create mode 100644 util/ceg/ce_back/obj_back/gen1.c create mode 100644 util/ceg/ce_back/obj_back/gen2.c create mode 100644 util/ceg/ce_back/obj_back/gen4.c create mode 100644 util/ceg/ce_back/obj_back/hash.h create mode 100644 util/ceg/ce_back/obj_back/header.h create mode 100644 util/ceg/ce_back/obj_back/init_back.c create mode 100644 util/ceg/ce_back/obj_back/label.c create mode 100644 util/ceg/ce_back/obj_back/memory.c create mode 100644 util/ceg/ce_back/obj_back/misc.c create mode 100644 util/ceg/ce_back/obj_back/mysprint.c create mode 100644 util/ceg/ce_back/obj_back/output.c create mode 100644 util/ceg/ce_back/obj_back/reloc1.c create mode 100644 util/ceg/ce_back/obj_back/reloc2.c create mode 100644 util/ceg/ce_back/obj_back/reloc4.c create mode 100644 util/ceg/ce_back/obj_back/relocation.c create mode 100644 util/ceg/ce_back/obj_back/rom2.c create mode 100644 util/ceg/ce_back/obj_back/rom4.c create mode 100644 util/ceg/ce_back/obj_back/set_global.c create mode 100644 util/ceg/ce_back/obj_back/set_local.c create mode 100644 util/ceg/ce_back/obj_back/switchseg.c create mode 100644 util/ceg/ce_back/obj_back/symboldef.c create mode 100644 util/ceg/ce_back/obj_back/symtable.c create mode 100644 util/ceg/ce_back/obj_back/text2.c create mode 100644 util/ceg/defaults/message/C_cst.c create mode 100644 util/ceg/defaults/message/C_dlb.c create mode 100644 util/ceg/defaults/message/C_dnam.c create mode 100644 util/ceg/defaults/message/C_fcon.c create mode 100644 util/ceg/defaults/message/C_icon.c create mode 100644 util/ceg/defaults/message/C_ilb.c create mode 100644 util/ceg/defaults/message/C_mes_begin.c create mode 100644 util/ceg/defaults/message/C_mes_end.c create mode 100644 util/ceg/defaults/message/C_pnam.c create mode 100644 util/ceg/defaults/message/C_scon.c create mode 100644 util/ceg/defaults/message/C_ucon.c create mode 100644 util/ceg/defaults/not_impl/not_impl.c create mode 100644 util/ceg/defaults/not_impl/not_impl_table create mode 100644 util/ceg/defaults/pseudo/C_busy.c create mode 100644 util/ceg/defaults/pseudo/C_close.c create mode 100644 util/ceg/defaults/pseudo/C_df_dlb.c create mode 100644 util/ceg/defaults/pseudo/C_df_dnam.c create mode 100644 util/ceg/defaults/pseudo/C_df_ilb.c create mode 100644 util/ceg/defaults/pseudo/C_end.c create mode 100644 util/ceg/defaults/pseudo/C_end_narg.c create mode 100644 util/ceg/defaults/pseudo/C_exa_dlb.c create mode 100644 util/ceg/defaults/pseudo/C_exa_dnam.c create mode 100644 util/ceg/defaults/pseudo/C_exp.c create mode 100644 util/ceg/defaults/pseudo/C_ina_dlb.c create mode 100644 util/ceg/defaults/pseudo/C_ina_dnam.c create mode 100644 util/ceg/defaults/pseudo/C_init.c create mode 100644 util/ceg/defaults/pseudo/C_inp.c create mode 100644 util/ceg/defaults/pseudo/C_magic.c create mode 100644 util/ceg/defaults/pseudo/C_open.c create mode 100644 util/ceg/defaults/pseudo/C_pro.c create mode 100644 util/ceg/defaults/pseudo/C_pro_narg.c create mode 100644 util/ceg/defaults/pseudo_vars.c create mode 100644 util/ceg/defaults/storage/C_bss_cst.c create mode 100644 util/ceg/defaults/storage/C_bss_dlb.c create mode 100644 util/ceg/defaults/storage/C_bss_dnam.c create mode 100644 util/ceg/defaults/storage/C_bss_ilb.c create mode 100644 util/ceg/defaults/storage/C_bss_pnam.c create mode 100644 util/ceg/defaults/storage/C_con_cst.c create mode 100644 util/ceg/defaults/storage/C_con_dlb.c create mode 100644 util/ceg/defaults/storage/C_con_dnam.c create mode 100644 util/ceg/defaults/storage/C_con_ilb.c create mode 100644 util/ceg/defaults/storage/C_con_pnam.c create mode 100644 util/ceg/defaults/storage/C_con_scon.c create mode 100644 util/ceg/defaults/storage/C_hol_cst.c create mode 100644 util/ceg/defaults/storage/C_hol_dlb.c create mode 100644 util/ceg/defaults/storage/C_hol_dnam.c create mode 100644 util/ceg/defaults/storage/C_hol_ilb.c create mode 100644 util/ceg/defaults/storage/C_hol_pnam.c create mode 100644 util/ceg/defaults/storage/C_rom_cst.c create mode 100644 util/ceg/defaults/storage/C_rom_dlb.c create mode 100644 util/ceg/defaults/storage/C_rom_dnam.c create mode 100644 util/ceg/defaults/storage/C_rom_ilb.c create mode 100644 util/ceg/defaults/storage/C_rom_pnam.c create mode 100644 util/ceg/defaults/storage/C_rom_scon.c create mode 100644 util/ceg/util/create_ofiles create mode 100644 util/ceg/util/install_ceg create mode 100644 util/ceg/util/make_as create mode 100644 util/ceg/util/make_obj create mode 100644 util/ceg/util/make_own create mode 100644 util/ceg/util/preproc create mode 100644 util/ceg/util/update diff --git a/util/ceg/ce_back/as_back/Makefile b/util/ceg/ce_back/as_back/Makefile new file mode 100644 index 000000000..1fd424135 --- /dev/null +++ b/util/ceg/ce_back/as_back/Makefile @@ -0,0 +1,93 @@ +EM=/proj/em/Work +CEG=/usr/star/kaashoek/em/ceg.1 +SOURCE=$(CEG)/ce_back/as_back + +IDIRS=-I.\ + -I..\ + -I$(EM)/h\ + -I$(EM)/modules/h + +LIBS=$(EM)/modules/lib/object.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libsystem.a + +all : bottom.o con1.o con2.o con4.o end_back.o gen1.o gen2.o\ + gen4.o init_back.o reloc1.o reloc2.o reloc4.o bss.o\ + rom1.o rom2.o rom4.o set_global.o set_local.o switchseg.o symboldef.o \ + do_open.o do_close.o text1.o text2.o text4.o + +bottom.o : ../mach.h back.h header.h $(SOURCE)/bottom.c + cc -c $(IDIRS) $(SOURCE)/bottom.c + +bss.o : ../mach.h back.h header.h $(SOURCE)/bss.c + cc -c $(IDIRS) $(SOURCE)/bss.c + +text1.o : ../mach.h back.h header.h $(SOURCE)/text1.c + cc -c $(IDIRS) $(SOURCE)/text1.c + +text2.o : ../mach.h back.h header.h $(SOURCE)/text2.c + cc -c $(IDIRS) $(SOURCE)/text2.c + +text4.o : ../mach.h back.h header.h $(SOURCE)/text4.c + cc -c $(IDIRS) $(SOURCE)/text4.c + +con1.o : ../mach.h back.h header.h $(SOURCE)/con1.c + cc -c $(IDIRS) $(SOURCE)/con1.c + +con2.o : ../mach.h back.h header.h $(SOURCE)/con2.c + cc -c $(IDIRS) $(SOURCE)/con2.c + +con4.o : ../mach.h back.h header.h $(SOURCE)/con4.c + cc -c $(IDIRS) $(SOURCE)/con4.c + +do_open.o : back.h header.h ../mach.h $(SOURCE)/do_open.c + cc -c $(IDIRS) -I.. $(SOURCE)/do_open.c + +do_close.o : back.h header.h ../mach.h $(SOURCE)/do_close.c + cc -c $(IDIRS) -I.. $(SOURCE)/do_close.c + +gen1.o : back.h header.h ../mach.h $(SOURCE)/gen1.c + cc -c $(IDIRS) $(SOURCE)/gen1.c + +gen2.o : back.h header.h ../mach.h $(SOURCE)/gen2.c + cc -c $(IDIRS) $(SOURCE)/gen2.c + +gen4.o : back.h header.h ../mach.h $(SOURCE)/gen4.c + cc -c $(IDIRS) $(SOURCE)/gen4.c + +init_back.o : header.h back.h ../mach.h $(SOURCE)/init_back.c + cc -c $(IDIRS) -I.. $(SOURCE)/init_back.c + +end_back.o : header.h back.h ../mach.h $(SOURCE)/end_back.c + cc -c $(IDIRS) -I.. $(SOURCE)/end_back.c + +reloc1.o : back.h header.h ../mach.h $(SOURCE)/reloc1.c + cc -c $(IDIRS) $(SOURCE)/reloc1.c + +reloc2.o : back.h header.h ../mach.h $(SOURCE)/reloc2.c + cc -c $(IDIRS) $(SOURCE)/reloc2.c + +reloc4.o : back.h header.h ../mach.h $(SOURCE)/reloc4.c + cc -c $(IDIRS) $(SOURCE)/reloc4.c + +rom1.o : back.h header.h ../mach.h $(SOURCE)/rom1.c + cc -c $(IDIRS) $(SOURCE)/rom1.c + +rom2.o : back.h header.h ../mach.h $(SOURCE)/rom2.c + cc -c $(IDIRS) $(SOURCE)/rom2.c + +rom4.o : back.h header.h ../mach.h $(SOURCE)/rom4.c + cc -c $(IDIRS) $(SOURCE)/rom4.c + +set_global.o : header.h back.h ../mach.h $(SOURCE)/set_global.c + cc -c $(IDIRS) -I.. $(SOURCE)/set_global.c + +set_local.o : header.h back.h ../mach.h $(SOURCE)/set_local.c + cc -c $(IDIRS) -I.. $(SOURCE)/set_local.c + +switchseg.o : header.h back.h ../mach.h $(SOURCE)/switchseg.c + cc -c $(IDIRS) -I.. $(SOURCE)/switchseg.c + +symboldef.o : header.h back.h ../mach.h $(SOURCE)/symboldef.c + cc -c $(IDIRS) -I.. $(SOURCE)/symboldef.c diff --git a/util/ceg/ce_back/as_back/back.h b/util/ceg/ce_back/as_back/back.h new file mode 100644 index 000000000..71c6df929 --- /dev/null +++ b/util/ceg/ce_back/as_back/back.h @@ -0,0 +1,18 @@ +#include +#include + +extern File *codefile; + +extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(), + *extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(); + +extern int holno, procno; + +#define swtxt() switchseg( SEGTXT) + +#define SEGTXT 0 +#define SEGROM 1 +#define SEGCON 2 +#define SEGBSS 3 + +#define ABSOLUTE 1 diff --git a/util/ceg/ce_back/as_back/bottom.c b/util/ceg/ce_back/as_back/bottom.c new file mode 100644 index 000000000..faa1f1298 --- /dev/null +++ b/util/ceg/ce_back/as_back/bottom.c @@ -0,0 +1,96 @@ +#include "mach.h" +#include "const.h" +#include "back.h" + + +int procno = 0, holno = 0, cur_seg = -1, saved = FALSE; +char name[256], labeltje[256]; + +File *codefile; + + +align_word() + +/* The EM-definition demands that segments are aligned at a word boundary + */ + +{ + switch ( cur_seg) { + case SEGTXT : return; + default : fprint( codefile, ALIGN_FMT); + } +} + + +save_label( l) +char *l; +{ + sprint( labeltje, "%s", l); + saved = TRUE; +} + + +dump_label() +{ + if ( saved) { + align_word(); + symbol_definition( labeltje); + } + saved = FALSE; +} + + +char *extnd_pro( procno) +int procno; +{ + sprint( name, "pro%d", procno); + return( name); +} + + +char *extnd_start( procno) +int procno; +{ + sprint( name, "start%d", procno); + return( name); +} + + +char *extnd_name( s) +char *s; +{ + sprint( name, NAME_FMT, s); + return( name); +} + + +char *extnd_dnam( s) +char *s; +{ + sprint( name, DNAM_FMT, s); + return( name); +} + + +char *extnd_dlb( g) +arith g; +{ + sprint( name, DLB_FMT, (arith)g); + return( name); +} + + +char *extnd_ilb( l) +arith l; +{ + sprint( name, ILB_FMT, procno, (arith) l); + return( name); +} + + +char *extnd_hol( hol) +int hol; +{ + sprint( name, HOL_FMT, hol); + return( name); +} diff --git a/util/ceg/ce_back/as_back/bss.c b/util/ceg/ce_back/as_back/bss.c new file mode 100644 index 000000000..2545fdfce --- /dev/null +++ b/util/ceg/ce_back/as_back/bss.c @@ -0,0 +1,7 @@ +#include "header.h" + +bss( n) +arith n; +{ + fprint( codefile, BSS_FMT, (arith) n); +} diff --git a/util/ceg/ce_back/as_back/con1.c b/util/ceg/ce_back/as_back/con1.c new file mode 100644 index 000000000..df74cef3d --- /dev/null +++ b/util/ceg/ce_back/as_back/con1.c @@ -0,0 +1,7 @@ +#include "header.h" + +con1( w) +arith w; +{ + gen1( w); +} diff --git a/util/ceg/ce_back/as_back/con2.c b/util/ceg/ce_back/as_back/con2.c new file mode 100644 index 000000000..258bdc40d --- /dev/null +++ b/util/ceg/ce_back/as_back/con2.c @@ -0,0 +1,7 @@ +#include "header.h" + +con2( w) +arith w; +{ + gen2( w); +} diff --git a/util/ceg/ce_back/as_back/con4.c b/util/ceg/ce_back/as_back/con4.c new file mode 100644 index 000000000..9b806b595 --- /dev/null +++ b/util/ceg/ce_back/as_back/con4.c @@ -0,0 +1,7 @@ +#include "header.h" + +con4( w) +arith w; +{ + gen4( w); +} diff --git a/util/ceg/ce_back/as_back/const.h b/util/ceg/ce_back/as_back/const.h new file mode 100644 index 000000000..0a2068341 --- /dev/null +++ b/util/ceg/ce_back/as_back/const.h @@ -0,0 +1,2 @@ +#define TRUE 1 +#define FALSE 0 diff --git a/util/ceg/ce_back/as_back/do_close.c b/util/ceg/ce_back/as_back/do_close.c new file mode 100644 index 000000000..a8121f2e1 --- /dev/null +++ b/util/ceg/ce_back/as_back/do_close.c @@ -0,0 +1,6 @@ +#include "header.h" + +do_close() +{ + sys_close( codefile); +} diff --git a/util/ceg/ce_back/as_back/do_open.c b/util/ceg/ce_back/as_back/do_open.c new file mode 100644 index 000000000..f32f0a89b --- /dev/null +++ b/util/ceg/ce_back/as_back/do_open.c @@ -0,0 +1,10 @@ +#include "header.h" + +do_open( filename) +char *filename; +{ + if ( filename == (char *) '\0') + return( FALSE); + else + return( sys_open( filename, OP_WRITE, &codefile)); +} diff --git a/util/ceg/ce_back/as_back/end_back.c b/util/ceg/ce_back/as_back/end_back.c new file mode 100644 index 000000000..5d6e4ecaa --- /dev/null +++ b/util/ceg/ce_back/as_back/end_back.c @@ -0,0 +1,5 @@ +#include "header.h" + +end_back() +{ +} diff --git a/util/ceg/ce_back/as_back/gen1.c b/util/ceg/ce_back/as_back/gen1.c new file mode 100644 index 000000000..7d766e3c4 --- /dev/null +++ b/util/ceg/ce_back/as_back/gen1.c @@ -0,0 +1,17 @@ +#include "header.h" + +gen1( w) +arith w; +{ + switch ( cur_seg) { + case SEGTXT : fprint( codefile, BYTE_FMT, (arith) w); + break; + case SEGCON : fprint( codefile, BYTE_FMT, (arith) w); + break; + case SEGROM : fprint( codefile, BYTE_FMT, (arith) w); + break; + case SEGBSS : bss( 1); + break; + default : fprint( STDERR, "gen1 unkown seg %d\n", cur_seg); + } +} diff --git a/util/ceg/ce_back/as_back/gen2.c b/util/ceg/ce_back/as_back/gen2.c new file mode 100644 index 000000000..26172f208 --- /dev/null +++ b/util/ceg/ce_back/as_back/gen2.c @@ -0,0 +1,17 @@ +#include "header.h" + +gen2( w) +arith w; +{ + switch ( cur_seg) { + case SEGTXT : fprint( codefile, WORD_FMT, (arith) w); + break; + case SEGCON : fprint( codefile, WORD_FMT, (arith) w); + break; + case SEGROM : fprint( codefile, WORD_FMT, (arith) w); + break; + case SEGBSS : bss( 2); + break; + default : fprint( STDERR, "gen2 unkown seg %d\n", cur_seg); + } +} diff --git a/util/ceg/ce_back/as_back/gen4.c b/util/ceg/ce_back/as_back/gen4.c new file mode 100644 index 000000000..6871179a5 --- /dev/null +++ b/util/ceg/ce_back/as_back/gen4.c @@ -0,0 +1,17 @@ +#include "header.h" + +gen4( w) +arith w; +{ + switch ( cur_seg) { + case SEGTXT : fprint( codefile, LONG_FMT, (arith) w); + break; + case SEGCON : fprint( codefile, LONG_FMT, (arith) w); + break; + case SEGROM : fprint( codefile, LONG_FMT, (arith) w); + break; + case SEGBSS : bss( 4); + break; + default : fprint( STDERR, "gen4 unkown seg %d\n", cur_seg); + } +} diff --git a/util/ceg/ce_back/as_back/header.h b/util/ceg/ce_back/as_back/header.h new file mode 100644 index 000000000..640f3f9d9 --- /dev/null +++ b/util/ceg/ce_back/as_back/header.h @@ -0,0 +1,7 @@ +#include "mach.h" +#include "const.h" +#include "back.h" + +extern int cur_seg; + +extern holno, procno; diff --git a/util/ceg/ce_back/as_back/init_back.c b/util/ceg/ce_back/as_back/init_back.c new file mode 100644 index 000000000..28687dbb2 --- /dev/null +++ b/util/ceg/ce_back/as_back/init_back.c @@ -0,0 +1,5 @@ +#include "header.h" + +init_back() +{ +} diff --git a/util/ceg/ce_back/as_back/reloc1.c b/util/ceg/ce_back/as_back/reloc1.c new file mode 100644 index 000000000..24557b8e9 --- /dev/null +++ b/util/ceg/ce_back/as_back/reloc1.c @@ -0,0 +1,9 @@ +#include "header.h" + +reloc1( s, o, r) +char *s; +arith o; +int r; +{ + fprint( codefile, RELOC1_FMT, s, (arith) o); +} diff --git a/util/ceg/ce_back/as_back/reloc2.c b/util/ceg/ce_back/as_back/reloc2.c new file mode 100644 index 000000000..85a4485a0 --- /dev/null +++ b/util/ceg/ce_back/as_back/reloc2.c @@ -0,0 +1,9 @@ +#include "header.h" + +reloc2( s, o, r) +char *s; +arith o; +int r; +{ + fprint( codefile, RELOC2_FMT, s, (arith) o); +} diff --git a/util/ceg/ce_back/as_back/reloc4.c b/util/ceg/ce_back/as_back/reloc4.c new file mode 100644 index 000000000..773231d37 --- /dev/null +++ b/util/ceg/ce_back/as_back/reloc4.c @@ -0,0 +1,9 @@ +#include "header.h" + +reloc4( s, o, r) +char *s; +arith o; +int r; +{ + fprint( codefile, RELOC4_FMT, s, (arith) o); +} diff --git a/util/ceg/ce_back/as_back/rom1.c b/util/ceg/ce_back/as_back/rom1.c new file mode 100644 index 000000000..dec8207fb --- /dev/null +++ b/util/ceg/ce_back/as_back/rom1.c @@ -0,0 +1,7 @@ +#include "header.h" + +rom1( w) +arith w; +{ + gen1( w); +} diff --git a/util/ceg/ce_back/as_back/rom2.c b/util/ceg/ce_back/as_back/rom2.c new file mode 100644 index 000000000..f64118610 --- /dev/null +++ b/util/ceg/ce_back/as_back/rom2.c @@ -0,0 +1,7 @@ +#include "header.h" + +rom2( w) +arith w; +{ + gen2( w); +} diff --git a/util/ceg/ce_back/as_back/rom4.c b/util/ceg/ce_back/as_back/rom4.c new file mode 100644 index 000000000..89eca333a --- /dev/null +++ b/util/ceg/ce_back/as_back/rom4.c @@ -0,0 +1,7 @@ +#include "header.h" + +rom4( w) +arith w; +{ + gen4( w); +} diff --git a/util/ceg/ce_back/as_back/set_global.c b/util/ceg/ce_back/as_back/set_global.c new file mode 100644 index 000000000..18f9c1bdc --- /dev/null +++ b/util/ceg/ce_back/as_back/set_global.c @@ -0,0 +1,7 @@ +#include "header.h" + +set_global_visible( s) +char *s; +{ + fprint( codefile, GLOBAL_FMT, s); +} diff --git a/util/ceg/ce_back/as_back/set_local.c b/util/ceg/ce_back/as_back/set_local.c new file mode 100644 index 000000000..6c3d2fd3a --- /dev/null +++ b/util/ceg/ce_back/as_back/set_local.c @@ -0,0 +1,7 @@ +#include "header.h" + +set_local_visible( s) +char *s; +{ + fprint( codefile, LOCAL_FMT, s); +} diff --git a/util/ceg/ce_back/as_back/switchseg.c b/util/ceg/ce_back/as_back/switchseg.c new file mode 100644 index 000000000..e3d7d743f --- /dev/null +++ b/util/ceg/ce_back/as_back/switchseg.c @@ -0,0 +1,25 @@ +#include "header.h" + +switchseg( seg) +int seg; +{ + if ( seg == cur_seg) + return; + + cur_seg = seg; + + switch ( cur_seg) { + case SEGTXT : fprint( codefile, SEGTXT_FMT); + break; + case SEGCON : fprint( codefile, SEGDAT_FMT); + break; + case SEGROM : fprint( codefile, SEGDAT_FMT); + break; + case SEGBSS : fprint( codefile, SEGBSS_FMT); + break; + } + + if ( seg != SEGTXT) + align_word(); +} + diff --git a/util/ceg/ce_back/as_back/symboldef.c b/util/ceg/ce_back/as_back/symboldef.c new file mode 100644 index 000000000..7b4c64440 --- /dev/null +++ b/util/ceg/ce_back/as_back/symboldef.c @@ -0,0 +1,7 @@ +#include "header.h" + +symbol_definition( s) +char *s; +{ + fprint( codefile, SYMBOL_DEF_FMT, s); +} diff --git a/util/ceg/ce_back/as_back/text1.c b/util/ceg/ce_back/as_back/text1.c new file mode 100644 index 000000000..d95be856e --- /dev/null +++ b/util/ceg/ce_back/as_back/text1.c @@ -0,0 +1,7 @@ +#include "header.h" + +text1( w) +arith w; +{ + gen1( w); +} diff --git a/util/ceg/ce_back/as_back/text2.c b/util/ceg/ce_back/as_back/text2.c new file mode 100644 index 000000000..6ec0d1c84 --- /dev/null +++ b/util/ceg/ce_back/as_back/text2.c @@ -0,0 +1,7 @@ +#include "header.h" + +text2( w) +arith w; +{ + gen2( w); +} diff --git a/util/ceg/ce_back/as_back/text4.c b/util/ceg/ce_back/as_back/text4.c new file mode 100644 index 000000000..9d033bdff --- /dev/null +++ b/util/ceg/ce_back/as_back/text4.c @@ -0,0 +1,7 @@ +#include "header.h" + +text4( w) +arith w; +{ + gen4( w); +} diff --git a/util/ceg/ce_back/obj_back/Makefile b/util/ceg/ce_back/obj_back/Makefile new file mode 100644 index 000000000..408ab241e --- /dev/null +++ b/util/ceg/ce_back/obj_back/Makefile @@ -0,0 +1,107 @@ +EM=/proj/em/Work +CEG=/usr/star/kaashoek/em/ceg.1 +SOURCE=$(CEG)/ce_back/obj_back + +IDIRS=-I.\ + -I..\ + -I$(EM)/h\ + -I$(EM)/modules/h + +LIBS=$(EM)/modules/lib/object.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libsystem.a + +all : data.o con2.o con4.o relocation.o end_back.o gen1.o gen2.o\ + gen4.o init_back.o mysprint.o output.o reloc1.o reloc2.o reloc4.o\ + rom2.o rom4.o set_global.o set_local.o switchseg.o symboldef.o text2.o\ + text4.o do_open.o do_close.o memory.o label.o misc.o extnd.o symtable.o + +data.o : data.h back.h header.h $(SOURCE)/data.c + cc -c $(IDIRS) $(SOURCE)/data.c + +memory.o :data.h back.h header.h $(SOURCE)/memory.c + cc -c $(IDIRS) $(SOURCE)/memory.c + +con2.o : data.h back.h header.h $(SOURCE)/con2.c + cc -c $(IDIRS) $(SOURCE)/con2.c + +con4.o : data.h back.h header.h $(SOURCE)/con4.c + cc -c $(IDIRS) $(SOURCE)/con4.c + +relocation.o : data.h back.h ../mach.h $(SOURCE)/relocation.c + cc -c $(IDIRS) -I.. $(SOURCE)/relocation.c + +do_open.o : data.h back.h ../mach.h $(SOURCE)/do_open.c + cc -c $(IDIRS) -I.. $(SOURCE)/do_open.c + +do_close.o : data.h back.h ../mach.h $(SOURCE)/do_close.c + cc -c $(IDIRS) -I.. $(SOURCE)/do_close.c + +gen1.o : data.h back.h header.h $(SOURCE)/gen1.c + cc -c $(IDIRS) $(SOURCE)/gen1.c + +gen2.o : data.h back.h header.h $(SOURCE)/gen2.c + cc -c $(IDIRS) $(SOURCE)/gen2.c + +gen4.o : data.h back.h header.h $(SOURCE)/gen4.c + cc -c $(IDIRS) $(SOURCE)/gen4.c + +init_back.o : data.h back.h ../mach.h $(SOURCE)/init_back.c + cc -c $(IDIRS) -I.. $(SOURCE)/init_back.c + +end_back.o : data.h back.h ../mach.h $(SOURCE)/end_back.c + cc -c $(IDIRS) -I.. $(SOURCE)/end_back.c + +mysprint.o : data.h back.h data.h $(SOURCE)/mysprint.c + cc -c $(IDIRS) $(SOURCE)/mysprint.c + +output.o : data.h back.h ../mach.h $(SOURCE)/output.c + cc -c $(IDIRS) -I.. $(SOURCE)/output.c + +reloc1.o : data.h back.h header.h $(SOURCE)/reloc1.c + cc -c $(IDIRS) $(SOURCE)/reloc1.c + +reloc2.o : data.h back.h header.h $(SOURCE)/reloc2.c + cc -c $(IDIRS) $(SOURCE)/reloc2.c + +reloc4.o : data.h back.h header.h $(SOURCE)/reloc4.c + cc -c $(IDIRS) $(SOURCE)/reloc4.c + +rom2.o : data.h back.h header.h $(SOURCE)/rom2.c + cc -c $(IDIRS) $(SOURCE)/rom2.c + +rom4.o : data.h back.h header.h $(SOURCE)/rom4.c + cc -c $(IDIRS) $(SOURCE)/rom4.c + +set_global.o : data.h back.h ../mach.h $(SOURCE)/set_global.c + cc -c $(IDIRS) -I.. $(SOURCE)/set_global.c + +set_local.o : data.h back.h ../mach.h $(SOURCE)/set_local.c + cc -c $(IDIRS) -I.. $(SOURCE)/set_local.c + +switchseg.o : data.h back.h ../mach.h $(SOURCE)/switchseg.c + cc -c $(IDIRS) -I.. $(SOURCE)/switchseg.c + +symboldef.o : data.h back.h ../mach.h $(SOURCE)/symboldef.c + cc -c $(IDIRS) -I.. $(SOURCE)/symboldef.c + +text2.o : data.h back.h ../mach.h $(SOURCE)/text2.c + cc -c $(IDIRS) -I.. $(SOURCE)/text2.c + +text4.o : data.h back.h ../mach.h $(SOURCE)/text4.c + cc -c $(IDIRS) -I.. $(SOURCE)/text4.c + +symtable.o : data.h back.h ../mach.h $(SOURCE)/symtable.c + cc -c $(IDIRS) -I.. $(SOURCE)/symtable.c + +extnd.o : data.h back.h ../mach.h $(SOURCE)/extnd.c + cc -c $(IDIRS) -I.. $(SOURCE)/extnd.c + +misc.o : data.h back.h ../mach.h $(SOURCE)/misc.c + cc -c $(IDIRS) -I.. $(SOURCE)/misc.c + +label.o : data.h back.h ../mach.h $(SOURCE)/label.c + cc -c $(IDIRS) -I.. $(SOURCE)/label.c + diff --git a/util/ceg/ce_back/obj_back/back.h b/util/ceg/ce_back/obj_back/back.h new file mode 100644 index 000000000..c19148c72 --- /dev/null +++ b/util/ceg/ce_back/obj_back/back.h @@ -0,0 +1,27 @@ +extern char *extnd_name(), *extnd_dnam(), *extnd_dlb(), *extnd_ilb(), + *extnd_hol(), *extnd_ext(), *extnd_pro(), *extnd_start(); +extern holno, procno; + +#include "data.h" + +#define text1(b) {if (text-text_area>=size_text) mem_text() ; *text++=b;} +#define con1(b) {if (data-data_area>=size_data) mem_data(); *data++ = b;} +#define rom1(b) {if (data-data_area>=size_data) mem_data(); *data++=b;} +#define bss( n) ( nbss += n) + +#define SEGTXT 0 +#define SEGROM 1 +#define SEGCON 2 +#define SEGBSS 3 + +#define swtxt() switchseg( SEGTXT) + +#define MAXTEXT 20 +#define MAXDATA 20 +#define MAXRELO 3 +#define MAXNAME 5 +#define MAXSTRING 20 +#define MAXHASH 256 + +#define PC_REL 1 +#define ABSOLUTE !PC_REL diff --git a/util/ceg/ce_back/obj_back/con2.c b/util/ceg/ce_back/obj_back/con2.c new file mode 100644 index 000000000..8e30cfc28 --- /dev/null +++ b/util/ceg/ce_back/obj_back/con2.c @@ -0,0 +1,15 @@ +#include "mach.h" +#include "back.h" + +con2( w) +TWO_BYTES w; +{ +#ifdef BYTES_REVERSED + con1( (char) ( ( unsigned short)w>>8)); + con1( (char) w); +#else + con1( (char) w); + con1( (char) ( ( unsigned short)w>>8)); +#endif +} + diff --git a/util/ceg/ce_back/obj_back/con4.c b/util/ceg/ce_back/obj_back/con4.c new file mode 100644 index 000000000..af590e679 --- /dev/null +++ b/util/ceg/ce_back/obj_back/con4.c @@ -0,0 +1,15 @@ +#include "mach.h" + +con4( l) +FOUR_BYTES l; +{ +#ifdef WORDS_REVERSED + con2( (short) ((unsigned long)l>>16)); + con2( (short) l); +#else + con2( (short) l); + con2( (short) ((unsigned long)l>>16)); +#endif +} + + diff --git a/util/ceg/ce_back/obj_back/data.c b/util/ceg/ce_back/obj_back/data.c new file mode 100644 index 000000000..edca182de --- /dev/null +++ b/util/ceg/ce_back/obj_back/data.c @@ -0,0 +1,97 @@ +#include +#include +#include "mach.h" + + +char *text_area, + *data_area, + *string_area, + *text, *data, *string; +struct outrelo *reloc_info, *relo; +struct outname *symbol_table; + + +int cur_seg = -1 , nname = 0; +long nbss = 0, size_text, size_data, size_reloc, size_symbol, + size_string; + + +put1(sect,addr,b) +char *sect; +long addr; +char b; +{ + sect[addr] = b; +} + + +put2(sect,addr,w) +char *sect; +long addr; +int w; +{ +#ifdef BYTES_REVERSED + put1(sect,addr,(char) (w>>8)); + put1(sect,addr+1,(char) w); +#else + put1(sect,addr,(char) w); + put1(sect,addr+1,(char) (w>>8)); +#endif +} + + +put4(sect,addr,l) +char *sect; +long addr; +long l; +{ +#ifdef WORDS_REVERSED + put2(sect,addr,(short) (l>>16)); + put2(sect,addr+2,(short) l); +#else + put2(sect,addr,(short) l); + put2(sect,addr+2,(short) (l>>16)); +#endif +} + + +char get1( sect, addr) +char *sect; +long addr; +{ + return( sect[addr]); +} + + +short get2(sect,addr) +char *sect; +long addr; +{ + short h,l; + +#ifdef BYTES_REVERSED + h = sect[addr]; + l = sect[addr+1]; +#else + l = sect[addr]; + h = sect[addr+1]; +#endif + return( ( h << 8) | ( l & 255)); +} + + +long get4(sect,addr) +char *sect; +long addr; +{ + long l,h; + +#ifdef WORDS_REVERSED + h = get2(sect,addr); + l = get2(sect,addr+2); +#else + l = get2(sect,addr); + h = get2(sect,addr+2); +#endif + return( ( h << 16) | ( l & 65535L)); +} diff --git a/util/ceg/ce_back/obj_back/data.h b/util/ceg/ce_back/obj_back/data.h new file mode 100644 index 000000000..abdfc1862 --- /dev/null +++ b/util/ceg/ce_back/obj_back/data.h @@ -0,0 +1,13 @@ +extern long cur_value(); + +extern int cur_seg; + +extern char *text, *data, *string; +extern int nname; +extern long nbss, size_text, size_data, size_reloc, size_symbol, + size_string; + +extern char *text_area, *data_area, *string_area; +extern struct outrelo *reloc_info, *relo; +extern struct outname *symbol_table; + diff --git a/util/ceg/ce_back/obj_back/do_close.c b/util/ceg/ce_back/obj_back/do_close.c new file mode 100644 index 000000000..b6f8eec58 --- /dev/null +++ b/util/ceg/ce_back/obj_back/do_close.c @@ -0,0 +1,10 @@ +#include +#include +#include + +do_close() +{ + output(); + + wr_close(); +} diff --git a/util/ceg/ce_back/obj_back/do_open.c b/util/ceg/ce_back/obj_back/do_open.c new file mode 100644 index 000000000..3c01988d6 --- /dev/null +++ b/util/ceg/ce_back/obj_back/do_open.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include "data.h" +#include "header.h" + +do_open( filename) +char *filename; +{ + if ( filename == (char *) '\0') + return( 0); + else + return( wr_open( filename)); +} diff --git a/util/ceg/ce_back/obj_back/end_back.c b/util/ceg/ce_back/obj_back/end_back.c new file mode 100644 index 000000000..32ab8a3f7 --- /dev/null +++ b/util/ceg/ce_back/obj_back/end_back.c @@ -0,0 +1,41 @@ +#include +#include "mach.h" +#include "back.h" +#include "header.h" + + +end_back() +{ + sync(); + define_segments(); + do_local_relocation(); +} + + +sync() +{ + while ( ( text - text_area) % EM_WSIZE != 0 ) + text1( '\0'); + while ( ( data - data_area) % EM_WSIZE != 0 ) + con1( '\0'); +} + + +static char *seg_name[] = { + ".text", + ".rom", + ".con", + ".bss" + }; + + +define_segments() +{ + int i, s; + + for ( s = SEGTXT; s <= SEGBSS; s++) { + i = find_sym( seg_name[s], SYMBOL_DEFINITION); + symbol_table[i].on_type = ( S_MIN + s) | S_SCT; + } +} + diff --git a/util/ceg/ce_back/obj_back/extnd.c b/util/ceg/ce_back/obj_back/extnd.c new file mode 100644 index 000000000..cf8f3f14b --- /dev/null +++ b/util/ceg/ce_back/obj_back/extnd.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include "header.h" +#include "mach.h" + +/* The extnd_*() make a name unique. The resulting string is directly stored + in the symbol_table (by mysprint()). Later additional fields in the + symbol_table are filled. For these actions the values of the index in + the symbol_table and the length of the string are stored. + */ + +extern int string_lengte, index_symbol_table; +int procno = 0, holno = 0; + + +char *extnd_pro( procno) +int procno; +{ + string_lengte = mysprint( "pro%d", procno); + index_symbol_table = find_sym( string, STORE_STRING); + return( symbol_table[ index_symbol_table].on_foff + string_area); +} + + +char *extnd_start( procno) +int procno; +{ + string_lengte = mysprint( "start%d", procno); + index_symbol_table = find_sym( string, STORE_STRING); + return( symbol_table[ index_symbol_table].on_foff + string_area); +} + + +char *extnd_name( s) +char *s; +{ + string_lengte = mysprint( NAME_FMT, s); + index_symbol_table = find_sym( string, STORE_STRING); + return( string_area + symbol_table[ index_symbol_table].on_foff); +} + + +char *extnd_dnam( s) +char *s; +{ + string_lengte = mysprint( DNAM_FMT, s); + index_symbol_table = find_sym( string, STORE_STRING); + return( symbol_table[ index_symbol_table].on_foff + string_area); +} + + +char *extnd_dlb( g) +arith g; +{ + string_lengte = mysprint( DLB_FMT, (arith)g); + index_symbol_table = find_sym( string, STORE_STRING); + return( symbol_table[ index_symbol_table].on_foff + string_area); +} + + +char *extnd_ilb( l) +arith l; +{ + string_lengte = mysprint( ILB_FMT, procno, (arith) l); + index_symbol_table = find_sym( string, STORE_STRING); + return( symbol_table[ index_symbol_table].on_foff + string_area); +} + + +char *extnd_hol( hol) +int hol; +{ + string_lengte = mysprint( HOL_FMT, hol); + index_symbol_table = find_sym( string, STORE_STRING); + return( symbol_table[ index_symbol_table].on_foff + string_area); +} diff --git a/util/ceg/ce_back/obj_back/gen1.c b/util/ceg/ce_back/obj_back/gen1.c new file mode 100644 index 000000000..664f9fe56 --- /dev/null +++ b/util/ceg/ce_back/obj_back/gen1.c @@ -0,0 +1,21 @@ +#include +#include "mach.h" +#include "back.h" + +gen1( c) +ONE_BYTE c; +{ + switch ( cur_seg) { + case SEGTXT : text1( c); + return; + case SEGCON : con1( c); + return; + case SEGROM : rom1( c); + return; + case SEGBSS : bss( 1); + return; + default : fprint( STDERR, "gen1() : bad seg number\n"); + return; + } +} + diff --git a/util/ceg/ce_back/obj_back/gen2.c b/util/ceg/ce_back/obj_back/gen2.c new file mode 100644 index 000000000..0664af095 --- /dev/null +++ b/util/ceg/ce_back/obj_back/gen2.c @@ -0,0 +1,15 @@ +#include "mach.h" +#include "back.h" + +gen2( w) +TWO_BYTES w; +{ +#ifdef BYTES_REVERSED + gen1( (char) ( ( unsigned short)w>>8)); + gen1( (char) w); +#else + gen1( (char) w); + gen1( (char) ( ( unsigned short)w>>8)); +#endif +} + diff --git a/util/ceg/ce_back/obj_back/gen4.c b/util/ceg/ce_back/obj_back/gen4.c new file mode 100644 index 000000000..e214934d8 --- /dev/null +++ b/util/ceg/ce_back/obj_back/gen4.c @@ -0,0 +1,14 @@ +#include "mach.h" + +gen4( l) +FOUR_BYTES l; +{ +#ifdef WORDS_REVERSED + gen2( (short) ((unsigned long)l>>16)); + gen2( (short) l); +#else + gen2( (short) l); + gen2( (short) ((unsigned long)l>>16)); +#endif +} + diff --git a/util/ceg/ce_back/obj_back/hash.h b/util/ceg/ce_back/obj_back/hash.h new file mode 100644 index 000000000..52b6ff592 --- /dev/null +++ b/util/ceg/ce_back/obj_back/hash.h @@ -0,0 +1,6 @@ +struct Hashitem { + int hs_next; + int hs_nami; +}; + +extern struct Hashitem *Hashitems; diff --git a/util/ceg/ce_back/obj_back/header.h b/util/ceg/ce_back/obj_back/header.h new file mode 100644 index 000000000..fdc9be34f --- /dev/null +++ b/util/ceg/ce_back/obj_back/header.h @@ -0,0 +1,5 @@ +#define SYMBOL_DEFINITION 1 +#define REFERENCE 2 +#define STORE_STRING 3 + +#define conv_seg( s) ( ( s == SEGROM) ? SEGCON : s) diff --git a/util/ceg/ce_back/obj_back/init_back.c b/util/ceg/ce_back/obj_back/init_back.c new file mode 100644 index 000000000..58bd911e8 --- /dev/null +++ b/util/ceg/ce_back/obj_back/init_back.c @@ -0,0 +1,27 @@ +#include +#include "back.h" +#include "hash.h" + +char *calloc(); + +init_back() +{ + text_area = calloc( MAXTEXT, sizeof( char)); + data_area = calloc( MAXDATA, sizeof( char)); + reloc_info = (struct outrelo *)calloc( MAXRELO, SZ_RELO); + symbol_table = (struct outname *)calloc( MAXNAME, SZ_NAME); + Hashitems = (struct Hashitem *)calloc( MAXNAME + 1, + sizeof( struct Hashitem)); + string_area = calloc( MAXSTRING, sizeof( char)); + + text = text_area; + data = data_area; + string = string_area; + relo = reloc_info; + + size_text = MAXTEXT; + size_data = MAXDATA; + size_reloc = MAXRELO; + size_symbol = MAXNAME; + size_string = MAXSTRING; +} diff --git a/util/ceg/ce_back/obj_back/label.c b/util/ceg/ce_back/obj_back/label.c new file mode 100644 index 000000000..8f5d96c20 --- /dev/null +++ b/util/ceg/ce_back/obj_back/label.c @@ -0,0 +1,24 @@ +#include +#include "header.h" +#include "back.h" + +int Label, label_waiting; + +save_label( lab) +char *lab; +{ + Label = find_sym( lab, SYMBOL_DEFINITION); + label_waiting = 1; +} + + +dump_label() +{ + if ( label_waiting) { + align_word(); + symbol_table[ Label].on_valu = cur_value(); + symbol_table[ Label].on_type |= ( S_MIN + conv_seg( cur_seg)); + label_waiting = 0; + } +} + diff --git a/util/ceg/ce_back/obj_back/memory.c b/util/ceg/ce_back/obj_back/memory.c new file mode 100644 index 000000000..36aff065b --- /dev/null +++ b/util/ceg/ce_back/obj_back/memory.c @@ -0,0 +1,64 @@ +#include +#include +#include "data.h" +#include "hash.h" + +char *realloc(); + +mem_text() +{ + /* print( "text_area too small %d %d \n", text_area, text); */ + + text_area = realloc( text_area, sizeof( char) * 2 * size_text); + text = text_area + size_text; + size_text = 2 * size_text; +} + + +mem_data() +{ + /* print( "data_area too small\n"); */ + + data_area = realloc( data_area, sizeof( char) * 2 * size_data); + data = data_area + size_data; + size_data = 2 * size_data; +} + + +mem_symbol_hash() +{ + /* print( "symbol_table out of memory\n"); */ + + size_symbol = 2 * size_symbol; + symbol_table = (struct outname *) realloc( (char *) symbol_table, + sizeof( struct outname) * size_symbol); + + /* print( "hash out of memory\n"); */ + + Hashitems = (struct Hashitem *) realloc( (char *) Hashitems, + sizeof( struct Hashitem)*(size_symbol+1)); +} + + +mem_relo() +{ + /* print( "reloc_table out of memory\n"); */ + + reloc_info = (struct outrelo *) realloc( (char *) reloc_info, + sizeof( struct outrelo) * 2 * size_reloc); + relo = reloc_info + size_reloc; + size_reloc = 2 * size_reloc; +} + + +mem_string() +{ + int i; + + /* print( "string_area out of memory %d %d \n", string_area, string);*/ + + i = string - string_area; + size_string = 2 * size_string; + string_area = realloc( string_area, sizeof( char) * size_string); + string = string_area + i; +} diff --git a/util/ceg/ce_back/obj_back/misc.c b/util/ceg/ce_back/obj_back/misc.c new file mode 100644 index 000000000..bd6463447 --- /dev/null +++ b/util/ceg/ce_back/obj_back/misc.c @@ -0,0 +1,39 @@ +#include +#include "mach.h" +#include "back.h" + +/* The following functions are called from reloc1(), reloc2(), reloc4(), + dump_label(). + */ + +align_word() +{ + switch ( cur_seg) { + case SEGTXT : return; + case SEGCON : while ( (data - data_area) % EM_WSIZE != 0) + con1( '\0'); + return; + case SEGROM : while ( (data - data_area) % EM_WSIZE != 0) + rom1( '\0'); + return; + case SEGBSS : while ( nbss % EM_WSIZE != 0) + nbss++; + return; + default : fprint( STDERR, "align_word() : unknown seg\n"); + return; + } +} + + +long cur_value() +{ + switch( cur_seg) { + case SEGTXT: return text - text_area; + case SEGCON: return data - data_area; + case SEGROM: return data - data_area; + case SEGBSS: return nbss; + default : fprint( STDERR, "cur_value() : unknown seg\n"); + return -1L; + } +} + diff --git a/util/ceg/ce_back/obj_back/mysprint.c b/util/ceg/ce_back/obj_back/mysprint.c new file mode 100644 index 000000000..d2d53bf70 --- /dev/null +++ b/util/ceg/ce_back/obj_back/mysprint.c @@ -0,0 +1,122 @@ +#include +#include "data.h" + +int mysprint( fmt, args) + char *fmt; + int args; +{ + return( _myformat( fmt, &args)); +} + +char *long2str(); + +static int integral(c) +{ + switch (c) { + case 'b': + return -2; + case 'd': + return 10; + case 'o': + return -8; + case 'u': + return -10; + case 'x': + return -16; + } + return 0; +} + +int _myformat( fmt, argp) + char *fmt; + char *argp; +{ + register char *pf = fmt, *pa = argp; + register char *pb = string; + int n = 0; + + while (*pf) { + if (*pf == '%') { + register width, base, pad, npad, s_l; + char *arg; + char cbuf[2]; + char *badformat = ""; + + /* get padder */ + if (*++pf == '0') { + pad = '0'; + ++pf; + } + else + pad = ' '; + + /* get width */ + width = 0; + while (*pf >= '0' && *pf <= '9') + width = 10 * width + *pf++ - '0'; + + /* get text and move pa */ + if (*pf == 's') { + arg = *(char **)pa; + pa += sizeof(char *); + } + else + if (*pf == 'c') { + cbuf[0] = * (int *) pa; + cbuf[1] = '\0'; + pa += sizeof(int); + arg = &cbuf[0]; + } + else + if (*pf == 'l') { + /* alignment ??? */ + if (base = integral(*++pf)) { + arg = long2str(*(long *)pa, base); + pa += sizeof(long); + } + else { + pf--; + arg = badformat; + } + } + else + if (base = integral(*pf)) { + arg = long2str((long)*(int *)pa, base); + pa += sizeof(int); + } + else + if (*pf == '%') + arg = "%"; + else + arg = badformat; + + s_l = strlen( arg); + npad = width - s_l; + if ( npad > 0) + s_l += npad; + + if ( n + s_l + string - string_area >= size_string) { + mem_string(); + pb = string + n; + } + + while (npad-- > 0) + *pb++ = pad; + + while (*pb++ = *arg++); + n += s_l; + + pb--; + pf++; + } + else { + if ( n + ( string - string_area) >= size_string) { + mem_string(); + pb = string + n; + } + n++; + *pb++ = *pf++; + } + } + return n ; +} diff --git a/util/ceg/ce_back/obj_back/output.c b/util/ceg/ce_back/obj_back/output.c new file mode 100644 index 000000000..5a576d3fa --- /dev/null +++ b/util/ceg/ce_back/obj_back/output.c @@ -0,0 +1,89 @@ +#include +#include +#include "data.h" + +output() +/* Notice : entries in the symbol_table are converted. + */ + +{ + struct outhead header; + struct outsect sect; + long ntext = text - text_area, + ndata = data - data_area, + nchar = string - string_area; + int nrelo = relo - reloc_info; + + header.oh_magic = O_MAGIC; + header.oh_flags = HF_LINK; + header.oh_nsect = 4; + header.oh_nrelo = nrelo; + header.oh_nname = nname; + header.oh_nemit = ntext + ndata; + header.oh_nchar = nchar; + + wr_ohead( &header); + + sect.os_base = 20; + sect.os_size = ntext; + sect.os_foff = OFF_EMIT( header); + sect.os_flen = ntext; + sect.os_lign = 1; + + wr_sect( §, 1); + + sect.os_base = 20 + ntext; + sect.os_size = 0; + sect.os_foff = OFF_EMIT( header) + ntext; + sect.os_flen = 0; + sect.os_lign = 1; + + wr_sect( §, 1); + + sect.os_base = 20 + ntext; + sect.os_size = ndata; + sect.os_foff = OFF_EMIT( header) + ntext; + sect.os_flen = ndata; + sect.os_lign = 1; + + wr_sect( §, 1); + + sect.os_base = 20 + ntext + ndata; + sect.os_size = nbss; + sect.os_foff = OFF_EMIT( header) + ntext + ndata; + sect.os_flen = 0; + sect.os_lign = 1; + + wr_sect( §, 1); + + wr_outsect( 0); + wr_emit( text_area, ntext); + wr_outsect( 2); + wr_emit( data_area, ndata); + + wr_relo( reloc_info, nrelo); + + convert_outname( &header); + wr_name( symbol_table, nname); + + wr_string( string_area, nchar); +} + +wr_fatal() +{ + fprint( STDERR, "write failed\n"); + abort(); +} + + +convert_outname( header) +struct outhead *header; +{ + int i; + + for ( i=0; i < nname; i++) { + symbol_table[ i].on_foff += OFF_CHAR( *header); + } +} + + diff --git a/util/ceg/ce_back/obj_back/reloc1.c b/util/ceg/ce_back/obj_back/reloc1.c new file mode 100644 index 000000000..624fc0a01 --- /dev/null +++ b/util/ceg/ce_back/obj_back/reloc1.c @@ -0,0 +1,29 @@ +#include +#include +#include "mach.h" +#include "back.h" +#include "header.h" + +reloc1( sym, off, pcrel) +char *sym; +arith off; +int pcrel; +{ + if ( relo - reloc_info >= size_reloc) + mem_relo(); + + relo->or_type = RELO1; +#ifdef BYTES_REVERSED /* Nog optimaliseren?? */ + relo->or_type |= RELBR; +#endif +#ifdef WORDS_REVERSED + relo->or_type |= RELWR; +#endif + relo->or_type |= ( pcrel) ? RELPC : S_UND; + relo->or_sect = S_MIN + conv_seg( cur_seg); + relo->or_nami = find_sym(sym, REFERENCE); + relo->or_addr = cur_value(); + gen1( (pcrel) ? off - ( cur_value() + 1) : off); + + relo++; +} diff --git a/util/ceg/ce_back/obj_back/reloc2.c b/util/ceg/ce_back/obj_back/reloc2.c new file mode 100644 index 000000000..d2b338d4d --- /dev/null +++ b/util/ceg/ce_back/obj_back/reloc2.c @@ -0,0 +1,29 @@ +#include +#include +#include "mach.h" +#include "back.h" +#include "header.h" + +reloc2( sym, off, pcrel) +char *sym; +arith off; +int pcrel; +{ + if ( relo - reloc_info >= size_reloc) + mem_relo(); + + relo->or_type = RELO2; +#ifdef BYTES_REVERSED /* Nog optimaliseren?? */ + relo->or_type |= RELBR; +#endif +#ifdef WORDS_REVERSED + relo->or_type |= RELWR; +#endif + relo->or_type |= ( pcrel) ? RELPC : S_UND; + relo->or_sect = S_MIN + conv_seg( cur_seg); + relo->or_nami = find_sym(sym, REFERENCE); + relo->or_addr = cur_value(); + gen2( (pcrel) ? off - ( cur_value() + 2) : off); + + relo++; +} diff --git a/util/ceg/ce_back/obj_back/reloc4.c b/util/ceg/ce_back/obj_back/reloc4.c new file mode 100644 index 000000000..4022e2c18 --- /dev/null +++ b/util/ceg/ce_back/obj_back/reloc4.c @@ -0,0 +1,35 @@ +#include +#include +#include +#include "mach.h" +#include "back.h" +#include "header.h" + +reloc4( sym, off, pcrel) +char *sym; +arith off; +int pcrel; +{ + if ( relo - reloc_info >= size_reloc) + mem_relo(); + + relo->or_type = RELO4; +#ifdef BYTES_REVERSED /* Nog optimaliseren?? */ + relo->or_type |= RELBR; +#endif +#ifdef WORDS_REVERSED + relo->or_type |= RELWR; +#endif + relo->or_type |= ( pcrel) ? RELPC : S_UND; + relo->or_sect = S_MIN + conv_seg( cur_seg); + relo->or_nami = find_sym(sym, REFERENCE); + relo->or_addr = cur_value(); + gen4( (pcrel) ? off - ( cur_value() + 4) : off); + + /* print( "r %s r %ld s %d in %d adrr %ld off %ld\n", + sym, pcrel, cur_seg, relo->or_nami, relo->or_addr, + (pcrel) ? off-cur_value() : off); + */ + + relo++; +} diff --git a/util/ceg/ce_back/obj_back/relocation.c b/util/ceg/ce_back/obj_back/relocation.c new file mode 100644 index 000000000..cb0e8aac9 --- /dev/null +++ b/util/ceg/ce_back/obj_back/relocation.c @@ -0,0 +1,91 @@ +#include +#include +#include "back.h" + +#define seg_index( s) ( nname - SEGBSS - 1 + s) + +long get4(); +long base_adres(); +extern short get2(); +extern char get1(); + + +do_local_relocation() +{ + register struct outrelo *ptr; + register int s; + + for ( ptr = reloc_info; ptr < relo; ptr++) { + s = ptr->or_nami; + if ( symbol_table[ s].on_valu != -1) + do_relo(&symbol_table[ s], ptr); + } +} + + +do_relo(np,rp) +struct outname *np; +struct outrelo *rp; +{ + long oldval,newval; + char *sect; + + switch( rp->or_sect - S_MIN) { + case SEGTXT: + sect = text_area; + break; + case SEGCON: + sect = data_area; + break; + default: + fprint( STDERR, + "do_local_relo(): bad section %d\n", + rp->or_sect - S_MIN); + break; + } + + /* nu reloceren tov het segment waar het symbool in voorkomt! */ + if ( rp->or_type & RELO4) { + oldval = get4( sect, rp->or_addr); + newval = oldval + np->on_valu; + put4( sect, rp->or_addr, newval); + + rp->or_nami = seg_index( + ( symbol_table[ rp->or_nami].on_type & S_TYP) - S_MIN); + } + else if ( rp->or_type & RELO2) { + oldval = (long) get2( sect, rp->or_addr); + newval = oldval + np->on_valu; + put2( sect, rp->or_addr, (int) newval); + + rp->or_nami = seg_index( + ( symbol_table[ rp->or_nami].on_type & S_TYP) - S_MIN); + } + else if ( rp->or_type & RELO1) { + oldval = (long) get1( sect, rp->or_addr); + newval = oldval + np->on_valu; + put1( sect, rp->or_addr, (char) newval); + + rp->or_nami = seg_index( + ( symbol_table[ rp->or_nami].on_type & S_TYP) - S_MIN); + } + else + print( STDERR, "do_relo() : bad relocation size\n"); + /* print( + "reloc %s adrr=%ld sect=%ld oldval=%ld newval=%ld def = %ld\n", + np->on_foff+string_area, rp->or_addr, rp->or_sect-S_MIN, oldval, newval, np->on_valu); + */ + +} + + +long base_adres( seg) +int seg; +{ + switch ( seg) { + case SEGTXT : return( 0); + case SEGCON : return( text-text_area); + case SEGBSS : return( text-text_area + data-data_area); + default : fprint( STDERR, "base_adres() wrong seg %d\n", seg); + } +} diff --git a/util/ceg/ce_back/obj_back/rom2.c b/util/ceg/ce_back/obj_back/rom2.c new file mode 100644 index 000000000..4d227f906 --- /dev/null +++ b/util/ceg/ce_back/obj_back/rom2.c @@ -0,0 +1,16 @@ +#include "mach.h" +#include "back.h" + +rom2( w) +TWO_BYTES w; +{ +#ifdef BYTES_REVERSED + rom1( (char) ( ( unsigned short)w>>8)); + rom1( (char) w); +#else + rom1( (char) w); + rom1( (char) ( ( unsigned short)w>>8)); +#endif +} + + diff --git a/util/ceg/ce_back/obj_back/rom4.c b/util/ceg/ce_back/obj_back/rom4.c new file mode 100644 index 000000000..1a6150b1a --- /dev/null +++ b/util/ceg/ce_back/obj_back/rom4.c @@ -0,0 +1,15 @@ +#include "mach.h" + +rom4( l) +FOUR_BYTES l; +{ +#ifdef WORDS_REVERSED + rom2( (short) ((unsigned long)l>>16)); + rom2( (short) l); +#else + rom2( (short) l); + rom2( (short) ((unsigned long)l>>16)); +#endif +} + + diff --git a/util/ceg/ce_back/obj_back/set_global.c b/util/ceg/ce_back/obj_back/set_global.c new file mode 100644 index 000000000..82809c10c --- /dev/null +++ b/util/ceg/ce_back/obj_back/set_global.c @@ -0,0 +1,14 @@ +#include +#include "data.h" +#include "header.h" + +set_global_visible(sym) +char *sym; +{ + int i; + + i = find_sym(sym, REFERENCE); + symbol_table[i].on_type |= S_EXT; +} + + diff --git a/util/ceg/ce_back/obj_back/set_local.c b/util/ceg/ce_back/obj_back/set_local.c new file mode 100644 index 000000000..841fa764f --- /dev/null +++ b/util/ceg/ce_back/obj_back/set_local.c @@ -0,0 +1,14 @@ +#include +#include "data.h" +#include "header.h" + +set_local_visible(sym) +char *sym; +{ + int i; + + i = find_sym(sym, REFERENCE); + symbol_table[i].on_type &= (~S_EXT); +} + + diff --git a/util/ceg/ce_back/obj_back/switchseg.c b/util/ceg/ce_back/obj_back/switchseg.c new file mode 100644 index 000000000..4b8312086 --- /dev/null +++ b/util/ceg/ce_back/obj_back/switchseg.c @@ -0,0 +1,14 @@ +#include "data.h" + +switchseg( seg) +int seg; + +/* De EM definitie eist dat pseudoinstructies gealigned worden op + * woordgrens. + */ +{ + if ( seg == cur_seg) + return; + cur_seg = seg; + align_word(); +} diff --git a/util/ceg/ce_back/obj_back/symboldef.c b/util/ceg/ce_back/obj_back/symboldef.c new file mode 100644 index 000000000..6dfb7451e --- /dev/null +++ b/util/ceg/ce_back/obj_back/symboldef.c @@ -0,0 +1,18 @@ +#include +#include +#include "data.h" +#include "back.h" +#include "header.h" + +symbol_definition(sym) +char *sym; +{ + int i; + + i = find_sym( sym, SYMBOL_DEFINITION); + (symbol_table + i)->on_valu = cur_value(); + (symbol_table + i)->on_type |= (S_MIN + conv_seg( cur_seg)); + /* print( "s %s in %d seg %d addr %ld\n", sym , i, conv_seg( cur_seg), + cur_value()); */ +} + diff --git a/util/ceg/ce_back/obj_back/symtable.c b/util/ceg/ce_back/obj_back/symtable.c new file mode 100644 index 000000000..83f031266 --- /dev/null +++ b/util/ceg/ce_back/obj_back/symtable.c @@ -0,0 +1,99 @@ +#include +#include +#include "hash.h" +#include "header.h" +#include "back.h" + + +int string_lengte = 0, + index_symbol_table = -1; + +struct Hashitem *Hashitems ; +int Hashtab[ MAXHASH]; + + +int find_sym( sym, isdef) +char *sym; +int isdef; +{ + register char *p; + register struct outname *s; + register struct Hashitem *ip; + register int h; + + if ( index_symbol_table != -1 ) { + s = symbol_table + index_symbol_table; + if ( sym == s->on_foff + string_area) { + if ( (s->on_valu == -2) && ( isdef == REFERENCE)) { + s->on_type = S_EXT; + s->on_valu = -1; + } + return( index_symbol_table); + } + } + + h = Hash(sym); + for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems; + ip = (ip->hs_next) + Hashitems) { + s = symbol_table + ip->hs_nami; + if (strcmp(sym, (s->on_foff) + string_area) == 0) { + if ( (s->on_valu == -2) && (isdef == REFERENCE)) { + s->on_type = S_EXT; + s->on_valu = -1; + } + return ip->hs_nami; + } + } + + if ( nname >= size_symbol) + mem_symbol_hash(); + + s = symbol_table + nname; + ip = Hashitems + nname + 1; /* skip the first entry */ + + if (isdef == REFERENCE) { + s->on_type = S_EXT; + s->on_valu = -1; + } + if (isdef == STORE_STRING) { + s->on_type = S_UND; + s->on_valu = -2; + } + + ip->hs_nami = nname; + ip->hs_next = Hashtab[h]; + Hashtab[h] = ip - Hashitems; + + if ( sym == string) + string += string_lengte; + else { /* zie C_fil, C_lin, C_lni */ + string_lengte = 0; + for( p=sym; *p != '\0' ; p++) { + if ( (string - string_area) >= size_string) + mem_string(); + *string++ = *p; + string_lengte++; + } + } + if ( (string - string_area) >= size_string) + mem_string(); + *string++ = '\0'; + s->on_foff = string - (string_lengte + 1) - string_area; + + return nname++; +} + + +int Hash(sym) +char *sym; +{ + register unsigned h; + register c; + + h = 0; + while (c = *sym++) { + h <<= 2; + h += c; + } + return (h % MAXHASH); +} diff --git a/util/ceg/ce_back/obj_back/text2.c b/util/ceg/ce_back/obj_back/text2.c new file mode 100644 index 000000000..58c580ef2 --- /dev/null +++ b/util/ceg/ce_back/obj_back/text2.c @@ -0,0 +1,15 @@ +#include "mach.h" +#include "back.h" + +text2( w) +TWO_BYTES w; +{ +#ifdef BYTES_REVERSED + text1( (char) ( ( unsigned short)w>>8)); + text1( (char) w); +#else + text1( (char) w); + text1( (char) ( ( unsigned short)w>>8)); +#endif +} + diff --git a/util/ceg/defaults/message/C_cst.c b/util/ceg/defaults/message/C_cst.c new file mode 100644 index 000000000..f6cc082f3 --- /dev/null +++ b/util/ceg/defaults/message/C_cst.c @@ -0,0 +1,6 @@ +#include + +C_cst( l) +arith l; +{ +} diff --git a/util/ceg/defaults/message/C_dlb.c b/util/ceg/defaults/message/C_dlb.c new file mode 100644 index 000000000..69c135754 --- /dev/null +++ b/util/ceg/defaults/message/C_dlb.c @@ -0,0 +1,7 @@ +#include + +C_dlb( l, val) +label l; +char *val; +{ +} diff --git a/util/ceg/defaults/message/C_dnam.c b/util/ceg/defaults/message/C_dnam.c new file mode 100644 index 000000000..e98c1ee71 --- /dev/null +++ b/util/ceg/defaults/message/C_dnam.c @@ -0,0 +1,7 @@ +#include + +C_dnam( str, val) +char *str; +arith val; +{ +} diff --git a/util/ceg/defaults/message/C_fcon.c b/util/ceg/defaults/message/C_fcon.c new file mode 100644 index 000000000..17a923552 --- /dev/null +++ b/util/ceg/defaults/message/C_fcon.c @@ -0,0 +1,7 @@ +#include + +C_fcon( val, siz) +char *val; +arith siz; +{ +} diff --git a/util/ceg/defaults/message/C_icon.c b/util/ceg/defaults/message/C_icon.c new file mode 100644 index 000000000..1f7c6f2b3 --- /dev/null +++ b/util/ceg/defaults/message/C_icon.c @@ -0,0 +1,7 @@ +#include + +C_icon( val, siz) +char *val; +arith siz; +{ +} diff --git a/util/ceg/defaults/message/C_ilb.c b/util/ceg/defaults/message/C_ilb.c new file mode 100644 index 000000000..32415de44 --- /dev/null +++ b/util/ceg/defaults/message/C_ilb.c @@ -0,0 +1,6 @@ +#include + +C_ilb( l) +label l; +{ +} diff --git a/util/ceg/defaults/message/C_mes_begin.c b/util/ceg/defaults/message/C_mes_begin.c new file mode 100644 index 000000000..0f2696cac --- /dev/null +++ b/util/ceg/defaults/message/C_mes_begin.c @@ -0,0 +1,6 @@ +#include + +C_mes_begin( ms) +int ms; +{ +} diff --git a/util/ceg/defaults/message/C_mes_end.c b/util/ceg/defaults/message/C_mes_end.c new file mode 100644 index 000000000..2dec7eb23 --- /dev/null +++ b/util/ceg/defaults/message/C_mes_end.c @@ -0,0 +1,5 @@ +#include + +C_mes_end() +{ +} diff --git a/util/ceg/defaults/message/C_pnam.c b/util/ceg/defaults/message/C_pnam.c new file mode 100644 index 000000000..d007929dd --- /dev/null +++ b/util/ceg/defaults/message/C_pnam.c @@ -0,0 +1,6 @@ +#include + +C_pnam( str) +char *str; +{ +} diff --git a/util/ceg/defaults/message/C_scon.c b/util/ceg/defaults/message/C_scon.c new file mode 100644 index 000000000..21e9ae6b9 --- /dev/null +++ b/util/ceg/defaults/message/C_scon.c @@ -0,0 +1,7 @@ +#include + +C_scon( str, siz) +char *str; +arith siz; +{ +} diff --git a/util/ceg/defaults/message/C_ucon.c b/util/ceg/defaults/message/C_ucon.c new file mode 100644 index 000000000..5acd2223e --- /dev/null +++ b/util/ceg/defaults/message/C_ucon.c @@ -0,0 +1,7 @@ +#include + +C_ucon( val, siz) +char *val; +arith siz; +{ +} diff --git a/util/ceg/defaults/not_impl/not_impl.c b/util/ceg/defaults/not_impl/not_impl.c new file mode 100644 index 000000000..593e546ec --- /dev/null +++ b/util/ceg/defaults/not_impl/not_impl.c @@ -0,0 +1,7 @@ +#include + +not_implemented( instr) +char *instr; +{ + fprint( STDERR, "!! %s, NOT implemented !!\n", instr); +} diff --git a/util/ceg/defaults/not_impl/not_impl_table b/util/ceg/defaults/not_impl/not_impl_table new file mode 100644 index 000000000..6c3a91a13 --- /dev/null +++ b/util/ceg/defaults/not_impl/not_impl_table @@ -0,0 +1,268 @@ +C_loc ::= not_implemented( "C_loc"). +C_ldc ::= not_implemented( "C_ldc"). +C_loc ::= not_implemented( "C_loc"). +C_ldc ::= not_implemented( "C_ldc"). +C_lol ::= not_implemented( "C_lol"). +C_loe ::= not_implemented( "C_loe"). +C_loe_dnam ::= not_implemented( "C_loe_dnam"). +C_loe_dlb ::= not_implemented( "C_loe_dlb"). +C_lil ::= not_implemented( "C_lil"). +C_lof ::= not_implemented( "C_lof"). +C_lal ::= not_implemented( "C_lal"). +C_lae ::= not_implemented( "C_lae"). +C_lae_dnam ::= not_implemented( "C_lae_dnam"). +C_lae_dlb ::= not_implemented( "C_lae_dlb"). +C_lxl ::= not_implemented( "C_lxl"). +C_lxa ::= not_implemented( "C_lxa"). +C_loi ::= not_implemented( "C_loi"). +C_los ::= not_implemented( "C_los"). +C_los_narg ::= not_implemented( "C_los_narg"). +C_ldl ::= not_implemented( "C_ldl"). +C_lde ::= not_implemented( "C_lde"). +C_lde_dnam ::= not_implemented( "C_lde_dnam"). +C_lde_dlb ::= not_implemented( "C_lde_dlb"). +C_ldf ::= not_implemented( "C_ldf"). +C_lpi ::= not_implemented( "C_lpi"). +C_inn ::= not_implemented( "C_inn"). +C_inn_narg ::= not_implemented( "C_inn_narg"). +C_set ::= not_implemented( "C_set"). +C_set_narg ::= not_implemented( "C_set_narg"). +C_lar ::= not_implemented( "C_lar"). +C_lar_narg ::= not_implemented( "C_lar_narg"). +C_sar ::= not_implemented( "C_sar"). +C_sar_narg ::= not_implemented( "C_sar_narg"). +C_aar ::= not_implemented( "C_aar"). +C_aar_narg ::= not_implemented( "C_aar_narg"). +C_cmi ::= not_implemented( "C_cmi"). +C_cmi_narg ::= not_implemented( "C_cmi_narg"). +C_cmf ::= not_implemented( "C_cmf"). +C_cmf_narg ::= not_implemented( "C_cmf_narg"). +C_cmu ::= not_implemented( "C_cmu"). +C_cmu_narg ::= not_implemented( "C_cmu_narg"). +C_cms ::= not_implemented( "C_cms"). +C_cms_narg ::= not_implemented( "C_cms_narg"). +C_cmp ::= not_implemented( "C_cmp"). +C_tlt ::= not_implemented( "C_tlt"). +C_tle ::= not_implemented( "C_tle"). +C_teq ::= not_implemented( "C_teq"). +C_tne ::= not_implemented( "C_tne"). +C_tge ::= not_implemented( "C_tge"). +C_tgt ::= not_implemented( "C_tgt"). +C_bra ::= not_implemented( "C_bra"). +C_blt ::= not_implemented( "C_blt"). +C_ble ::= not_implemented( "C_ble"). +C_beq ::= not_implemented( "C_beq"). +C_bne ::= not_implemented( "C_bne"). +C_bge ::= not_implemented( "C_bge"). +C_bgt ::= not_implemented( "C_bgt"). +C_zlt ::= not_implemented( "C_zlt"). +C_zle ::= not_implemented( "C_zle"). +C_zeq ::= not_implemented( "C_zeq"). +C_zne ::= not_implemented( "C_zne"). +C_zge ::= not_implemented( "C_zge"). +C_zgt ::= not_implemented( "C_zgt"). +C_cai ::= not_implemented( "C_cai"). +C_cal ::= not_implemented( "C_cal"). +C_lfr ::= not_implemented( "C_lfr"). +C_ret ::= not_implemented( "C_ret"). +C_asp ::= not_implemented( "C_asp"). +C_ass ::= not_implemented( "C_ass"). +C_ass_narg ::= not_implemented( "C_ass_narg"). +C_blm ::= not_implemented( "C_blm"). +C_bls ::= not_implemented( "C_bls"). +C_bls_narg ::= not_implemented( "C_bls_narg"). +C_csa ::= not_implemented( "C_csa"). +C_csa_narg ::= not_implemented( "C_csa_narg"). +C_csb ::= not_implemented( "C_csb"). +C_csb_narg ::= not_implemented( "C_csb_narg"). +C_dch ::= not_implemented( "C_dch"). +C_dup ::= not_implemented( "C_dup"). +C_dus ::= not_implemented( "C_dus"). +C_dus_narg ::= not_implemented( "C_dus_narg"). +C_exg ::= not_implemented( "C_exg"). +C_exg_narg ::= not_implemented( "C_exg_narg"). +C_fil ::= not_implemented( "C_fil"). +C_fil_dnam ::= not_implemented( "C_fil_dnam"). +C_fil_dlb ::= not_implemented( "C_fil_dlb"). +C_gto ::= not_implemented( "C_gto"). +C_gto_dnam ::= not_implemented( "C_gto_dnam"). +C_gto_dlb ::= not_implemented( "C_gto_dlb"). +C_lim ::= not_implemented( "C_lim"). +C_lin ::= not_implemented( "C_lin"). +C_lni ::= not_implemented( "C_lni"). +C_lor ::= not_implemented( "C_lor"). +C_lpb ::= not_implemented( "C_lpb"). +C_mon ::= not_implemented( "C_mon"). +C_nop ::= not_implemented( "C_nop"). +C_rck ::= not_implemented( "C_rck"). +C_rck_narg ::= not_implemented( "C_rck_narg"). +C_rtt ::= not_implemented( "C_rtt"). +C_sig ::= not_implemented( "C_sig"). +C_sim ::= not_implemented( "C_sim"). +C_str ::= not_implemented( "C_str"). +C_trp ::= not_implemented( "C_trp"). +C_stl ::= not_implemented( "C_stl"). +C_ste ::= not_implemented( "C_ste"). +C_ste_dnam ::= not_implemented( "C_ste_dnam"). +C_ste_dlb ::= not_implemented( "C_ste_dlb"). +C_sil ::= not_implemented( "C_sil"). +C_stf ::= not_implemented( "C_stf"). +C_sti ::= not_implemented( "C_sti"). +C_sts ::= not_implemented( "C_sts"). +C_sts_narg ::= not_implemented( "C_sts_narg"). +C_sdl ::= not_implemented( "C_sdl"). +C_sde ::= not_implemented( "C_sde"). +C_sde_dnam ::= not_implemented( "C_sde_dnam"). +C_sde_dlb ::= not_implemented( "C_sde_dlb"). +C_sdf ::= not_implemented( "C_sdf"). +C_adi ::= not_implemented( "C_adi"). +C_adi_narg ::= not_implemented( "C_adi_narg"). +C_sbi ::= not_implemented( "C_sbi"). +C_sbi_narg ::= not_implemented( "C_sbi_narg"). +C_mli ::= not_implemented( "C_mli"). +C_mli_narg ::= not_implemented( "C_mli_narg"). +C_dvi ::= not_implemented( "C_dvi"). +C_dvi_narg ::= not_implemented( "C_dvi_narg"). +C_rmi ::= not_implemented( "C_rmi"). +C_rmi_narg ::= not_implemented( "C_rmi_narg"). +C_ngi ::= not_implemented( "C_ngi"). +C_ngi_narg ::= not_implemented( "C_ngi_narg"). +C_sli ::= not_implemented( "C_sli"). +C_sli_narg ::= not_implemented( "C_sli_narg"). +C_sri ::= not_implemented( "C_sri"). +C_sri_narg ::= not_implemented( "C_sri_narg"). +C_adu ::= not_implemented( "C_adu"). +C_adu_narg ::= not_implemented( "C_adu_narg"). +C_sbu ::= not_implemented( "C_sbu"). +C_sbu_narg ::= not_implemented( "C_sbu_narg"). +C_mlu ::= not_implemented( "C_mlu"). +C_mlu_narg ::= not_implemented( "C_mlu_narg"). +C_dvu ::= not_implemented( "C_dvu"). +C_dvu_narg ::= not_implemented( "C_dvu_narg"). +C_rmu ::= not_implemented( "C_rmu"). +C_rmu_narg ::= not_implemented( "C_rmu_narg"). +C_slu ::= not_implemented( "C_slu"). +C_slu_narg ::= not_implemented( "C_slu_narg"). +C_sru ::= not_implemented( "C_sru"). +C_sru_narg ::= not_implemented( "C_sru_narg"). +C_adf ::= not_implemented( "C_adf"). +C_adf_narg ::= not_implemented( "C_adf_narg"). +C_sbf ::= not_implemented( "C_sbf"). +C_sbf_narg ::= not_implemented( "C_sbf_narg"). +C_mlf ::= not_implemented( "C_mlf"). +C_mlf_narg ::= not_implemented( "C_mlf_narg"). +C_dvf ::= not_implemented( "C_dvf"). +C_dvf_narg ::= not_implemented( "C_dvf_narg"). +C_ngf ::= not_implemented( "C_ngf"). +C_ngf_narg ::= not_implemented( "C_ngf_narg"). +C_fif ::= not_implemented( "C_fif"). +C_fif_narg ::= not_implemented( "C_fif_narg"). +C_fef ::= not_implemented( "C_fef"). +C_fef_narg ::= not_implemented( "C_fef_narg"). +C_adp ::= not_implemented( "C_adp"). +C_ads ::= not_implemented( "C_ads"). +C_ads_narg ::= not_implemented( "C_ads_narg"). +C_sbs ::= not_implemented( "C_sbs"). +C_sbs_narg ::= not_implemented( "C_sbs_narg"). +C_inc ::= not_implemented( "C_inc"). +C_inl ::= not_implemented( "C_inl"). +C_ine ::= not_implemented( "C_ine"). +C_ine_dnam ::= not_implemented( "C_ine_dnam"). +C_ine_dlb ::= not_implemented( "C_ine_dlb"). +C_dec ::= not_implemented( "C_dec"). +C_del ::= not_implemented( "C_del"). +C_dee ::= not_implemented( "C_dee"). +C_dee_dnam ::= not_implemented( "C_dee_dnam"). +C_dee_dlb ::= not_implemented( "C_dee_dlb"). +C_zrl ::= not_implemented( "C_zrl"). +C_zre ::= not_implemented( "C_zre"). +C_zre_dnam ::= not_implemented( "C_zre_dnam"). +C_zre_dlb ::= not_implemented( "C_zre_dlb"). +C_zrf ::= not_implemented( "C_zrf"). +C_zrf_narg ::= not_implemented( "C_zrf_narg"). +C_zer ::= not_implemented( "C_zer"). +C_zer_narg ::= not_implemented( "C_zer_narg"). +C_cii ::= not_implemented( "C_cii"). +C_cui ::= not_implemented( "C_cui"). +C_cfi ::= not_implemented( "C_cfi"). +C_cif ::= not_implemented( "C_cif"). +C_cuf ::= not_implemented( "C_cuf"). +C_cff ::= not_implemented( "C_cff"). +C_ciu ::= not_implemented( "C_ciu"). +C_cuu ::= not_implemented( "C_cuu"). +C_cfu ::= not_implemented( "C_cfu"). +C_and ::= not_implemented( "C_and"). +C_and_narg ::= not_implemented( "C_and_narg"). +C_ior ::= not_implemented( "C_ior"). +C_ior_narg ::= not_implemented( "C_ior_narg"). +C_xor ::= not_implemented( "C_xor"). +C_xor_narg ::= not_implemented( "C_xor_narg"). +C_com ::= not_implemented( "C_com"). +C_com_narg ::= not_implemented( "C_com_narg"). +C_rol ::= not_implemented( "C_rol"). +C_rol_narg ::= not_implemented( "C_rol_narg"). +C_ror ::= not_implemented( "C_ror"). +C_ror_narg ::= not_implemented( "C_ror_narg"). +C_init ::= not_implemented( "C_init"). +C_open ::= not_implemented( "C_open"). +C_close ::= not_implemented( "C_close"). +C_magic ::= not_implemented( "C_magic"). +C_df_dlb ::= not_implemented( "C_df_dlb"). +C_df_dnam ::= not_implemented( "C_df_dnam"). +C_df_ilb ::= not_implemented( "C_df_ilb"). +C_pro ::= not_implemented( "C_pro"). +C_pro_narg ::= not_implemented( "C_pro_narg"). +C_end ::= not_implemented( "C_end"). +C_end_narg ::= not_implemented( "C_end_narg"). +C_exa_dlb ::= not_implemented( "C_exa_dlb"). +C_exa_dnam ::= not_implemented( "C_exa_dnam"). +C_exp ::= not_implemented( "C_exp"). +C_ina_dlb ::= not_implemented( "C_ina_dlb"). +C_ina_dnam ::= not_implemented( "C_ina_dnam"). +C_inp ::= not_implemented( "C_inp"). +C_con_cst ::= not_implemented( "C_con_cst"). +C_con_icon ::= not_implemented( "C_con_icon"). +C_con_ucon ::= not_implemented( "C_con_ucon"). +C_con_fcon ::= not_implemented( "C_con_fcon"). +C_con_scon ::= not_implemented( "C_con_scon"). +C_con_dnam ::= not_implemented( "C_con_dnam"). +C_con_dlb ::= not_implemented( "C_con_dlb"). +C_con_ilb ::= not_implemented( "C_con_ilb"). +C_con_pnam ::= not_implemented( "C_con_pnam"). +C_rom_cst ::= not_implemented( "C_rom_cst"). +C_rom_icon ::= not_implemented( "C_rom_icon"). +C_rom_ucon ::= not_implemented( "C_rom_ucon"). +C_rom_fcon ::= not_implemented( "C_rom_fcon"). +C_rom_scon ::= not_implemented( "C_rom_scon"). +C_rom_dnam ::= not_implemented( "C_rom_dnam"). +C_rom_dlb ::= not_implemented( "C_rom_dlb"). +C_rom_ilb ::= not_implemented( "C_rom_ilb"). +C_rom_pnam ::= not_implemented( "C_rom_pnam"). +C_bss_cst ::= not_implemented( "C_bss_cst"). +C_bss_icon ::= not_implemented( "C_bss_icon"). +C_bss_ucon ::= not_implemented( "C_bss_ucon"). +C_bss_fcon ::= not_implemented( "C_bss_fcon"). +C_bss_dnam ::= not_implemented( "C_bss_dnam"). +C_bss_dlb ::= not_implemented( "C_bss_dlb"). +C_bss_ilb ::= not_implemented( "C_bss_ilb"). +C_bss_pnam ::= not_implemented( "C_bss_pnam"). +C_hol_cst ::= not_implemented( "C_hol_cst"). +C_hol_icon ::= not_implemented( "C_hol_icon"). +C_hol_ucon ::= not_implemented( "C_hol_ucon"). +C_hol_fcon ::= not_implemented( "C_hol_fcon"). +C_hol_dnam ::= not_implemented( "C_hol_dnam"). +C_hol_dlb ::= not_implemented( "C_hol_dlb"). +C_hol_ilb ::= not_implemented( "C_hol_ilb"). +C_hol_pnam ::= not_implemented( "C_hol_pnam"). +C_cst ::= not_implemented( "C_cst"). +C_icon ::= not_implemented( "C_icon"). +C_ucon ::= not_implemented( "C_ucon"). +C_fcon ::= not_implemented( "C_fcon"). +C_scon ::= not_implemented( "C_scon"). +C_dnam ::= not_implemented( "C_dnam"). +C_dlb ::= not_implemented( "C_dlb"). +C_ilb ::= not_implemented( "C_ilb"). +C_pnam ::= not_implemented( "C_pnam"). +C_mes_begin ::= not_implemented( "C_mes_begin"). +C_mes_end ::= not_implemented( "C_mes_end"). +C_exc ::= not_implemented( "C_exc"). diff --git a/util/ceg/defaults/pseudo/C_busy.c b/util/ceg/defaults/pseudo/C_busy.c new file mode 100644 index 000000000..83f1c15fb --- /dev/null +++ b/util/ceg/defaults/pseudo/C_busy.c @@ -0,0 +1,6 @@ +extern int busy; + +int C_busy() +{ + return( busy); +} diff --git a/util/ceg/defaults/pseudo/C_close.c b/util/ceg/defaults/pseudo/C_close.c new file mode 100644 index 000000000..3b3e75128 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_close.c @@ -0,0 +1,12 @@ +#include + +extern int busy; + +C_close() +{ + assert( busy); + + end_back(); + do_close(); + busy = 0; +} diff --git a/util/ceg/defaults/pseudo/C_df_dlb.c b/util/ceg/defaults/pseudo/C_df_dlb.c new file mode 100644 index 000000000..c6b8bfbf2 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_df_dlb.c @@ -0,0 +1,13 @@ +#include +#include "back.h" + +C_df_dlb( l) +label l; + +/* Bij welk data-segment hoort dit label thuis? ROM, CON, HOL, BSS ??? + * Oplossing : Bewaar het label totdat de eerstvolgende data-instructie aange- + * roepen wordt, op dat moment het label genereren!! + */ +{ + save_label( extnd_dlb( l)); +} diff --git a/util/ceg/defaults/pseudo/C_df_dnam.c b/util/ceg/defaults/pseudo/C_df_dnam.c new file mode 100644 index 000000000..26bbb66c4 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_df_dnam.c @@ -0,0 +1,8 @@ +#include +#include "back.h" + +C_df_dnam( s) +char *s; +{ + save_label( extnd_name( s)); +} diff --git a/util/ceg/defaults/pseudo/C_df_ilb.c b/util/ceg/defaults/pseudo/C_df_ilb.c new file mode 100644 index 000000000..0df98f645 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_df_ilb.c @@ -0,0 +1,9 @@ +#include +#include "back.h" + +C_df_ilb( l) +label l; +{ + symbol_definition( extnd_ilb( l)); + set_local_visible( extnd_ilb( l)); +} diff --git a/util/ceg/defaults/pseudo/C_end.c b/util/ceg/defaults/pseudo/C_end.c new file mode 100644 index 000000000..bb6e067ed --- /dev/null +++ b/util/ceg/defaults/pseudo/C_end.c @@ -0,0 +1,21 @@ +#include +#include "back.h" + +extern int locals_created; + +C_end( l) +arith l; +{ + char *p; + + swtxt(); + + if ( !locals_created) { + p = extnd_pro( procno); + + symbol_definition( p); + set_local_visible( p); + locals( l); + jump( extnd_start( procno)); + } +} diff --git a/util/ceg/defaults/pseudo/C_end_narg.c b/util/ceg/defaults/pseudo/C_end_narg.c new file mode 100644 index 000000000..be1a6bc76 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_end_narg.c @@ -0,0 +1,8 @@ +#include + +extern int locals_created; + +C_end_narg() +{ + assert( locals_created); +} diff --git a/util/ceg/defaults/pseudo/C_exa_dlb.c b/util/ceg/defaults/pseudo/C_exa_dlb.c new file mode 100644 index 000000000..69b8834c3 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_exa_dlb.c @@ -0,0 +1,8 @@ +#include +#include "back.h" + +C_exa_dlb( l) +label l; +{ + set_global_visible( extnd_dlb( l)); +} diff --git a/util/ceg/defaults/pseudo/C_exa_dnam.c b/util/ceg/defaults/pseudo/C_exa_dnam.c new file mode 100644 index 000000000..9e4f26d9a --- /dev/null +++ b/util/ceg/defaults/pseudo/C_exa_dnam.c @@ -0,0 +1,8 @@ +#include +#include "back.h" + +C_exa_dnam( s) +char *s; +{ + set_global_visible( extnd_dnam( s)); +} diff --git a/util/ceg/defaults/pseudo/C_exp.c b/util/ceg/defaults/pseudo/C_exp.c new file mode 100644 index 000000000..b6a1814c4 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_exp.c @@ -0,0 +1,8 @@ +#include +#include "back.h" + +C_exp( s) +char *s; +{ + set_global_visible( extnd_name( s)); +} diff --git a/util/ceg/defaults/pseudo/C_ina_dlb.c b/util/ceg/defaults/pseudo/C_ina_dlb.c new file mode 100644 index 000000000..6b8aa0feb --- /dev/null +++ b/util/ceg/defaults/pseudo/C_ina_dlb.c @@ -0,0 +1,8 @@ +#include +#include "back.h" + +C_ina_dlb( l) +label l; +{ + set_local_visible( extnd_dlb( l)); +} diff --git a/util/ceg/defaults/pseudo/C_ina_dnam.c b/util/ceg/defaults/pseudo/C_ina_dnam.c new file mode 100644 index 000000000..67d454b2c --- /dev/null +++ b/util/ceg/defaults/pseudo/C_ina_dnam.c @@ -0,0 +1,8 @@ +#include +#include "back.h" + +C_ina_dnam( s) +char *s; +{ + set_local_visible( extnd_name( s)); +} diff --git a/util/ceg/defaults/pseudo/C_init.c b/util/ceg/defaults/pseudo/C_init.c new file mode 100644 index 000000000..8ba85c2d7 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_init.c @@ -0,0 +1,18 @@ +#include +#include +#include "mach.h" + +C_init( wsize, psize) +arith wsize, psize; +{ + if ( wsize != EM_WSIZE) { + fprint( STDERR, "wrong word size\n"); + exit( -1); + } + if ( psize != EM_PSIZE) { + fprint( STDERR, "wrong pointer size\n"); + exit( -1); + } + + init_back(); +} diff --git a/util/ceg/defaults/pseudo/C_inp.c b/util/ceg/defaults/pseudo/C_inp.c new file mode 100644 index 000000000..2ca0ec032 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_inp.c @@ -0,0 +1,8 @@ +#include +#include "back.h" + +C_inp( s) +char *s; +{ + set_local_visible( extnd_name( s)); +} diff --git a/util/ceg/defaults/pseudo/C_magic.c b/util/ceg/defaults/pseudo/C_magic.c new file mode 100644 index 000000000..c6034572e --- /dev/null +++ b/util/ceg/defaults/pseudo/C_magic.c @@ -0,0 +1,3 @@ +C_magic() +{ +} diff --git a/util/ceg/defaults/pseudo/C_open.c b/util/ceg/defaults/pseudo/C_open.c new file mode 100644 index 000000000..4da83367a --- /dev/null +++ b/util/ceg/defaults/pseudo/C_open.c @@ -0,0 +1,17 @@ +#include +#include + +extern int busy; + +int C_open( filename) +char *filename; +{ + assert( !busy); + + if ( !do_open( filename)) { + fprint( STDERR, "Couldn't open %s\n", filename); + return( 0) + } + else + return( 1); +} diff --git a/util/ceg/defaults/pseudo/C_pro.c b/util/ceg/defaults/pseudo/C_pro.c new file mode 100644 index 000000000..30263237c --- /dev/null +++ b/util/ceg/defaults/pseudo/C_pro.c @@ -0,0 +1,17 @@ +#include +#include "back.h" + +extern int locals_created; + +C_pro( s, l) +char *s; +arith l; +{ + swtxt(); + + symbol_definition( extnd_name( s)); + procno++; + prolog(); + locals(l); + locals_created = 1; +} diff --git a/util/ceg/defaults/pseudo/C_pro_narg.c b/util/ceg/defaults/pseudo/C_pro_narg.c new file mode 100644 index 000000000..344956352 --- /dev/null +++ b/util/ceg/defaults/pseudo/C_pro_narg.c @@ -0,0 +1,24 @@ +#include +#include "back.h" + +extern int locals_created; + +C_pro_narg( s) +char*s; + +/* Het aantal locale variabelen is nog niet bekend, maar het stack-frame moet + * nu wel gemaakt worden! Oplossing : Pas bij bij C_end() is het aantal locale + * variabelen bekend dus nu een "jump" genereren en bij C_end() prolog() aan- + * roepen en daarna terug-jump-en naar het begin van de EM-procedure. + */ +{ + swtxt(); + + symbol_definition( extnd_name( s)); + procno++; + prolog(); + locals_created = 0; + jump( extnd_pro( procno)); + symbol_definition( extnd_start( procno)); + set_local_visible( extnd_start( procno)); +} diff --git a/util/ceg/defaults/pseudo_vars.c b/util/ceg/defaults/pseudo_vars.c new file mode 100644 index 000000000..2280dbaaf --- /dev/null +++ b/util/ceg/defaults/pseudo_vars.c @@ -0,0 +1 @@ +int locals_created = 0, busy = 0; diff --git a/util/ceg/defaults/storage/C_bss_cst.c b/util/ceg/defaults/storage/C_bss_cst.c new file mode 100644 index 000000000..fab227c9e --- /dev/null +++ b/util/ceg/defaults/storage/C_bss_cst.c @@ -0,0 +1,48 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_bss_cst( n, w, i) +arith n, w; +int i; +{ + if ( i == 0 || w == BSS_INIT) { + switchseg( SEGBSS); + dump_label(); + + bss( n); + } + else { + switchseg( SEGCON); + dump_label(); + + for ( i = 0; i < n/EM_WSIZE; i++) + conEM_WSIZE( (CAST_WSIZE) w); + } +} diff --git a/util/ceg/defaults/storage/C_bss_dlb.c b/util/ceg/defaults/storage/C_bss_dlb.c new file mode 100644 index 000000000..2a8f5edb4 --- /dev/null +++ b/util/ceg/defaults/storage/C_bss_dlb.c @@ -0,0 +1,49 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_bss_dlb( n, l, offs, i) +arith n, offs; +label l; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + dump_label(); + + bss( n); + } + else { + switchseg( SEGCON); + dump_label(); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_dlb( l), offs, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_bss_dnam.c b/util/ceg/defaults/storage/C_bss_dnam.c new file mode 100644 index 000000000..dbedda866 --- /dev/null +++ b/util/ceg/defaults/storage/C_bss_dnam.c @@ -0,0 +1,49 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_bss_dnam( n, s, offs, i) +arith n, offs; +char *s; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + dump_label(); + + bss( n); + } + else { + switchseg( SEGCON); + dump_label(); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_dnam( s), offs, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_bss_ilb.c b/util/ceg/defaults/storage/C_bss_ilb.c new file mode 100644 index 000000000..ac0562c99 --- /dev/null +++ b/util/ceg/defaults/storage/C_bss_ilb.c @@ -0,0 +1,49 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_bss_ilb( n, l, i) +arith n; +label l; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + dump_label(); + + bss( n); + } + else { + switchseg( SEGCON); + dump_label(); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_ilb( l), 0, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_bss_pnam.c b/util/ceg/defaults/storage/C_bss_pnam.c new file mode 100644 index 000000000..f9edda723 --- /dev/null +++ b/util/ceg/defaults/storage/C_bss_pnam.c @@ -0,0 +1,49 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_bss_pnam( n, s, i) +arith n; +char *s; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + dump_label(); + + bss( n); + } + else { + switchseg( SEGCON); + dump_label(); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_name( s), 0, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_con_cst.c b/util/ceg/defaults/storage/C_con_cst.c new file mode 100644 index 000000000..14b1a2b7a --- /dev/null +++ b/util/ceg/defaults/storage/C_con_cst.c @@ -0,0 +1,39 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + + +C_con_cst( c) +arith c; +{ + switchseg( SEGCON); + dump_label(); + + conEM_WSIZE( (CAST_WSIZE) c); +} diff --git a/util/ceg/defaults/storage/C_con_dlb.c b/util/ceg/defaults/storage/C_con_dlb.c new file mode 100644 index 000000000..a65b30d27 --- /dev/null +++ b/util/ceg/defaults/storage/C_con_dlb.c @@ -0,0 +1,39 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_con_dlb( g, o) +label g; +arith o; +{ + switchseg( SEGCON); + dump_label(); + + relocEM_PSIZE( extnd_dlb( g), o, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_con_dnam.c b/util/ceg/defaults/storage/C_con_dnam.c new file mode 100644 index 000000000..b682111c3 --- /dev/null +++ b/util/ceg/defaults/storage/C_con_dnam.c @@ -0,0 +1,39 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_con_dnam( g, o) +char *g; +arith o; +{ + switchseg( SEGCON); + dump_label(); + + relocEM_PSIZE( extnd_name( g), o, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_con_ilb.c b/util/ceg/defaults/storage/C_con_ilb.c new file mode 100644 index 000000000..e1fef6ec2 --- /dev/null +++ b/util/ceg/defaults/storage/C_con_ilb.c @@ -0,0 +1,38 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_con_ilb( l) +label l; +{ + switchseg( SEGCON); + dump_label(); + + relocEM_PSIZE( extnd_ilb( l), 0, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_con_pnam.c b/util/ceg/defaults/storage/C_con_pnam.c new file mode 100644 index 000000000..513546336 --- /dev/null +++ b/util/ceg/defaults/storage/C_con_pnam.c @@ -0,0 +1,38 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_con_pnam( p) +char *p; +{ + switchseg( SEGCON); + dump_label(); + + relocEM_PSIZE( extnd_name( p), 0, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_con_scon.c b/util/ceg/defaults/storage/C_con_scon.c new file mode 100644 index 000000000..80b75e3c6 --- /dev/null +++ b/util/ceg/defaults/storage/C_con_scon.c @@ -0,0 +1,40 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_con_scon( s, n) +char *s; +arith n; +{ + switchseg( SEGCON); + dump_label(); + + for ( ; n-- > 0;) + con1( (ONE_BYTE) *s++); +} diff --git a/util/ceg/defaults/storage/C_hol_cst.c b/util/ceg/defaults/storage/C_hol_cst.c new file mode 100644 index 000000000..32aef24dd --- /dev/null +++ b/util/ceg/defaults/storage/C_hol_cst.c @@ -0,0 +1,50 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_hol_cst( n, w, i) +arith n, w; +int i; +{ + if ( i == 0 || w == BSS_INIT) { + switchseg( SEGBSS); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + bss( n); + } + else { + switchseg( SEGCON); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + for ( i = 0; i < n/EM_WSIZE; i++) + conEM_WSIZE( (CAST_WSIZE) w); + } +} diff --git a/util/ceg/defaults/storage/C_hol_dlb.c b/util/ceg/defaults/storage/C_hol_dlb.c new file mode 100644 index 000000000..a68b0ac1b --- /dev/null +++ b/util/ceg/defaults/storage/C_hol_dlb.c @@ -0,0 +1,51 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_hol_dlb( n, l, offs, i) +arith n, offs; +label l; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + bss( n); + } + else { + switchseg( SEGCON); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_dlb( l), offs, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_hol_dnam.c b/util/ceg/defaults/storage/C_hol_dnam.c new file mode 100644 index 000000000..05b51634b --- /dev/null +++ b/util/ceg/defaults/storage/C_hol_dnam.c @@ -0,0 +1,51 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_hol_dnam( n, s, offs, i) +arith n, offs; +char *s; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + bss( n); + } + else { + switchseg( SEGCON); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_dnam( s), offs, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_hol_ilb.c b/util/ceg/defaults/storage/C_hol_ilb.c new file mode 100644 index 000000000..69a6b71ab --- /dev/null +++ b/util/ceg/defaults/storage/C_hol_ilb.c @@ -0,0 +1,51 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_hol_ilb( n, l, i) +arith n; +label l; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + bss( n); + } + else { + switchseg( SEGCON); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_ilb( l), 0, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_hol_pnam.c b/util/ceg/defaults/storage/C_hol_pnam.c new file mode 100644 index 000000000..14ef3c257 --- /dev/null +++ b/util/ceg/defaults/storage/C_hol_pnam.c @@ -0,0 +1,51 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_hol_pnam( n, s, i) +arith n; +char *s; +int i; +{ + if ( i == 0) { + switchseg( SEGBSS); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + bss( n); + } + else { + switchseg( SEGCON); + align_word(); + symbol_definition( extnd_hol( ++holno)); + + for ( i = 0; i < n/EM_PSIZE; i++) + relocEM_PSIZE( extnd_name( s), 0, ABSOLUTE); + } +} diff --git a/util/ceg/defaults/storage/C_rom_cst.c b/util/ceg/defaults/storage/C_rom_cst.c new file mode 100644 index 000000000..f57db3589 --- /dev/null +++ b/util/ceg/defaults/storage/C_rom_cst.c @@ -0,0 +1,38 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_rom_cst( c) +arith c; +{ + switchseg( SEGROM); + dump_label(); + + romEM_WSIZE( (CAST_WSIZE) c); +} diff --git a/util/ceg/defaults/storage/C_rom_dlb.c b/util/ceg/defaults/storage/C_rom_dlb.c new file mode 100644 index 000000000..1d9a35248 --- /dev/null +++ b/util/ceg/defaults/storage/C_rom_dlb.c @@ -0,0 +1,39 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_rom_dlb( g, o) +label g; +arith o; +{ + switchseg( SEGROM); + dump_label(); + + relocEM_PSIZE( extnd_dlb( g), o, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_rom_dnam.c b/util/ceg/defaults/storage/C_rom_dnam.c new file mode 100644 index 000000000..f69b25778 --- /dev/null +++ b/util/ceg/defaults/storage/C_rom_dnam.c @@ -0,0 +1,39 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_rom_dnam( g, o) +char *g; +arith o; +{ + switchseg( SEGROM); + dump_label(); + + relocEM_PSIZE( extnd_name( g), o, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_rom_ilb.c b/util/ceg/defaults/storage/C_rom_ilb.c new file mode 100644 index 000000000..89e956176 --- /dev/null +++ b/util/ceg/defaults/storage/C_rom_ilb.c @@ -0,0 +1,38 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_rom_ilb( l) +label l; +{ + switchseg( SEGROM); + dump_label(); + + relocEM_PSIZE( extnd_ilb( l), 0, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_rom_pnam.c b/util/ceg/defaults/storage/C_rom_pnam.c new file mode 100644 index 000000000..a448e1046 --- /dev/null +++ b/util/ceg/defaults/storage/C_rom_pnam.c @@ -0,0 +1,38 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_rom_pnam( p) +char *p; +{ + switchseg( SEGROM); + dump_label(); + + relocEM_PSIZE( extnd_name( p), 0, ABSOLUTE); +} diff --git a/util/ceg/defaults/storage/C_rom_scon.c b/util/ceg/defaults/storage/C_rom_scon.c new file mode 100644 index 000000000..3c3999181 --- /dev/null +++ b/util/ceg/defaults/storage/C_rom_scon.c @@ -0,0 +1,40 @@ +#include +#include "mach.h" +#include "back.h" + +#if EM_WSIZE == 1 +#define conEM_WSIZE con1 +#define romEM_WSIZE rom1 +#define CAST_WSIZE ONE_BYTE +#endif +#if EM_WSIZE == 2 +#define conEM_WSIZE con2 +#define romEM_WSIZE rom2 +#define CAST_WSIZE TWO_BYTES +#endif +#if EM_WSIZE == 4 +#define conEM_WSIZE con4 +#define romEM_WSIZE rom4 +#define CAST_WSIZE FOUR_BYTES +#endif + +#if EM_PSIZE == 1 +#define relocEM_PSIZE reloc1 +#endif +#if EM_PSIZE == 2 +#define relocEM_PSIZE reloc2 +#endif +#if EM_PSIZE == 4 +#define relocEM_PSIZE reloc4 +#endif + +C_rom_scon( s, n) +char *s; +arith n; +{ + switchseg( SEGROM); + dump_label(); + + for ( ; n-- > 0;) + rom1( (ONE_BYTE) *s++); +} diff --git a/util/ceg/util/create_ofiles b/util/ceg/util/create_ofiles new file mode 100644 index 000000000..47d8311bb --- /dev/null +++ b/util/ceg/util/create_ofiles @@ -0,0 +1,9 @@ +for i in *.c +do + b=`basename $i .c` + if test !( -f $b.o) + then + >$b.o + touch $i + fi +done diff --git a/util/ceg/util/install_ceg b/util/ceg/util/install_ceg new file mode 100644 index 000000000..a30e7793b --- /dev/null +++ b/util/ceg/util/install_ceg @@ -0,0 +1,16 @@ +CEG=/usr/star/kaashoek/em/ceg.1 + +case $# in + 1) case $1 in + -as) cp $CEG/make_as ce_makefile;; + -obj) cp $CEG/make_obj ce_makefile;; + *) echo wrong option $1, use -as or -obj; + exit 1;; + esac;; + + 0) cp $CEG/make_own ce_makefile;; + + *) echo wrong number of arguments; + exit 1;; +esac +make -f ce_makefile install diff --git a/util/ceg/util/make_as b/util/ceg/util/make_as new file mode 100644 index 000000000..69eb9c3f2 --- /dev/null +++ b/util/ceg/util/make_as @@ -0,0 +1,70 @@ +EM = /proj/em/Work +CEG = /usr/star/kaashoek/em/ceg.1 + +Em = $(CEG)/EM_parser/as_EM_pars +ASMAIN = $(CEG)/assemble/as_assemble +BACK = $(CEG)/ce_back +AS = $(CEG)/as_parser +EVAL = $(CEG)/as_parser/eval +DEF = $(CEG)/defaults + +CC = cc + +IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back + +CEG_LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a + +.c.o : mach.h back/*h ; ( cd ce; $(CC) -c -O $(IFILES) ../$*.c) + + +install : back ceg ce + make ce.a + +ce : ceg/ceg + mkdir ce + ( cd ce; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table) + cp $(DEF)/*.c ce + cp $(DEF)/*/*.c ce + ( cd ce; $(CEG)/util/preproc ../EM_table | ../ceg/ceg -l) + ln mach.c ce/mach.c + +ceg : + mkdir ceg + cp $(ASMAIN)/* ceg + (cd ceg;$(CC) -c $(IFILES) *.c; ar r as_lib.a *.o; ranlib as_lib.a) + + +back : + mkdir back + cp $(BACK)/as_back/*h back + cp $(BACK)/as_back/Makefile back + ( cd back; make) + ar r back.a back/*o; + ranlib back.a + + + +ce.a : ce/*.o + ar r ce.a ce/*.o + ranlib ce.a + +ce/*.o : mach.h back/*.h + (cd ce;$(CC) -c -O $(IFILES) *.c) + +EM_instr : ceg/ceg mach.h back/*.h EM_table + ( cd ce; $(CEG)/util/preproc ../EM_table | ../ceg/ceg -l) + $(CEG)/util/create_ofiles + @make ce.a + + +ceg/ceg : $(Em)/em_parser ceg/as_lib.a ceg/eval_as.o + $(CC) -o ceg/ceg $(Em)/*.o ceg/eval_as.o ceg/as_lib.a $(CEG_LIBS) -ll + +ceg/eval_as.o : ceg/eval_as.c as.h $(AS)/as_parser.h $(Em)/arg_type.h + (cd ceg;$(CC) -c $(IFILES) eval_as.c) + +ceg/eval_as.c : as.c $(EVAL)/eval + $(EVAL)/eval < as.c > ceg/eval_as.c diff --git a/util/ceg/util/make_obj b/util/ceg/util/make_obj new file mode 100644 index 000000000..7ba079f70 --- /dev/null +++ b/util/ceg/util/make_obj @@ -0,0 +1,77 @@ +EM = /proj/em/Work +CEG = /usr/star/kaashoek/em/ceg.1 + +Em = $(CEG)/EM_parser/obj_EM_pars +AS = $(CEG)/as_parser +ASMAIN = $(CEG)/assemble/obj_assemble +EVAL = $(CEG)/as_parser/eval +BACK = $(CEG)/ce_back +DEF = $(CEG)/defaults + +CC = cc + +IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h -I../back + +CEG_LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a + +.c.o : mach.h back/*h ; ( cd ce; $(CC) -c -O $(IFILES) ../$*.c) + + +install : back ceg ce + make ce.a + +ce : ceg/ceg + mkdir ce + ( cd ce; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table) + cp $(DEF)/*.c ce + cp $(DEF)/*/*.c ce + ( cd ce; $(CEG)/util/preproc ../EM_table| ../ceg/ceg -l) + ln mach.c ce/mach.c + +ceg : + mkdir ceg + cp $(ASMAIN)/* ceg + (cd ceg;$(CC) -c $(IFILES) *.c; ar r as_lib.a *.o; ranlib as_lib.a) + + +back : + mkdir back + cp $(BACK)/obj_back/*h $(BACK)/obj_back/Makefile back + ( cd back; make) + ar r back.a back/*o; + ranlib back.a + + + +ce.a : ce/*.o + ar r ce.a ce/*.o + ranlib ce.a + +ce/*.o : mach.h back/*.h + (cd ce;$(CC) -c -O $(IFILES) *.c) + +EM_instr : ceg/ceg mach.h back/*.h EM_table + ( cd ce; $(CEG)/util/preproc ../EM_table| ../ceg/ceg -l) + $(CEG)/util/create_ofiles + @make ce.a + + + +ceg/ceg : $(Em)/em_parser ceg/as_lib.a ceg/as_instr.o ceg/eval_as.o + $(CC) -o ceg/ceg $(Em)/*.o ceg/as_instr.o ceg/eval_as.o ceg/as_lib.a\ + $(CEG_LIBS) -ll + +ceg/as_instr.o : as.h ceg/*h ceg/as_instr.c + (cd ceg;$(CC) -c $(IFILES) as_instr.c) + +ceg/as_instr.c : as_table $(AS)/as_parser + $(CEG)/util/preproc as_table| $(AS)/as_parser > ceg/as_instr.c + +ceg/eval_as.o : ceg/eval_as.c as.h $(AS)/as_parser.h $(Em)/arg_type.h + (cd ceg;$(CC) -c $(IFILES) eval_as.c) + +ceg/eval_as.c : as.c $(EVAL)/eval + $(EVAL)/eval < as.c > ceg/eval_as.c diff --git a/util/ceg/util/make_own b/util/ceg/util/make_own new file mode 100644 index 000000000..43fcdbce6 --- /dev/null +++ b/util/ceg/util/make_own @@ -0,0 +1,69 @@ +EM = /proj/em/Work +CEG = /usr/star/kaashoek/em/ceg + +Em = $(CEG)/EM_parser +AS = $(CEG)/as_parser +EVAL = $(CEG)/as_parser/eval +DEF = $(CEG)/defaults + +CC = cc + +IFILES = -I. -I.. -I$(AS) -I$(Em) -I$(EM)/h -I$(EM)/modules/h + +CEG_LIBS = $(EM)/modules/lib/liballoc.a\ + $(EM)/modules/lib/libprint.a\ + $(EM)/modules/lib/libstring.a\ + $(EM)/modules/lib/libsystem.a + +.c.o : mach.h back/*h ; ( cd ce; $(CC) -c -O $(IFILES) ../$*.c) + + +install : ceg ce + make ce.a + +ce : ceg/ceg + mkdir ce + ( cd ce; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table) + cp $(DEF)/*.c ce + cp $(DEF)/*/*.c ce + ( cd ce; $(CEG)/util/preproc ../EM_table| ../ceg/ceg -l) + ln mach.c ce/mach.c + +ceg : + mkdir ceg + + + +ce.a : ce/*.o + ar r ce.a ce/*.o + ranlib ce.a + +ce/*.o : mach.h + (cd ce;$(CC) -c -O $(IFILES) ../$*.c) + +EM_instr : ceg/ceg EM_table mach.h + ( cd ce; $(CEG)/util/preproc ../EM_table| ../ceg/ceg -l) + $(CEG)/util/create_ofiles + @make ce.a + + + + +ceg/ceg : $(Em)/em_parser ceg/assemble.o ceg/as_instr.o ceg/eval_as.o + $(CC) -o ceg/ceg $(Em)/*.o ceg/assemble.o ceg/as_instr.o ceg/eval_as.o\ + $(CEG_LIBS) -ll + +ceg/assemble.o : as.h ceg/assemble.c ceg/*h + (cd ceg;$(CC) -c $(IFILES) assemble.c) + +ceg/as_instr.o : as.h ceg/*h ceg/as_instr.c + (cd ceg;$(CC) -c $(IFILES) as_instr.c) + +ceg/as_instr.c : as_table $(AS)/as_parser + $(CEG)/util/preproc as_table| $(AS)/as_parser > ceg/as_instr.c + +ceg/eval_as.o : ceg/eval_as.c as.h $(AS)/as_parser.h $(Em)/arg_type.h + (cd ceg;$(CC) -c $(IFILES) eval_as.c) + +ceg/eval_as.c : as.c $(EVAL)/eval + $(EVAL)/eval < as.c > ceg/eval_as.c diff --git a/util/ceg/util/preproc b/util/ceg/util/preproc new file mode 100644 index 000000000..d00c9055f --- /dev/null +++ b/util/ceg/util/preproc @@ -0,0 +1 @@ +/lib/cpp $@ | sed "/^#/d" diff --git a/util/ceg/util/update b/util/ceg/util/update new file mode 100644 index 000000000..b70a9312e --- /dev/null +++ b/util/ceg/util/update @@ -0,0 +1,28 @@ +make -f ce_makefile ceg/ceg + +for i +do + case $i in + ALL) make -f ce_makefile EM_instr ce.a; + exit 0;; + + *.o) make -f ce_makefile ce/$i; + ar r ce.a $i;; + + *..) ( cd ce; /lib/cpp ../EM_table| sed "/^#/d"| ../ceg/ceg -c $i); + F=`basename $i ..`; + U="_dnam" + V="_dlb" + make -f ce_makefile ce/$F.o ce/$F$U.o ce/"$F$V.o"; + echo ar r ce.a ce/$F.o ce/"$F$U.o" ce/"$F$V.o"; + ar r ce.a ce/$F.o ce/$F$U.o ce/"$F$U.o";; + + *) ( cd ce; /lib/cpp ../EM_table| sed "/^#/d"| ../ceg/ceg -c $i); + make -f ce_makefile ce/$i.o; + echo ar r ce.a ce/$i.o; + ar r ce.a ce/$i.o;; + esac +done + +echo ranlib ce.a +ranlib ce.a