C_jump ==> "bra $1".
C_locals ==> "link a6, #-$1".
+
+C_db_sline ==> "jsr (___u_LiB)".
$1 == 4 ==> "clrq -(sp)".
$1 == 8 ==> "clrq -(sp)".
default ==> "subl2 ~$1, sp".
+
+C_db_sline ==> "calls ~0, ___u_LiB".
{ "str", 0, 0, 0}}
}, *C_instr_info;
-#define N_INSTR 269
+#define N_INSTR 270
struct { char *name; int class, segment;}
EM_instr[ N_INSTR ] = {
{ "C_cuf", NO_ARGS, SEGTXT},
{ "C_cui", NO_ARGS, SEGTXT},
{ "C_cuu", NO_ARGS, SEGTXT},
+ { "C_db_sline", NO_ARGS, SEGTXT},
{ "C_dch", NO_ARGS, SEGTXT},
{ "C_dec", NO_ARGS, SEGTXT},
{ "C_dee", EXTERNAL, SEGTXT},
text1.c
text2.c
text4.c
+dbsym.c
--- /dev/null
+#include "header.h"
+
+#ifndef OWN_SYMB
+B_symbstr(s, len, type, add, val, added)
+char *s, *val;
+arith added;
+{
+ if (! s) s = "";
+ fprint(codefile, ".symb \"%s\", %s+%ld, 0x%x, %d\n", s, val, (long) added, type, add);
+}
+
+B_symbcst(s, len, type, add, val)
+char *s;
+arith val;
+{
+ if (! s) s = "";
+ fprint(codefile, ".symb \"%s\", %ld, 0x%x, %d\n", s, val, type, add);
+}
+
+B_symd(s, len, type, add)
+char *s;
+{
+ if (! s) s = "";
+ fprint(codefile, ".symd \"%s\", 0x%x, %d\n", s, type, add);
+}
+#endif
reloc2.$(SUF) reloc4.$(SUF) bss.$(SUF) rom1.$(SUF) rom2.$(SUF) \
rom4.$(SUF) set_global.$(SUF) set_local.$(SUF) switchseg.$(SUF) \
symboldef.$(SUF) do_open.$(SUF) do_close.$(SUF) text1.$(SUF) \
- text2.$(SUF) text4.$(SUF)
+ text2.$(SUF) text4.$(SUF) dbsym.$(SUF)
bottom.$(SUF) : $(SRC_DIR)/mach.h back.h header.h $(SOURCE)/bottom.c
$(CC) $(CFLAGS) -c $(SOURCE)/bottom.c
symboldef.$(SUF) : header.h back.h $(SRC_DIR)/mach.h $(SOURCE)/symboldef.c
$(CC) $(CFLAGS) -c $(SOURCE)/symboldef.c
+
+dbsym.$(SUF) : header.h back.h $(SRC_DIR)/mach.h $(SOURCE)/dbsym.c
+ $(CC) $(CFLAGS) -c $(SOURCE)/dbsym.c
text2.c
text4.c
common.c
+dbsym.c
char *extnd_dlb( g)
-arith g;
+label g;
{
- string_lengte = mysprint( DLB_FMT, (arith)g);
+ string_lengte = mysprint( DLB_FMT, (long)g);
index_symbol_table = find_sym( string, STORE_STRING);
return( symbol_table[ index_symbol_table].on_foff + string_area);
}
char *extnd_ilb( l, prcno)
arith l;
{
- string_lengte = mysprint( ILB_FMT, prcno, (arith) l);
+ string_lengte = mysprint( ILB_FMT, prcno, (long) l);
index_symbol_table = find_sym( string, STORE_STRING);
return( symbol_table[ index_symbol_table].on_foff + string_area);
}
#define SYMBOL_DEFINITION 1
#define REFERENCE 2
#define STORE_STRING 3
+#define FORCE_DEF 4
#define conv_seg( s) ( ( s == SEGROM) ? SEGCON : s)
{
struct outhead header;
struct outsect sect;
- long ntext = text - text_area,
+ long ntext = text - text_area,
ndata = data - data_area,
nchar;
* After that, the string table is reduced.
*/
-#define S_NEEDED 0x8000
-#define removable(nm) (!(nm.on_type & S_NEEDED) && *(nm.on_foff+string_area) == GENLAB)
+#define S_NEEDED S_MOD
+#define removable(nm) (!(nm->on_type & (S_NEEDED|S_STB)) && *(nm->on_foff+string_area) == GENLAB)
register int *diff_index =
(int *) Malloc((unsigned)(nname + 1) * sizeof(int));
register struct outrelo *rp = reloc_info;
+ register struct outname *np;
register int i;
char *new_str;
register char *p, *q;
rp++;
}
- for (i = 0; i < nname; i++) {
+ for (i = 0, np = symbol_table; i < nname; i++, np++) {
diff_index[i] = diff_index[i-1];
- if (removable(symbol_table[i])) {
+ if (removable(np)) {
diff_index[i]++;
}
+ if ((np->on_type & S_TYP) == S_CRS) {
+ struct outname *n = &symbol_table[(int) np->on_valu];
+ if (! (n->on_type & S_COM)) {
+ np->on_type &= ~S_TYP;
+ np->on_type |= (n->on_type & S_TYP);
+ np->on_valu = n->on_valu;
+ }
+ }
}
rp = reloc_info;
for (i = 0; i < nrelo; i++) {
+ symbol_table[rp->or_nami].on_type &= ~S_NEEDED;
rp->or_nami -= diff_index[rp->or_nami];
rp++;
}
- for (i = 0; i < nname; i++) {
- register struct outname *np = &symbol_table[i];
-
- np->on_type &= ~S_NEEDED;
+ for (i = 0, np = symbol_table; i < nname; i++, np++) {
+ if ((np->on_type & S_TYP) == S_CRS) {
+ np->on_valu -= diff_index[(int) np->on_valu];
+ }
if (diff_index[i] && diff_index[i] == diff_index[i-1]) {
symbol_table[i - diff_index[i]] = *np;
}
free((char *)(diff_index-1));
new_str = q = Malloc((unsigned)(string - string_area));
- for (i = 0; i < nname; i++) {
- p = symbol_table[i].on_foff + string_area;
- symbol_table[i].on_foff = q - new_str;
+ for (i = 0, np = symbol_table; i < nname; i++, np++) {
+ p = np->on_foff + string_area;
+ np->on_foff = q - new_str;
while (*q++ = *p) p++;
}
free(string_area);
string_area = new_str;
string = q;
+ for (i = 0, np = symbol_table; i < nname; i++, np++) {
+ if ((np->on_type & S_TYP) == S_CRS) {
+ /* replace by reference to string */
+ np->on_valu = symbol_table[(int) np->on_valu].on_foff;
+ }
+ }
}
wr_fatal()
convert_outname( header)
struct outhead *header;
{
- int i;
-
- for ( i=0; i < nname; i++) {
- symbol_table[ i].on_foff += OFF_CHAR( *header);
- }
+ int i;
+ register struct outname *np;
+ register long l = OFF_CHAR(*header);
+
+ for (i = 0, np = symbol_table; i < nname; i++, np++) {
+ np->on_foff += l;
+ if ((np->on_type & S_TYP) == S_CRS) {
+ np->on_valu += l;
+ }
+ }
}
-
-
reloc1.$(SUF) reloc2.$(SUF) reloc4.$(SUF) rom2.$(SUF) rom4.$(SUF) \
set_global.$(SUF) set_local.$(SUF) switchseg.$(SUF) symboldef.$(SUF) \
text2.$(SUF) text4.$(SUF) do_open.$(SUF) do_close.$(SUF) memory.$(SUF) \
- label.$(SUF) misc.$(SUF) extnd.$(SUF) symtable.$(SUF) common.$(SUF)
+ label.$(SUF) misc.$(SUF) extnd.$(SUF) symtable.$(SUF) common.$(SUF) \
+ dbsym.$(SUF)
data.$(SUF) : data.h back.h header.h $(SOURCE)/data.c
$(CC) $(CFLAGS) -c $(SOURCE)/data.c
common.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/common.c
$(CC) $(CFLAGS) -c $(SOURCE)/common.c
+dbsym.$(SUF) : data.h back.h $(SRC_DIR)/mach.h $(SOURCE)/dbsym.c
+ $(CC) $(CFLAGS) -c $(SOURCE)/dbsym.c
register struct Hashitem *ip;
register int h;
- if ( index_symbol_table != -1 ) {
+ if (isdef != FORCE_DEF) {
+ 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)) {
}
return( index_symbol_table);
}
- }
+ }
- h = Hash(sym);
- for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems;
+ h = Hash(sym);
+ for ( ip = Hashtab[h] + Hashitems ; ip != Hashitems;
ip = (ip->hs_next) + Hashitems) {
register char *p = sym, *q;
}
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) {
+ if (isdef != FORCE_DEF) {
+ ip = Hashitems + nname + 1; /* skip the first entry */
+
+ if (isdef == REFERENCE) {
s->on_type = S_EXT;
s->on_valu = -1;
- }
- if (isdef == STORE_STRING) {
+ }
+ 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;
+ ip->hs_nami = nname;
+ ip->hs_next = Hashtab[h];
+ Hashtab[h] = ip - Hashitems;
+ }
if ( sym == string)
string += string_lengte;
do_close.c do_open.c end_back.c gen1.c gen2.c gen4.c header.h \
init_back.c reloc1.c reloc2.c reloc4.c rom1.c rom2.c rom4.c \
set_global.c set_local.c switchseg.c symboldef.c text1.c \
- text2.c text4.c
+ text2.c text4.c dbsym.c
OBJLIST = back.h con2.c con4.c data.c data.h do_close.c do_open.c \
end_back.c extnd.c gen1.c gen2.c gen4.c hash.h header.h \
init_back.c label.c memory.c misc.c output.c \
reloc1.c reloc2.c reloc4.c relocation.c rom2.c rom4.c \
set_global.c set_local.c switchseg.c symboldef.c symtable.c \
- text2.c text4.c common.c
+ text2.c text4.c common.c dbsym.c
all:
#define CODE_EXPANDER
#include <em.h>
+#include <stb.h>
+#include <em_mes.h>
+
+extern int __db_mes, __db_cst, __db_len, __db_type, __db_add;
+extern char *__db_str;
C_cst( l)
arith l;
{
+ if (__db_mes) {
+ if (! __db_cst) __db_type = l;
+ else if (__db_cst == 1) {
+ if (__db_mes == ms_std) {
+ if (__db_type == N_SLINE) {
+ C_db_sline();
+ }
+ B_symd(__db_str, __db_len, __db_type, (int) l);
+ }
+ else __db_add = l;
+ }
+ else B_symbcst(__db_str, __db_len, __db_type, __db_add, l);
+ __db_cst++;
+ }
}
#define CODE_EXPANDER
#include <em.h>
+#include "back.h"
+
+extern int __db_mes, __db_len, __db_type, __db_add;
+extern char *__db_str;
C_dlb( l, val)
label l;
-char *val;
+arith val;
{
+ if (__db_mes) {
+ B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_dlb(l), val);
+ }
}
#define CODE_EXPANDER
#include <em.h>
+#include "back.h"
+
+extern int __db_mes, __db_len, __db_type, __db_add;
+extern char *__db_str;
C_dnam( str, val)
char *str;
arith val;
{
+ if (__db_mes) {
+ B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_dnam(str), val);
+ }
}
#define CODE_EXPANDER
#include <em.h>
+#include "back.h"
+
+extern int __db_mes, __db_len, __db_type, __db_add;
+extern char *__db_str;
+
+extern int B_procno;
C_ilb( l)
label l;
{
+ if (__db_mes) {
+ B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_ilb(l, B_procno), (arith) 0);
+ }
}
#define CODE_EXPANDER
#include <em.h>
+#include <em_mes.h>
+
+int __db_mes;
+char *__db_str = 0;
+int __db_len = 0;
+int __db_cst = 0;
+int __db_type;
+int __db_add;
C_mes_begin( ms)
int ms;
{
+ __db_mes = (ms == ms_stb || ms == ms_std) ? ms : 0;
}
#define CODE_EXPANDER
#include <em.h>
+extern int __db_mes;
+extern int __db_cst;
+extern char *__db_str;
+
C_mes_end()
{
+ if (__db_mes) {
+ __db_mes = 0;
+ __db_cst = 0;
+ __db_str = 0;
+ }
}
#define CODE_EXPANDER
#include <em.h>
+#include "back.h"
+
+extern int __db_mes, __db_len, __db_type, __db_add;
+extern char *__db_str;
C_pnam( str)
char *str;
{
+ if (__db_mes) {
+ B_symbstr(__db_str, __db_len, __db_type, __db_add, extnd_name(str), (arith) 0);
+ }
}
#define CODE_EXPANDER
#include <em.h>
+extern int __db_mes;
+extern char *__db_str;
+extern int __db_len;
+
C_scon( str, siz)
char *str;
arith siz;
{
+ if (__db_mes) {
+ __db_str = str;
+ __db_len = siz;
+ }
}
C_hol_fcon ==> not_implemented( "C_hol_fcon").
C_con_fcon ==> not_implemented( "C_con_fcon").
C_exc ==> not_implemented( "C_exc").
+C_db_sline ==> .