From d039d2ce979b381262d613dba752c934436f8923 Mon Sep 17 00:00:00 2001 From: Paul Koning Date: Tue, 9 Aug 2022 10:22:24 -0400 Subject: [PATCH 01/48] Fix ^R to ignore RAD50 characters after the first three. --- parse.c | 8 +++++++- tests/test-prec.lst.ok | 12 +++++++++--- tests/test-prec.mac | 6 ++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/parse.c b/parse.c index c6c5fe2..abd7476 100644 --- a/parse.c +++ b/parse.c @@ -1249,8 +1249,14 @@ EX_TREE *parse_unary( cp += 2; /* bracketed range is an extension */ if (brackrange(cp, &start, &len, &endcp)) value = rad50(cp + start, NULL); - else + else { value = rad50(cp, &endcp); + /* It turns out that ^R allows extra characters; + * it will stop consuming input at the first + * non-RAD50 character. */ + while (ascii2rad50 (*endcp) != -1) + endcp++; + } tp = new_ex_lit(value); tp->cp = endcp; return tp; diff --git a/tests/test-prec.lst.ok b/tests/test-prec.lst.ok index ba762f2..64ff630 100644 --- a/tests/test-prec.lst.ok +++ b/tests/test-prec.lst.ok @@ -121,16 +121,22 @@ test-prec.mac:100: ***ERROR Invalid expression in .WORD 101 102 000150 000001 000002 000003 1,2,3 103 000156 000000G 000000G 000000G .1,.2,.3 - 103 + 104 + 105 ; Strange cases for ^R operator. It turns out extra RAD50 characters + 106 ; are ignored; processing starts at the next non-RAD50 character. + 107 000164 070254 .word ^rRAD50CHARACTERS ; 070254 extra characters ignored + 108 000166 000001 .word ^r A..EXTRA ; 000001 extra characters ignored + 109 000170 000002 .word ^r A..EXTRA+1 ; 000002 extra characters ignored + 109 Symbol table $ = ****** GX .1 = ****** GX .3 = ****** GX FIVE = 000005 -. 000164R 001 .2 = ****** GX A 000030R 001 NAME = ****** G +. 000172R 001 .2 = ****** GX A 000030R 001 NAME = ****** G Program sections: . ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) - 000164 001 (RW,I,LCL,REL,CON,NOSAV) + 000172 001 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-prec.mac b/tests/test-prec.mac index 5ad7462..cf26a32 100644 --- a/tests/test-prec.mac +++ b/tests/test-prec.mac @@ -101,3 +101,9 @@ $ 1,2,3 .1,.2,.3 + +; Strange cases for ^R operator. It turns out extra RAD50 characters +; are ignored; processing starts at the next non-RAD50 character. + .word ^rRAD50CHARACTERS ; 070254 extra characters ignored + .word ^r A..EXTRA ; 000001 extra characters ignored + .word ^r A..EXTRA+1 ; 000002 extra characters ignored From eeb47202866b1cb67d838a79b1c37aa75a9fe49d Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Sat, 30 Jul 2022 18:47:00 +0200 Subject: [PATCH 02/48] Cleanup trailing whitespace. --- assemble.c | 6 +++--- listing.c | 2 +- macros.h | 2 +- rept_irpc.c | 2 +- util.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/assemble.c b/assemble.c index 6d5bf59..66bde4c 100644 --- a/assemble.c +++ b/assemble.c @@ -728,7 +728,7 @@ O 75 .endc case P_MDELETE: return 1; /* TODO: or should it just be a NOP? */ - + case P_MEXIT: { STREAM *macstr; @@ -1286,7 +1286,7 @@ O 75 .endc { int i, count; unsigned *rad50; - + /* Now assemble the argument */ rad50 = assemble_rad50 (cp, 0, &count, stack); for (i = 0; i < count; i++) { @@ -1833,7 +1833,7 @@ O 75 .endc } } } - + /* Only thing left is an implied .WORD directive */ /*JH: fall through in case of illegal opcode, illegal label! */ free(label); diff --git a/listing.c b/listing.c index cd34d16..4ffb312 100644 --- a/listing.c +++ b/listing.c @@ -178,7 +178,7 @@ void report( return; /* Don't report now. */ errline = 1; - + if (str) { name = str->name; line = str->line; diff --git a/macros.h b/macros.h index 0fe966a..5af39a2 100644 --- a/macros.h +++ b/macros.h @@ -74,6 +74,6 @@ BUFFER *subst_args( int do_mcall ( char *label, STACK *stack); - + #endif diff --git a/rept_irpc.c b/rept_irpc.c index 45f2438..3459709 100644 --- a/rept_irpc.c +++ b/rept_irpc.c @@ -200,7 +200,7 @@ STREAM_VTBL irp_stream_vtbl = { static char *get_irp_sym (char *cp, char **endcp, int *islocal) { char *ret = NULL; - + cp = skipwhite(cp); if (*cp == '<') { ret = get_symbol (cp + 1, &cp, islocal); diff --git a/util.c b/util.c index 77ef628..b4aa003 100644 --- a/util.c +++ b/util.c @@ -322,7 +322,7 @@ void padto( char *defext (char *fn, const char *ext) { char *ret; - + if (strchr (fn, '.')) return fn; ret = realloc (fn, strlen (fn) + strlen (ext) + 2); From f552587ed87bc4457bad02466b37458ea0305bbf Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Tue, 9 Aug 2022 21:35:15 +0200 Subject: [PATCH 03/48] Add .packed directive. --- CHANGES | 5 +++ assemble.c | 81 ++++++++++++++++++++++++++++++++++++++++ tests/RunTests | 1 + tests/test-packed.lst.ok | 65 ++++++++++++++++++++++++++++++++ tests/test-packed.mac | 40 ++++++++++++++++++++ 5 files changed, 192 insertions(+) create mode 100644 tests/test-packed.lst.ok create mode 100644 tests/test-packed.mac diff --git a/CHANGES b/CHANGES index 0cc8d0b..404d065 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +??.??.202?: Rhialto + version 0.9wip: + - Fix ^R to ignore RAD50 characters after the first three.(Paul Koning) + - Add .packed directive. + 07.07.2022: Rhialto version 0.8: - Improve parsing of symbols, e.g. `4..` is not a symbol. diff --git a/assemble.c b/assemble.c index 66bde4c..cce1de6 100644 --- a/assemble.c +++ b/assemble.c @@ -2,6 +2,7 @@ #include +#include #include #include "assemble.h" /* my own definitions */ @@ -1296,6 +1297,86 @@ O 75 .endc } return 1; + case P_PACKED: +#define PACKED_POSITIVE 0x0C +#define PACKED_NEGATIVE 0x0D +#define PACKED_UNSIGNED 0x0F + { + int sign; /* The sign comes at the end */ + + cp = skipwhite(cp); + + if (*cp == '+') { + sign = PACKED_POSITIVE; + cp++; + } else if (*cp == '-') { + sign = PACKED_NEGATIVE; + cp++; + } else { + sign = PACKED_UNSIGNED; + } + + /* Count number of digits */ + int ndigits = 0; + for (char *tmp = cp; + isdigit((unsigned char )*tmp); + tmp++) { + ndigits++; + } + + if (ndigits > 31) { + report(stack->top, "Too many packed decimal digits\n"); + return 1; + } + + /* If the number of digits is even, + * prefix an imaginary zero. */ + int nybbles = !(ndigits % 2); + int byte = 0; + + while (isdigit((unsigned char)*cp)) { + int value = *cp - '0'; + byte = (byte << 4) + value; + nybbles++; + if ((nybbles % 2) == 0) { + store_word(stack->top, tr, 1, byte); + byte = 0; + } + cp++; + } + + /* Append the sign, making an even number of nybbles. */ + byte = (byte << 4) + sign; + store_word(stack->top, tr, 1, byte); + + /* Maybe store the number of digits into a symbol. */ + cp = skipdelim(cp); + if (!EOL(*cp)) { + int islocal; + + label = get_symbol(cp, &cp, &islocal); + + if (label == NULL) { + report(stack->top, "Bad .PACKED syntax: symbol name expected\n"); + return 0; + } + + /* Check if already defined. + * TODO: maybe add_sym() should check that? */ + SYMBOL *sym; + if ((sym = lookup_sym(label, &symbol_st)) && + (sym->flags & SYMBOLFLAG_PERMANENT)) { + report(stack->top, "Symbol '%s' already defined\n", label); + return 0; + } + add_sym(label, ndigits, SYMBOLFLAG_DEFINITION | islocal, &absolute_section, + &symbol_st); + free(label); + } + + } + return CHECK_EOL; + default: report(stack->top, "Unimplemented directive %s\n", op->label); return 0; diff --git a/tests/RunTests b/tests/RunTests index c8b554a..33b276c 100755 --- a/tests/RunTests +++ b/tests/RunTests @@ -27,6 +27,7 @@ TESTS="test-asciz \ test-mcall-file \ test-opcodes \ test-operands \ + test-packed \ test-prec \ test-psect \ test-rad50 \ diff --git a/tests/test-packed.lst.ok b/tests/test-packed.lst.ok new file mode 100644 index 0000000..949e84b --- /dev/null +++ b/tests/test-packed.lst.ok @@ -0,0 +1,65 @@ + 1 ;;;; + 2 ; + 3 ; Test the packed decimals. + 4 ; + 5 .list hex ; Not yet supported... + 6 + 7 000000 017 .packed , u0 + 8 000001 014 .packed +, p0 + 9 000002 015 .packed -, n0 + 10 + 11 000003 017 .packed 0, u0len + 12 000004 014 .packed +0, p0len + 13 000005 015 .packed -0, n0len + 14 + 15 000006 037 .packed 1, u1len + 16 000007 034 .packed +1, p1len + 17 000010 035 .packed -1, n1len + 18 + 19 000011 001 057 .packed 12, u12len + 20 000013 001 055 .packed -12, n12len + 21 000015 001 054 .packed +12, p12len + 22 + 23 000017 022 077 .packed 123, u123len + 24 000021 001 043 117 .packed 1234, u124len + 25 000024 022 064 137 .packed 12345, u125len + 26 +test-packed.mac:27: ***ERROR Symbol 'LAB' already defined + 27 000027 061 101 137 lab: .packed 31415, lab ; M error (multiply defined) +test-packed.mac:28: ***ERROR Symbol 'L2' already defined + 28 000032 057 l2:: .packed 2,l2 ; M error (multiply defined) + 29 000003 l3 = 3 + 30 000033 077 .packed 3,l3 ; redef'n ok + 31 000004 l4 == 4 + 32 000034 117 .packed 4,l4 ; redef'n ok + 33 000005 l5 =: 5 ; M error; why??? +test-packed.mac:34: ***ERROR Symbol 'L5' already defined + 34 000035 137 .packed 5,l5 ; M error + 35 + 36 000036 022 064 126 .packed 1234567890123456789012345678901 + 000041 170 220 022 + 000044 064 126 170 + 000047 220 022 064 + 000052 126 170 220 + 000055 037 + 37 ; too long: +test-packed.mac:38: ***ERROR Too many packed decimal digits + 38 .packed 12345678901234567890123456789012 + 39 + 40 .end + 40 + + +Symbol table + +. 000056R 001 LAB 000027R 001 P0 = 000000 U0LEN = 000001 U1LEN = 000001 +L2 000032RG 001 N0 = 000000 P0LEN = 000001 U123LE= 000003 +L3 = 000001 N0LEN = 000001 P12LEN= 000002 U124LE= 000004 +L4 = 000001 G N12LEN= 000002 P1LEN = 000001 U125LE= 000005 +L5 = 000005 N1LEN = 000001 U0 = 000000 U12LEN= 000002 + + +Program sections: + +. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV) + 000056 001 (RW,I,LCL,REL,CON,NOSAV) diff --git a/tests/test-packed.mac b/tests/test-packed.mac new file mode 100644 index 0000000..4dd3000 --- /dev/null +++ b/tests/test-packed.mac @@ -0,0 +1,40 @@ +;;;; +; +; Test the packed decimals. +; + .list hex ; Not yet supported... + + .packed , u0 + .packed +, p0 + .packed -, n0 + + .packed 0, u0len + .packed +0, p0len + .packed -0, n0len + + .packed 1, u1len + .packed +1, p1len + .packed -1, n1len + + .packed 12, u12len + .packed -12, n12len + .packed +12, p12len + + .packed 123, u123len + .packed 1234, u124len + .packed 12345, u125len + +lab: .packed 31415, lab ; M error (multiply defined) +l2:: .packed 2,l2 ; M error (multiply defined) +l3 = 3 + .packed 3,l3 ; redef'n ok +l4 == 4 + .packed 4,l4 ; redef'n ok +l5 =: 5 ; M error; why??? + .packed 5,l5 ; M error + + .packed 1234567890123456789012345678901 + ; too long: + .packed 12345678901234567890123456789012 + + .end From 1f0801478f56613a17222ce8f8ae3b3fe74dc2f5 Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Thu, 11 Aug 2022 21:18:33 +0200 Subject: [PATCH 04/48] Better check for bad symbol redefinitions. When adding a symbol, check if a "permanent" symbol (read: a label) is being redefined and issue an appropriate diagnostic. This makes sure that the symbols named in .narg .nchr and .ntype are checked appropriately (not just those in .packed). --- CHANGES | 1 + assemble.c | 44 +-- assemble_aux.c | 12 +- symbols.c | 628 +++++++++++++++++++------------------- symbols.h | 7 +- tests/test-asciz.lst.ok | 1 + tests/test-include.lst.ok | 1 + tests/test-packed.lst.ok | 25 +- tests/test-packed.mac | 9 + 9 files changed, 388 insertions(+), 340 deletions(-) diff --git a/CHANGES b/CHANGES index 404d065..56c26f9 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,7 @@ version 0.9wip: - Fix ^R to ignore RAD50 characters after the first three.(Paul Koning) - Add .packed directive. + - Better check for bad symbol redefinitions. 07.07.2022: Rhialto version 0.8: diff --git a/assemble.c b/assemble.c index cce1de6..0566415 100644 --- a/assemble.c +++ b/assemble.c @@ -215,7 +215,8 @@ O 75 .endc ncp++; } - sym = add_sym(label, DOT, flag, current_pc->section, &symbol_st); + sym = add_sym(label, DOT, flag, current_pc->section, &symbol_st, + stack->top); cp = ncp; if (sym == NULL) @@ -315,9 +316,11 @@ O 75 .endc /* regular symbols */ if (value->type == EX_LIT) { - sym = add_sym(label, value->data.lit, flags, &absolute_section, &symbol_st); + sym = add_sym(label, value->data.lit, flags, &absolute_section, + &symbol_st, stack->top); } else if (value->type == EX_SYM || value->type == EX_TEMP_SYM) { - sym = add_sym(label, value->data.symbol->value, flags, value->data.symbol->section, &symbol_st); + sym = add_sym(label, value->data.symbol->value, flags, + value->data.symbol->section, &symbol_st, stack->top); } else { report(stack->top, "Complex expression cannot be assigned to a symbol\n"); @@ -325,7 +328,8 @@ O 75 .endc /* This may work better in pass 2 - something in RT-11 monitor needs the symbol to apear to be defined even if I can't resolve its value. */ - sym = add_sym(label, 0, SYMBOLFLAG_UNDEFINED, &absolute_section, &symbol_st); + sym = add_sym(label, 0, SYMBOLFLAG_UNDEFINED, + &absolute_section, &symbol_st, stack->top); } else sym = NULL; } @@ -521,8 +525,8 @@ O 75 .endc mstr = (MACRO_STREAM *) str; - add_sym(label, mstr->nargs, SYMBOLFLAG_DEFINITION | islocal, &absolute_section, - &symbol_st); + add_sym(label, mstr->nargs, SYMBOLFLAG_DEFINITION | islocal, + &absolute_section, &symbol_st, stack->top); free(label); list_value(stack->top, mstr->nargs); return CHECK_EOL; @@ -544,8 +548,8 @@ O 75 .endc string = getstring(cp, &cp); - add_sym(label, strlen(string), SYMBOLFLAG_DEFINITION | islocal, &absolute_section, - &symbol_st); + add_sym(label, strlen(string), SYMBOLFLAG_DEFINITION | islocal, + &absolute_section, &symbol_st, stack->top); free(label); free(string); return CHECK_EOL; @@ -572,7 +576,8 @@ O 75 .endc return 0; } - add_sym(label, mode.type, SYMBOLFLAG_DEFINITION | islocal, &absolute_section, &symbol_st); + add_sym(label, mode.type, SYMBOLFLAG_DEFINITION | islocal, + &absolute_section, &symbol_st, stack->top); free_addr_mode(&mode); free(label); @@ -1079,7 +1084,9 @@ O 75 .endc sect->size = 0; sect->type = SECTION_USER; sections[sector++] = sect; - sectsym = add_sym(label, 0, SYMBOLFLAG_DEFINITION, sect, §ion_st); + sectsym = add_sym(label, 0, + SYMBOLFLAG_DEFINITION, sect, + §ion_st, stack->top); /* page 6-41 table 6-5 */ if (op->value == P_PSECT) { @@ -1188,8 +1195,9 @@ O 75 .endc sym->flags |= SYMBOLFLAG_GLOBAL | (op->value == P_WEAK ? SYMBOLFLAG_WEAK : 0); } else sym = add_sym(label, 0, - SYMBOLFLAG_GLOBAL | (op->value == P_WEAK ? SYMBOLFLAG_WEAK : 0), - &absolute_section, &symbol_st); + SYMBOLFLAG_GLOBAL | + (op->value == P_WEAK ? SYMBOLFLAG_WEAK : 0), + &absolute_section, &symbol_st, stack->top); free(label); cp = skipdelim(ncp); @@ -1361,16 +1369,8 @@ O 75 .endc return 0; } - /* Check if already defined. - * TODO: maybe add_sym() should check that? */ - SYMBOL *sym; - if ((sym = lookup_sym(label, &symbol_st)) && - (sym->flags & SYMBOLFLAG_PERMANENT)) { - report(stack->top, "Symbol '%s' already defined\n", label); - return 0; - } - add_sym(label, ndigits, SYMBOLFLAG_DEFINITION | islocal, &absolute_section, - &symbol_st); + add_sym(label, ndigits, SYMBOLFLAG_DEFINITION | islocal, + &absolute_section, &symbol_st, stack->top); free(label); } diff --git a/assemble_aux.c b/assemble_aux.c index b00fb3a..941df82 100644 --- a/assemble_aux.c +++ b/assemble_aux.c @@ -215,7 +215,7 @@ void implicit_gbl( /* either make the undefined symbol into an implicit global */ add_sym(value->data.symbol->label, 0, SYMBOLFLAG_GLOBAL, - &absolute_section, &implicit_st); + &absolute_section, &implicit_st, NULL); } else { /* or add it to the undefined symbol table, purely for listing purposes. @@ -224,10 +224,10 @@ void implicit_gbl( #define ADD_UNDEFINED_SYMBOLS_TO_MAIN_SYMBOL_TABLE 0 #if ADD_UNDEFINED_SYMBOLS_TO_MAIN_SYMBOL_TABLE add_sym(value->data.symbol->label, 0, SYMBOLFLAG_UNDEFINED, - &absolute_section, &symbol_st); + &absolute_section, &symbol_st, stack); #else add_sym(value->data.symbol->label, 0, SYMBOLFLAG_UNDEFINED, - &absolute_section, &undefined_st); + &absolute_section, &undefined_st, NULL); #endif } } @@ -266,7 +266,8 @@ void migrate_implicit( continue; // It's already in there. Great. } isym->flags |= SYMBOLFLAG_IMPLICIT_GLOBAL; - sym = add_sym(isym->label, isym->value, isym->flags, isym->section, &symbol_st); + sym = add_sym(isym->label, isym->value, isym->flags, isym->section, + &symbol_st, NULL); // Just one other thing - migrate the stmtno sym->stmtno = isym->stmtno; } @@ -288,7 +289,8 @@ void migrate_undefined( continue; /* It's already in there. Great. */ } isym->flags |= SYMBOLFLAG_UNDEFINED; /* Just in case */ - sym = add_sym(isym->label, isym->value, isym->flags, isym->section, &symbol_st); + sym = add_sym(isym->label, isym->value, isym->flags, isym->section, + &symbol_st, NULL); /* Just one other thing - migrate the stmtno */ sym->stmtno = isym->stmtno; } diff --git a/symbols.c b/symbols.c index afbaaee..92f784b 100644 --- a/symbols.c +++ b/symbols.c @@ -53,14 +53,14 @@ dump_sym(SYMBOL *sym) } void -check_sym_invariants(SYMBOL *sym, char *file, int line) +check_sym_invariants(SYMBOL *sym, char *file, int line, STREAM *stream) { int dump = 0; if (sym->section == &instruction_section) { /* The instructions use the flags field differently */ if ((sym->flags & ~OC_MASK) != 0) { - report(NULL, "%s %d: Instruction symbol %s has wrong flags\n", file, line, sym->label); + report(stream, "%s %d: Instruction symbol %s has wrong flags\n", file, line, sym->label); dump_sym(sym); } return; @@ -92,31 +92,31 @@ check_sym_invariants(SYMBOL *sym, char *file, int line) case SYMBOLFLAG_UNDEFINED: break; default: - report(NULL, "%s %d: Symbol %s definedness is inconsistent\n", file, line, sym->label); + report(stream, "%s %d: Symbol %s definedness is inconsistent\n", file, line, sym->label); dump++; } if ( (sym->flags & SYMBOLFLAG_IMPLICIT_GLOBAL) && !(sym->flags & SYMBOLFLAG_GLOBAL)) { - report(NULL, "%s %d: Symbol %s globalness is inconsistent\n", file, line, sym->label); + report(stream, "%s %d: Symbol %s globalness is inconsistent\n", file, line, sym->label); dump++; } if ( (sym->flags & SYMBOLFLAG_LOCAL) && (sym->flags & SYMBOLFLAG_GLOBAL)) { - report(NULL, "%s %d: Symbol %s is local and global\n", file, line, sym->label); + report(stream, "%s %d: Symbol %s is local and global\n", file, line, sym->label); dump++; } if ( (sym->flags & SYMBOLFLAG_PERMANENT) && !(sym->flags & SYMBOLFLAG_DEFINITION)) { - report(NULL, "%s %d: Symbol %s is permanent without definition\n", file, line, sym->label); + report(stream, "%s %d: Symbol %s is permanent without definition\n", file, line, sym->label); dump++; } if ( (sym->flags & SYMBOLFLAG_WEAK) && !(sym->flags & SYMBOLFLAG_GLOBAL)) { - report(NULL, "%s %d: Symbol %s weak/global is inconsistent\n", file, line, sym->label); + report(stream, "%s %d: Symbol %s weak/global is inconsistent\n", file, line, sym->label); dump++; } @@ -183,7 +183,7 @@ void free_sym( SYMBOL *sym) { if (sym->label) { - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, NULL); free(sym->label); sym->label = NULL; } @@ -200,7 +200,7 @@ void remove_sym( *symp; int hash; - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, NULL); hash = hash_name(sym->label); prevp = &table->hash[hash]; while (symp = *prevp, symp != NULL && symp != sym) @@ -226,7 +226,7 @@ SYMBOL *lookup_sym( sym = sym->next; if (sym) { - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, NULL); } return sym; } @@ -273,7 +273,7 @@ void add_table( sym->next = table->hash[hash]; table->hash[hash] = sym; - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, NULL); } /* add_sym - used throughout to add or update symbols in a symbol @@ -284,7 +284,8 @@ SYMBOL *add_sym( unsigned value, unsigned flags, SECTION *section, - SYMBOL_TABLE *table) + SYMBOL_TABLE *table, + STREAM *stream) { SYMBOL *sym; char label[SYMMAX_MAX + 1]; // big size @@ -303,19 +304,31 @@ SYMBOL *add_sym( if (sym != NULL) { // A symbol registered as "undefined" can be changed. // - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, stream); + + if (sym->flags & SYMBOLFLAG_PERMANENT) { + if (flags & SYMBOLFLAG_PERMANENT) { + if (sym->value != value || sym->section != section) { + report(stream, "Phase error: '%s'\n", label); + return NULL; + } + } else { + report(stream, "Redefining permanent symbol '%s'\n", label); + return NULL; + } + } if ((sym->flags & SYMBOLFLAG_UNDEFINED) && !(flags & SYMBOLFLAG_UNDEFINED)) { sym->flags &= ~(SYMBOLFLAG_PERMANENT | SYMBOLFLAG_UNDEFINED); } else if (!(sym->flags & SYMBOLFLAG_UNDEFINED) && (flags & SYMBOLFLAG_UNDEFINED)) { - report(NULL, "INTERNAL ERROR: Turning defined symbol '%s' into undefined\n", label); + report(stream, "INTERNAL ERROR: Turning defined symbol '%s' into undefined\n", label); return sym; } /* Check for compatible definition */ else if (sym->section == section && sym->value == value) { sym->flags |= flags; /* Merge flags quietly */ - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, stream); return sym; /* 's okay */ } @@ -324,10 +337,11 @@ SYMBOL *add_sym( sym->value = value; sym->flags |= flags; sym->section = section; - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, stream); return sym; } + report(stream, "INTERNAL ERROR: Bad symbol '%s' redefinition\n", label); return NULL; /* Bad symbol redefinition */ } @@ -347,308 +361,310 @@ SYMBOL *add_sym( void add_symbols( SECTION *current_section) { - current_pc = add_sym(".", 0, SYMBOLFLAG_DEFINITION, current_section, &symbol_st); +#define ADD_SYM(a,b,c,d,e) add_sym(a,b,c,d,e,NULL) + + current_pc = ADD_SYM(".", 0, SYMBOLFLAG_DEFINITION, current_section, &symbol_st); #define S (SYMBOLFLAG_PERMANENT | SYMBOLFLAG_DEFINITION) - reg_sym[0] = add_sym("R0", 0, S, ®ister_section, &system_st); - reg_sym[1] = add_sym("R1", 1, S, ®ister_section, &system_st); - reg_sym[2] = add_sym("R2", 2, S, ®ister_section, &system_st); - reg_sym[3] = add_sym("R3", 3, S, ®ister_section, &system_st); - reg_sym[4] = add_sym("R4", 4, S, ®ister_section, &system_st); - reg_sym[5] = add_sym("R5", 5, S, ®ister_section, &system_st); - reg_sym[6] = add_sym("SP", 6, S, ®ister_section, &system_st); - reg_sym[7] = add_sym("PC", 7, S, ®ister_section, &system_st); + reg_sym[0] = ADD_SYM("R0", 0, S, ®ister_section, &system_st); + reg_sym[1] = ADD_SYM("R1", 1, S, ®ister_section, &system_st); + reg_sym[2] = ADD_SYM("R2", 2, S, ®ister_section, &system_st); + reg_sym[3] = ADD_SYM("R3", 3, S, ®ister_section, &system_st); + reg_sym[4] = ADD_SYM("R4", 4, S, ®ister_section, &system_st); + reg_sym[5] = ADD_SYM("R5", 5, S, ®ister_section, &system_st); + reg_sym[6] = ADD_SYM("SP", 6, S, ®ister_section, &system_st); + reg_sym[7] = ADD_SYM("PC", 7, S, ®ister_section, &system_st); //JH: symbols longer than current SYMMAX will be truncated. SYMMAX=6 is minimum! - add_sym(".ASCII", P_ASCII, S, &pseudo_section, &system_st); - add_sym(".ASCIZ", P_ASCIZ, S, &pseudo_section, &system_st); - add_sym(".ASECT", P_ASECT, S, &pseudo_section, &system_st); - add_sym(".BLKB", P_BLKB, S, &pseudo_section, &system_st); - add_sym(".BLKW", P_BLKW, S, &pseudo_section, &system_st); - add_sym(".BYTE", P_BYTE, S, &pseudo_section, &system_st); - add_sym(".CSECT", P_CSECT, S, &pseudo_section, &system_st); - add_sym(".CROSS", P_CROSS, S, &pseudo_section, &system_st); - add_sym(".DSABL", P_DSABL, S, &pseudo_section, &system_st); - add_sym(".ENABL", P_ENABL, S, &pseudo_section, &system_st); - add_sym(".END", P_END, S, &pseudo_section, &system_st); - add_sym(".ENDC", P_ENDC, S, &pseudo_section, &system_st); - add_sym(".ENDM", P_ENDM, S, &pseudo_section, &system_st); - add_sym(".ENDR", P_ENDR, S, &pseudo_section, &system_st); - add_sym(".EOT", P_EOT, S, &pseudo_section, &system_st); - add_sym(".ERROR", P_ERROR, S, &pseudo_section, &system_st); - add_sym(".EVEN", P_EVEN, S, &pseudo_section, &system_st); - add_sym(".FLT2", P_FLT2, S, &pseudo_section, &system_st); - add_sym(".FLT4", P_FLT4, S, &pseudo_section, &system_st); - add_sym(".GLOBL", P_GLOBL, S, &pseudo_section, &system_st); - add_sym(".IDENT", P_IDENT, S, &pseudo_section, &system_st); - add_sym(".IF", P_IF, S, &pseudo_section, &system_st); - add_sym(".IFDF", P_IFDF, S, &pseudo_section, &system_st); - add_sym(".IFNDF", P_IFDF, S, &pseudo_section, &system_st); - add_sym(".IFF", P_IFF, S, &pseudo_section, &system_st); - add_sym(".IFT", P_IFT, S, &pseudo_section, &system_st); - add_sym(".IFTF", P_IFTF, S, &pseudo_section, &system_st); - add_sym(".IIF", P_IIF, S, &pseudo_section, &system_st); - add_sym(".INCLUDE", P_INCLUDE, S, &pseudo_section, &system_st); - add_sym(".IRP", P_IRP, S, &pseudo_section, &system_st); - add_sym(".IRPC", P_IRPC, S, &pseudo_section, &system_st); - add_sym(".LIBRARY", P_LIBRARY, S, &pseudo_section, &system_st); - add_sym(".LIMIT", P_LIMIT, S, &pseudo_section, &system_st); - add_sym(".LIST", P_LIST, S, &pseudo_section, &system_st); - add_sym(".MCALL", P_MCALL, S, &pseudo_section, &system_st); - add_sym(".MDELE", P_MDELETE, S, &pseudo_section, &system_st); - add_sym(".MEXIT", P_MEXIT, S, &pseudo_section, &system_st); - add_sym(".NARG", P_NARG, S, &pseudo_section, &system_st); - add_sym(".NCHR", P_NCHR, S, &pseudo_section, &system_st); - add_sym(".NLIST", P_NLIST, S, &pseudo_section, &system_st); - add_sym(".NOCRO", P_NOCROSS, S, &pseudo_section, &system_st); - add_sym(".NTYPE", P_NTYPE, S, &pseudo_section, &system_st); - add_sym(".ODD", P_ODD, S, &pseudo_section, &system_st); - add_sym(".PACKED", P_PACKED, S, &pseudo_section, &system_st); - add_sym(".PAGE", P_PAGE, S, &pseudo_section, &system_st); - add_sym(".PRINT", P_PRINT, S, &pseudo_section, &system_st); - add_sym(".PSECT", P_PSECT, S, &pseudo_section, &system_st); - add_sym(".RADIX", P_RADIX, S, &pseudo_section, &system_st); - add_sym(".RAD50", P_RAD50, S, &pseudo_section, &system_st); - add_sym(".REM", P_REM, S, &pseudo_section, &system_st); - add_sym(".REPT", P_REPT, S, &pseudo_section, &system_st); - add_sym(".RESTORE", P_RESTORE, S, &pseudo_section, &system_st); - add_sym(".SAVE", P_SAVE, S, &pseudo_section, &system_st); - add_sym(".SBTTL", P_SBTTL, S, &pseudo_section, &system_st); - add_sym(".TITLE", P_TITLE, S, &pseudo_section, &system_st); - add_sym(".WORD", P_WORD, S, &pseudo_section, &system_st); - add_sym(".MACRO", P_MACRO, S, &pseudo_section, &system_st); - add_sym(".WEAK", P_WEAK, S, &pseudo_section, &system_st); + ADD_SYM(".ASCII", P_ASCII, S, &pseudo_section, &system_st); + ADD_SYM(".ASCIZ", P_ASCIZ, S, &pseudo_section, &system_st); + ADD_SYM(".ASECT", P_ASECT, S, &pseudo_section, &system_st); + ADD_SYM(".BLKB", P_BLKB, S, &pseudo_section, &system_st); + ADD_SYM(".BLKW", P_BLKW, S, &pseudo_section, &system_st); + ADD_SYM(".BYTE", P_BYTE, S, &pseudo_section, &system_st); + ADD_SYM(".CSECT", P_CSECT, S, &pseudo_section, &system_st); + ADD_SYM(".CROSS", P_CROSS, S, &pseudo_section, &system_st); + ADD_SYM(".DSABL", P_DSABL, S, &pseudo_section, &system_st); + ADD_SYM(".ENABL", P_ENABL, S, &pseudo_section, &system_st); + ADD_SYM(".END", P_END, S, &pseudo_section, &system_st); + ADD_SYM(".ENDC", P_ENDC, S, &pseudo_section, &system_st); + ADD_SYM(".ENDM", P_ENDM, S, &pseudo_section, &system_st); + ADD_SYM(".ENDR", P_ENDR, S, &pseudo_section, &system_st); + ADD_SYM(".EOT", P_EOT, S, &pseudo_section, &system_st); + ADD_SYM(".ERROR", P_ERROR, S, &pseudo_section, &system_st); + ADD_SYM(".EVEN", P_EVEN, S, &pseudo_section, &system_st); + ADD_SYM(".FLT2", P_FLT2, S, &pseudo_section, &system_st); + ADD_SYM(".FLT4", P_FLT4, S, &pseudo_section, &system_st); + ADD_SYM(".GLOBL", P_GLOBL, S, &pseudo_section, &system_st); + ADD_SYM(".IDENT", P_IDENT, S, &pseudo_section, &system_st); + ADD_SYM(".IF", P_IF, S, &pseudo_section, &system_st); + ADD_SYM(".IFDF", P_IFDF, S, &pseudo_section, &system_st); + ADD_SYM(".IFNDF", P_IFDF, S, &pseudo_section, &system_st); + ADD_SYM(".IFF", P_IFF, S, &pseudo_section, &system_st); + ADD_SYM(".IFT", P_IFT, S, &pseudo_section, &system_st); + ADD_SYM(".IFTF", P_IFTF, S, &pseudo_section, &system_st); + ADD_SYM(".IIF", P_IIF, S, &pseudo_section, &system_st); + ADD_SYM(".INCLUDE", P_INCLUDE, S, &pseudo_section, &system_st); + ADD_SYM(".IRP", P_IRP, S, &pseudo_section, &system_st); + ADD_SYM(".IRPC", P_IRPC, S, &pseudo_section, &system_st); + ADD_SYM(".LIBRARY", P_LIBRARY, S, &pseudo_section, &system_st); + ADD_SYM(".LIMIT", P_LIMIT, S, &pseudo_section, &system_st); + ADD_SYM(".LIST", P_LIST, S, &pseudo_section, &system_st); + ADD_SYM(".MCALL", P_MCALL, S, &pseudo_section, &system_st); + ADD_SYM(".MDELE", P_MDELETE, S, &pseudo_section, &system_st); + ADD_SYM(".MEXIT", P_MEXIT, S, &pseudo_section, &system_st); + ADD_SYM(".NARG", P_NARG, S, &pseudo_section, &system_st); + ADD_SYM(".NCHR", P_NCHR, S, &pseudo_section, &system_st); + ADD_SYM(".NLIST", P_NLIST, S, &pseudo_section, &system_st); + ADD_SYM(".NOCRO", P_NOCROSS, S, &pseudo_section, &system_st); + ADD_SYM(".NTYPE", P_NTYPE, S, &pseudo_section, &system_st); + ADD_SYM(".ODD", P_ODD, S, &pseudo_section, &system_st); + ADD_SYM(".PACKED", P_PACKED, S, &pseudo_section, &system_st); + ADD_SYM(".PAGE", P_PAGE, S, &pseudo_section, &system_st); + ADD_SYM(".PRINT", P_PRINT, S, &pseudo_section, &system_st); + ADD_SYM(".PSECT", P_PSECT, S, &pseudo_section, &system_st); + ADD_SYM(".RADIX", P_RADIX, S, &pseudo_section, &system_st); + ADD_SYM(".RAD50", P_RAD50, S, &pseudo_section, &system_st); + ADD_SYM(".REM", P_REM, S, &pseudo_section, &system_st); + ADD_SYM(".REPT", P_REPT, S, &pseudo_section, &system_st); + ADD_SYM(".RESTORE", P_RESTORE, S, &pseudo_section, &system_st); + ADD_SYM(".SAVE", P_SAVE, S, &pseudo_section, &system_st); + ADD_SYM(".SBTTL", P_SBTTL, S, &pseudo_section, &system_st); + ADD_SYM(".TITLE", P_TITLE, S, &pseudo_section, &system_st); + ADD_SYM(".WORD", P_WORD, S, &pseudo_section, &system_st); + ADD_SYM(".MACRO", P_MACRO, S, &pseudo_section, &system_st); + ADD_SYM(".WEAK", P_WEAK, S, &pseudo_section, &system_st); #undef S - add_sym("ADC", I_ADC, OC_1GEN, &instruction_section, &system_st); - add_sym("ADCB", I_ADCB, OC_1GEN, &instruction_section, &system_st); - add_sym("ADD", I_ADD, OC_2GEN, &instruction_section, &system_st); - add_sym("ASH", I_ASH, OC_ASH, &instruction_section, &system_st); - add_sym("ASHC", I_ASHC, OC_ASH, &instruction_section, &system_st); - add_sym("ASL", I_ASL, OC_1GEN, &instruction_section, &system_st); - add_sym("ASLB", I_ASLB, OC_1GEN, &instruction_section, &system_st); - add_sym("ASR", I_ASR, OC_1GEN, &instruction_section, &system_st); - add_sym("ASRB", I_ASRB, OC_1GEN, &instruction_section, &system_st); - add_sym("BCC", I_BCC, OC_BR, &instruction_section, &system_st); - add_sym("BCS", I_BCS, OC_BR, &instruction_section, &system_st); - add_sym("BEQ", I_BEQ, OC_BR, &instruction_section, &system_st); - add_sym("BGE", I_BGE, OC_BR, &instruction_section, &system_st); - add_sym("BGT", I_BGT, OC_BR, &instruction_section, &system_st); - add_sym("BHI", I_BHI, OC_BR, &instruction_section, &system_st); - add_sym("BHIS", I_BHIS, OC_BR, &instruction_section, &system_st); - add_sym("BIC", I_BIC, OC_2GEN, &instruction_section, &system_st); - add_sym("BICB", I_BICB, OC_2GEN, &instruction_section, &system_st); - add_sym("BIS", I_BIS, OC_2GEN, &instruction_section, &system_st); - add_sym("BISB", I_BISB, OC_2GEN, &instruction_section, &system_st); - add_sym("BIT", I_BIT, OC_2GEN, &instruction_section, &system_st); - add_sym("BITB", I_BITB, OC_2GEN, &instruction_section, &system_st); - add_sym("BLE", I_BLE, OC_BR, &instruction_section, &system_st); - add_sym("BLO", I_BLO, OC_BR, &instruction_section, &system_st); - add_sym("BLOS", I_BLOS, OC_BR, &instruction_section, &system_st); - add_sym("BLT", I_BLT, OC_BR, &instruction_section, &system_st); - add_sym("BMI", I_BMI, OC_BR, &instruction_section, &system_st); - add_sym("BNE", I_BNE, OC_BR, &instruction_section, &system_st); - add_sym("BPL", I_BPL, OC_BR, &instruction_section, &system_st); - add_sym("BPT", I_BPT, OC_NONE, &instruction_section, &system_st); - add_sym("BR", I_BR, OC_BR, &instruction_section, &system_st); - add_sym("BVC", I_BVC, OC_BR, &instruction_section, &system_st); - add_sym("BVS", I_BVS, OC_BR, &instruction_section, &system_st); - add_sym("CALL", I_CALL, OC_1GEN, &instruction_section, &system_st); - add_sym("CALLR", I_CALLR, OC_1GEN, &instruction_section, &system_st); - add_sym("CCC", I_CCC, OC_NONE, &instruction_section, &system_st); - add_sym("CLC", I_CLC, OC_NONE, &instruction_section, &system_st); - add_sym("CLN", I_CLN, OC_NONE, &instruction_section, &system_st); - add_sym("CLR", I_CLR, OC_1GEN, &instruction_section, &system_st); - add_sym("CLRB", I_CLRB, OC_1GEN, &instruction_section, &system_st); - add_sym("CLV", I_CLV, OC_NONE, &instruction_section, &system_st); - add_sym("CLZ", I_CLZ, OC_NONE, &instruction_section, &system_st); - add_sym("CMP", I_CMP, OC_2GEN, &instruction_section, &system_st); - add_sym("CMPB", I_CMPB, OC_2GEN, &instruction_section, &system_st); - add_sym("COM", I_COM, OC_1GEN, &instruction_section, &system_st); - add_sym("COMB", I_COMB, OC_1GEN, &instruction_section, &system_st); - add_sym("DEC", I_DEC, OC_1GEN, &instruction_section, &system_st); - add_sym("DECB", I_DECB, OC_1GEN, &instruction_section, &system_st); - add_sym("DIV", I_DIV, OC_ASH, &instruction_section, &system_st); - add_sym("EMT", I_EMT, OC_MARK, &instruction_section, &system_st); - add_sym("FADD", I_FADD, OC_1REG, &instruction_section, &system_st); - add_sym("FDIV", I_FDIV, OC_1REG, &instruction_section, &system_st); - add_sym("FMUL", I_FMUL, OC_1REG, &instruction_section, &system_st); - add_sym("FSUB", I_FSUB, OC_1REG, &instruction_section, &system_st); - add_sym("HALT", I_HALT, OC_NONE, &instruction_section, &system_st); - add_sym("INC", I_INC, OC_1GEN, &instruction_section, &system_st); - add_sym("INCB", I_INCB, OC_1GEN, &instruction_section, &system_st); - add_sym("IOT", I_IOT, OC_NONE, &instruction_section, &system_st); - add_sym("JMP", I_JMP, OC_1GEN, &instruction_section, &system_st); - add_sym("JSR", I_JSR, OC_JSR, &instruction_section, &system_st); - add_sym("MARK", I_MARK, OC_MARK, &instruction_section, &system_st); - add_sym("MED6X", I_MED6X, OC_NONE, &instruction_section, &system_st); - add_sym("MED74C", I_MED74C, OC_NONE, &instruction_section, &system_st); - add_sym("MFPD", I_MFPD, OC_1GEN, &instruction_section, &system_st); - add_sym("MFPI", I_MFPI, OC_1GEN, &instruction_section, &system_st); - add_sym("MFPS", I_MFPS, OC_1GEN, &instruction_section, &system_st); - add_sym("MOV", I_MOV, OC_2GEN, &instruction_section, &system_st); - add_sym("MOVB", I_MOVB, OC_2GEN, &instruction_section, &system_st); - add_sym("MTPD", I_MTPD, OC_1GEN, &instruction_section, &system_st); - add_sym("MTPI", I_MTPI, OC_1GEN, &instruction_section, &system_st); - add_sym("MTPS", I_MTPS, OC_1GEN, &instruction_section, &system_st); - add_sym("MUL", I_MUL, OC_ASH, &instruction_section, &system_st); - add_sym("NEG", I_NEG, OC_1GEN, &instruction_section, &system_st); - add_sym("NEGB", I_NEGB, OC_1GEN, &instruction_section, &system_st); - add_sym("NOP", I_NOP, OC_NONE, &instruction_section, &system_st); - add_sym("RESET", I_RESET, OC_NONE, &instruction_section, &system_st); - add_sym("RETURN", I_RETURN, OC_NONE, &instruction_section, &system_st); - add_sym("ROL", I_ROL, OC_1GEN, &instruction_section, &system_st); - add_sym("ROLB", I_ROLB, OC_1GEN, &instruction_section, &system_st); - add_sym("ROR", I_ROR, OC_1GEN, &instruction_section, &system_st); - add_sym("RORB", I_RORB, OC_1GEN, &instruction_section, &system_st); - add_sym("RTI", I_RTI, OC_NONE, &instruction_section, &system_st); - add_sym("RTS", I_RTS, OC_1REG, &instruction_section, &system_st); - add_sym("RTT", I_RTT, OC_NONE, &instruction_section, &system_st); - add_sym("SBC", I_SBC, OC_1GEN, &instruction_section, &system_st); - add_sym("SBCB", I_SBCB, OC_1GEN, &instruction_section, &system_st); - add_sym("SCC", I_SCC, OC_NONE, &instruction_section, &system_st); - add_sym("SEC", I_SEC, OC_NONE, &instruction_section, &system_st); - add_sym("SEN", I_SEN, OC_NONE, &instruction_section, &system_st); - add_sym("SEV", I_SEV, OC_NONE, &instruction_section, &system_st); - add_sym("SEZ", I_SEZ, OC_NONE, &instruction_section, &system_st); - add_sym("SOB", I_SOB, OC_SOB, &instruction_section, &system_st); - add_sym("SPL", I_SPL, OC_1REG, &instruction_section, &system_st); - add_sym("SUB", I_SUB, OC_2GEN, &instruction_section, &system_st); - add_sym("SWAB", I_SWAB, OC_1GEN, &instruction_section, &system_st); - add_sym("SXT", I_SXT, OC_1GEN, &instruction_section, &system_st); - add_sym("TRAP", I_TRAP, OC_MARK, &instruction_section, &system_st); - add_sym("TST", I_TST, OC_1GEN, &instruction_section, &system_st); - add_sym("TSTB", I_TSTB, OC_1GEN, &instruction_section, &system_st); - add_sym("WAIT", I_WAIT, OC_NONE, &instruction_section, &system_st); - add_sym("XFC", I_XFC, OC_NONE, &instruction_section, &system_st); - add_sym("XOR", I_XOR, OC_JSR, &instruction_section, &system_st); - add_sym("MFPT", I_MFPT, OC_NONE, &instruction_section, &system_st); - add_sym("CSM", I_CSM, OC_1GEN, &instruction_section, &system_st); - add_sym("TSTSET", I_TSTSET, OC_1GEN, &instruction_section, &system_st); - add_sym("WRTLCK", I_WRTLCK, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ADC", I_ADC, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ADCB", I_ADCB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ADD", I_ADD, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("ASH", I_ASH, OC_ASH, &instruction_section, &system_st); + ADD_SYM("ASHC", I_ASHC, OC_ASH, &instruction_section, &system_st); + ADD_SYM("ASL", I_ASL, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ASLB", I_ASLB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ASR", I_ASR, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ASRB", I_ASRB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("BCC", I_BCC, OC_BR, &instruction_section, &system_st); + ADD_SYM("BCS", I_BCS, OC_BR, &instruction_section, &system_st); + ADD_SYM("BEQ", I_BEQ, OC_BR, &instruction_section, &system_st); + ADD_SYM("BGE", I_BGE, OC_BR, &instruction_section, &system_st); + ADD_SYM("BGT", I_BGT, OC_BR, &instruction_section, &system_st); + ADD_SYM("BHI", I_BHI, OC_BR, &instruction_section, &system_st); + ADD_SYM("BHIS", I_BHIS, OC_BR, &instruction_section, &system_st); + ADD_SYM("BIC", I_BIC, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("BICB", I_BICB, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("BIS", I_BIS, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("BISB", I_BISB, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("BIT", I_BIT, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("BITB", I_BITB, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("BLE", I_BLE, OC_BR, &instruction_section, &system_st); + ADD_SYM("BLO", I_BLO, OC_BR, &instruction_section, &system_st); + ADD_SYM("BLOS", I_BLOS, OC_BR, &instruction_section, &system_st); + ADD_SYM("BLT", I_BLT, OC_BR, &instruction_section, &system_st); + ADD_SYM("BMI", I_BMI, OC_BR, &instruction_section, &system_st); + ADD_SYM("BNE", I_BNE, OC_BR, &instruction_section, &system_st); + ADD_SYM("BPL", I_BPL, OC_BR, &instruction_section, &system_st); + ADD_SYM("BPT", I_BPT, OC_NONE, &instruction_section, &system_st); + ADD_SYM("BR", I_BR, OC_BR, &instruction_section, &system_st); + ADD_SYM("BVC", I_BVC, OC_BR, &instruction_section, &system_st); + ADD_SYM("BVS", I_BVS, OC_BR, &instruction_section, &system_st); + ADD_SYM("CALL", I_CALL, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("CALLR", I_CALLR, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("CCC", I_CCC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CLC", I_CLC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CLN", I_CLN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CLR", I_CLR, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("CLRB", I_CLRB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("CLV", I_CLV, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CLZ", I_CLZ, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CMP", I_CMP, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("CMPB", I_CMPB, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("COM", I_COM, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("COMB", I_COMB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("DEC", I_DEC, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("DECB", I_DECB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("DIV", I_DIV, OC_ASH, &instruction_section, &system_st); + ADD_SYM("EMT", I_EMT, OC_MARK, &instruction_section, &system_st); + ADD_SYM("FADD", I_FADD, OC_1REG, &instruction_section, &system_st); + ADD_SYM("FDIV", I_FDIV, OC_1REG, &instruction_section, &system_st); + ADD_SYM("FMUL", I_FMUL, OC_1REG, &instruction_section, &system_st); + ADD_SYM("FSUB", I_FSUB, OC_1REG, &instruction_section, &system_st); + ADD_SYM("HALT", I_HALT, OC_NONE, &instruction_section, &system_st); + ADD_SYM("INC", I_INC, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("INCB", I_INCB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("IOT", I_IOT, OC_NONE, &instruction_section, &system_st); + ADD_SYM("JMP", I_JMP, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("JSR", I_JSR, OC_JSR, &instruction_section, &system_st); + ADD_SYM("MARK", I_MARK, OC_MARK, &instruction_section, &system_st); + ADD_SYM("MED6X", I_MED6X, OC_NONE, &instruction_section, &system_st); + ADD_SYM("MED74C", I_MED74C, OC_NONE, &instruction_section, &system_st); + ADD_SYM("MFPD", I_MFPD, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("MFPI", I_MFPI, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("MFPS", I_MFPS, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("MOV", I_MOV, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("MOVB", I_MOVB, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("MTPD", I_MTPD, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("MTPI", I_MTPI, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("MTPS", I_MTPS, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("MUL", I_MUL, OC_ASH, &instruction_section, &system_st); + ADD_SYM("NEG", I_NEG, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("NEGB", I_NEGB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("NOP", I_NOP, OC_NONE, &instruction_section, &system_st); + ADD_SYM("RESET", I_RESET, OC_NONE, &instruction_section, &system_st); + ADD_SYM("RETURN", I_RETURN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("ROL", I_ROL, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ROLB", I_ROLB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("ROR", I_ROR, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("RORB", I_RORB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("RTI", I_RTI, OC_NONE, &instruction_section, &system_st); + ADD_SYM("RTS", I_RTS, OC_1REG, &instruction_section, &system_st); + ADD_SYM("RTT", I_RTT, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SBC", I_SBC, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("SBCB", I_SBCB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("SCC", I_SCC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SEC", I_SEC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SEN", I_SEN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SEV", I_SEV, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SEZ", I_SEZ, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SOB", I_SOB, OC_SOB, &instruction_section, &system_st); + ADD_SYM("SPL", I_SPL, OC_1REG, &instruction_section, &system_st); + ADD_SYM("SUB", I_SUB, OC_2GEN, &instruction_section, &system_st); + ADD_SYM("SWAB", I_SWAB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("SXT", I_SXT, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("TRAP", I_TRAP, OC_MARK, &instruction_section, &system_st); + ADD_SYM("TST", I_TST, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("TSTB", I_TSTB, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("WAIT", I_WAIT, OC_NONE, &instruction_section, &system_st); + ADD_SYM("XFC", I_XFC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("XOR", I_XOR, OC_JSR, &instruction_section, &system_st); + ADD_SYM("MFPT", I_MFPT, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CSM", I_CSM, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("TSTSET", I_TSTSET, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("WRTLCK", I_WRTLCK, OC_1GEN, &instruction_section, &system_st); /* FPP instructions */ - add_sym("ABSD", I_ABSD, OC_FPP_FDST, &instruction_section, &system_st); - add_sym("ABSF", I_ABSF, OC_FPP_FDST, &instruction_section, &system_st); - add_sym("ADDD", I_ADDD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("ADDF", I_ADDF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("CFCC", I_CFCC, OC_NONE, &instruction_section, &system_st); - add_sym("CLRD", I_CLRD, OC_FPP_FDST, &instruction_section, &system_st); - add_sym("CLRF", I_CLRF, OC_FPP_FDST, &instruction_section, &system_st); - add_sym("CMPD", I_CMPD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("CMPF", I_CMPF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("DIVD", I_DIVD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("DIVF", I_DIVF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("LDCDF", I_LDCDF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("LDCFD", I_LDCFD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("LDCID", I_LDCID, OC_FPP_SRCAC, &instruction_section, &system_st); - add_sym("LDCIF", I_LDCIF, OC_FPP_SRCAC, &instruction_section, &system_st); - add_sym("LDCLD", I_LDCLD, OC_FPP_SRCAC, &instruction_section, &system_st); - add_sym("LDCLF", I_LDCLF, OC_FPP_SRCAC, &instruction_section, &system_st); - add_sym("LDD", I_LDD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("LDEXP", I_LDEXP, OC_FPP_SRCAC, &instruction_section, &system_st); - add_sym("LDF", I_LDF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("LDFPS", I_LDFPS, OC_1GEN, &instruction_section, &system_st); - add_sym("MODD", I_MODD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("MODF", I_MODF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("MULD", I_MULD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("MULF", I_MULF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("NEGD", I_NEGD, OC_FPP_FDST, &instruction_section, &system_st); - add_sym("NEGF", I_NEGF, OC_FPP_FDST, &instruction_section, &system_st); - add_sym("SETD", I_SETD, OC_NONE, &instruction_section, &system_st); - add_sym("SETF", I_SETF, OC_NONE, &instruction_section, &system_st); - add_sym("SETI", I_SETI, OC_NONE, &instruction_section, &system_st); - add_sym("SETL", I_SETL, OC_NONE, &instruction_section, &system_st); - add_sym("STA0", I_STA0, OC_NONE, &instruction_section, &system_st); - add_sym("STB0", I_STB0, OC_NONE, &instruction_section, &system_st); - add_sym("STCDF", I_STCDF, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STCDI", I_STCDI, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STCDL", I_STCDL, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STCFD", I_STCFD, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STCFI", I_STCFI, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STCFL", I_STCFL, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STD", I_STD, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STEXP", I_STEXP, OC_FPP_ACDST, &instruction_section, &system_st); - add_sym("STF", I_STF, OC_FPP_ACFDST, &instruction_section, &system_st); - add_sym("STFPS", I_STFPS, OC_1GEN, &instruction_section, &system_st); - add_sym("STST", I_STST, OC_1GEN, &instruction_section, &system_st); - add_sym("SUBD", I_SUBD, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("SUBF", I_SUBF, OC_FPP_FSRCAC, &instruction_section, &system_st); - add_sym("TSTD", I_TSTD, OC_FPP_FDST, &instruction_section, &system_st); - add_sym("TSTF", I_TSTF, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("ABSD", I_ABSD, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("ABSF", I_ABSF, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("ADDD", I_ADDD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("ADDF", I_ADDF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("CFCC", I_CFCC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CLRD", I_CLRD, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("CLRF", I_CLRF, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("CMPD", I_CMPD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("CMPF", I_CMPF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("DIVD", I_DIVD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("DIVF", I_DIVF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("LDCDF", I_LDCDF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("LDCFD", I_LDCFD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("LDCID", I_LDCID, OC_FPP_SRCAC, &instruction_section, &system_st); + ADD_SYM("LDCIF", I_LDCIF, OC_FPP_SRCAC, &instruction_section, &system_st); + ADD_SYM("LDCLD", I_LDCLD, OC_FPP_SRCAC, &instruction_section, &system_st); + ADD_SYM("LDCLF", I_LDCLF, OC_FPP_SRCAC, &instruction_section, &system_st); + ADD_SYM("LDD", I_LDD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("LDEXP", I_LDEXP, OC_FPP_SRCAC, &instruction_section, &system_st); + ADD_SYM("LDF", I_LDF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("LDFPS", I_LDFPS, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("MODD", I_MODD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("MODF", I_MODF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("MULD", I_MULD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("MULF", I_MULF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("NEGD", I_NEGD, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("NEGF", I_NEGF, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("SETD", I_SETD, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SETF", I_SETF, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SETI", I_SETI, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SETL", I_SETL, OC_NONE, &instruction_section, &system_st); + ADD_SYM("STA0", I_STA0, OC_NONE, &instruction_section, &system_st); + ADD_SYM("STB0", I_STB0, OC_NONE, &instruction_section, &system_st); + ADD_SYM("STCDF", I_STCDF, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STCDI", I_STCDI, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STCDL", I_STCDL, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STCFD", I_STCFD, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STCFI", I_STCFI, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STCFL", I_STCFL, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STD", I_STD, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STEXP", I_STEXP, OC_FPP_ACDST, &instruction_section, &system_st); + ADD_SYM("STF", I_STF, OC_FPP_ACFDST, &instruction_section, &system_st); + ADD_SYM("STFPS", I_STFPS, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("STST", I_STST, OC_1GEN, &instruction_section, &system_st); + ADD_SYM("SUBD", I_SUBD, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("SUBF", I_SUBF, OC_FPP_FSRCAC, &instruction_section, &system_st); + ADD_SYM("TSTD", I_TSTD, OC_FPP_FDST, &instruction_section, &system_st); + ADD_SYM("TSTF", I_TSTF, OC_FPP_FDST, &instruction_section, &system_st); /* The CIS instructions */ - add_sym("ADDNI", I_ADDN|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("ADDN", I_ADDN, OC_NONE, &instruction_section, &system_st); - add_sym("ADDPI", I_ADDP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("ADDP", I_ADDP, OC_NONE, &instruction_section, &system_st); - add_sym("ASHNI", I_ASHN|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("ASHN", I_ASHN, OC_NONE, &instruction_section, &system_st); - add_sym("ASHPI", I_ASHP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("ASHP", I_ASHP, OC_NONE, &instruction_section, &system_st); - add_sym("CMPCI", I_CMPC|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("CMPC", I_CMPC, OC_NONE, &instruction_section, &system_st); - add_sym("CMPNI", I_CMPN|I_CIS_I, OC_CIS2, &instruction_section, &system_st); - add_sym("CMPN", I_CMPN, OC_NONE, &instruction_section, &system_st); - add_sym("CMPPI", I_CMPP|I_CIS_I, OC_CIS2, &instruction_section, &system_st); - add_sym("CMPP", I_CMPP, OC_NONE, &instruction_section, &system_st); - add_sym("CVTLNI",I_CVTLN|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("CVTLN", I_CVTLN, OC_NONE, &instruction_section, &system_st); - add_sym("CVTLPI",I_CVTLP|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("CVTLP", I_CVTPL, OC_NONE, &instruction_section, &system_st); - add_sym("CVTNLI",I_CVTNL|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("CVTNL", I_CVTNL, OC_NONE, &instruction_section, &system_st); - add_sym("CVTPLI",I_CVTPL|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("CVTPL", I_CVTPL, OC_NONE, &instruction_section, &system_st); - add_sym("CVTNPI",I_CVTNP|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("CVTNP", I_CVTNP, OC_NONE, &instruction_section, &system_st); - add_sym("CVTPNI",I_CVTPN|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("CVTPN", I_CVTPN, OC_NONE, &instruction_section, &system_st); - add_sym("DIVPI", I_DIVP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("DIVP", I_DIVP, OC_NONE, &instruction_section, &system_st); - add_sym("LOCCI", I_LOCC|I_CIS_I, OC_CIS2, &instruction_section, &system_st); - add_sym("LOCC", I_LOCC, OC_NONE, &instruction_section, &system_st); - add_sym("L2D0", I_L2Dr+0, OC_NONE, &instruction_section, &system_st); - add_sym("L2D1", I_L2Dr+1, OC_NONE, &instruction_section, &system_st); - add_sym("L2D2", I_L2Dr+2, OC_NONE, &instruction_section, &system_st); - add_sym("L2D3", I_L2Dr+3, OC_NONE, &instruction_section, &system_st); - add_sym("L2D4", I_L2Dr+4, OC_NONE, &instruction_section, &system_st); - add_sym("L2D5", I_L2Dr+5, OC_NONE, &instruction_section, &system_st); - add_sym("L2D6", I_L2Dr+6, OC_NONE, &instruction_section, &system_st); - add_sym("L2D7", I_L2Dr+7, OC_NONE, &instruction_section, &system_st); - add_sym("L3D0", I_L3Dr+0, OC_NONE, &instruction_section, &system_st); - add_sym("L3D1", I_L3Dr+1, OC_NONE, &instruction_section, &system_st); - add_sym("L3D2", I_L3Dr+2, OC_NONE, &instruction_section, &system_st); - add_sym("L3D3", I_L3Dr+3, OC_NONE, &instruction_section, &system_st); - add_sym("L3D4", I_L3Dr+4, OC_NONE, &instruction_section, &system_st); - add_sym("L3D5", I_L3Dr+5, OC_NONE, &instruction_section, &system_st); - add_sym("L3D6", I_L3Dr+6, OC_NONE, &instruction_section, &system_st); - add_sym("L3D7", I_L3Dr+7, OC_NONE, &instruction_section, &system_st); - add_sym("MATCI", I_MATC|I_CIS_I, OC_CIS2, &instruction_section, &system_st); - add_sym("MATC", I_MATC, OC_NONE, &instruction_section, &system_st); - add_sym("MOVCI", I_MOVC|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("MOVC", I_MOVC, OC_NONE, &instruction_section, &system_st); - add_sym("MOVRCI",I_MOVRC|I_CIS_I,OC_CIS3, &instruction_section, &system_st); - add_sym("MOVRC", I_MOVRC, OC_NONE, &instruction_section, &system_st); - add_sym("MOVTCI",I_MOVTC|I_CIS_I,OC_CIS4, &instruction_section, &system_st); - add_sym("MOVTC", I_MOVTC, OC_NONE, &instruction_section, &system_st); - add_sym("MULPI", I_MULP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("MULP", I_MULP, OC_NONE, &instruction_section, &system_st); - add_sym("SCANCI",I_SCANC|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("SCANC", I_SCANC, OC_NONE, &instruction_section, &system_st); - add_sym("SKPCI", I_SKPC|I_CIS_I, OC_CIS2, &instruction_section, &system_st); - add_sym("SKPC", I_SKPC, OC_NONE, &instruction_section, &system_st); - add_sym("SPANCI",I_SPANC|I_CIS_I,OC_CIS2, &instruction_section, &system_st); - add_sym("SPANC", I_SPANC, OC_NONE, &instruction_section, &system_st); - add_sym("SUBNI", I_SUBN|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("SUBN", I_SUBN, OC_NONE, &instruction_section, &system_st); - add_sym("SUBPI", I_SUBP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); - add_sym("SUBP", I_SUBP, OC_NONE, &instruction_section, &system_st); - - add_sym(current_section->label, 0, 0, current_section, §ion_st); + ADD_SYM("ADDNI", I_ADDN|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("ADDN", I_ADDN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("ADDPI", I_ADDP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("ADDP", I_ADDP, OC_NONE, &instruction_section, &system_st); + ADD_SYM("ASHNI", I_ASHN|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("ASHN", I_ASHN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("ASHPI", I_ASHP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("ASHP", I_ASHP, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CMPCI", I_CMPC|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("CMPC", I_CMPC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CMPNI", I_CMPN|I_CIS_I, OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CMPN", I_CMPN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CMPPI", I_CMPP|I_CIS_I, OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CMPP", I_CMPP, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CVTLNI",I_CVTLN|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CVTLN", I_CVTLN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CVTLPI",I_CVTLP|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CVTLP", I_CVTPL, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CVTNLI",I_CVTNL|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CVTNL", I_CVTNL, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CVTPLI",I_CVTPL|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CVTPL", I_CVTPL, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CVTNPI",I_CVTNP|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CVTNP", I_CVTNP, OC_NONE, &instruction_section, &system_st); + ADD_SYM("CVTPNI",I_CVTPN|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("CVTPN", I_CVTPN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("DIVPI", I_DIVP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("DIVP", I_DIVP, OC_NONE, &instruction_section, &system_st); + ADD_SYM("LOCCI", I_LOCC|I_CIS_I, OC_CIS2, &instruction_section, &system_st); + ADD_SYM("LOCC", I_LOCC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D0", I_L2Dr+0, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D1", I_L2Dr+1, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D2", I_L2Dr+2, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D3", I_L2Dr+3, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D4", I_L2Dr+4, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D5", I_L2Dr+5, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D6", I_L2Dr+6, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L2D7", I_L2Dr+7, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D0", I_L3Dr+0, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D1", I_L3Dr+1, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D2", I_L3Dr+2, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D3", I_L3Dr+3, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D4", I_L3Dr+4, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D5", I_L3Dr+5, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D6", I_L3Dr+6, OC_NONE, &instruction_section, &system_st); + ADD_SYM("L3D7", I_L3Dr+7, OC_NONE, &instruction_section, &system_st); + ADD_SYM("MATCI", I_MATC|I_CIS_I, OC_CIS2, &instruction_section, &system_st); + ADD_SYM("MATC", I_MATC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("MOVCI", I_MOVC|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("MOVC", I_MOVC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("MOVRCI",I_MOVRC|I_CIS_I,OC_CIS3, &instruction_section, &system_st); + ADD_SYM("MOVRC", I_MOVRC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("MOVTCI",I_MOVTC|I_CIS_I,OC_CIS4, &instruction_section, &system_st); + ADD_SYM("MOVTC", I_MOVTC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("MULPI", I_MULP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("MULP", I_MULP, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SCANCI",I_SCANC|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("SCANC", I_SCANC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SKPCI", I_SKPC|I_CIS_I, OC_CIS2, &instruction_section, &system_st); + ADD_SYM("SKPC", I_SKPC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SPANCI",I_SPANC|I_CIS_I,OC_CIS2, &instruction_section, &system_st); + ADD_SYM("SPANC", I_SPANC, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SUBNI", I_SUBN|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("SUBN", I_SUBN, OC_NONE, &instruction_section, &system_st); + ADD_SYM("SUBPI", I_SUBP|I_CIS_I, OC_CIS3, &instruction_section, &system_st); + ADD_SYM("SUBP", I_SUBP, OC_NONE, &instruction_section, &system_st); + + ADD_SYM(current_section->label, 0, 0, current_section, §ion_st); } /* sym_hist is a diagnostic function that prints a histogram of the @@ -740,7 +756,7 @@ void list_symbol_table( int i; for (i = line; i < nsyms; i += nlines) { sym = symbols[i]; - check_sym_invariants(sym, __FILE__, __LINE__); + check_sym_invariants(sym, __FILE__, __LINE__, NULL); fprintf(lstfile,"%-*s", longest_symbol, sym->label); fprintf(lstfile,"%c", (sym->section->flags & PSECT_REL) ? ' ' : '='); diff --git a/symbols.h b/symbols.h index 403d44f..53df804 100644 --- a/symbols.h +++ b/symbols.h @@ -34,7 +34,7 @@ typedef struct symbol { unsigned value; /* Symbol value */ int stmtno; /* Statement number of symbol's definition */ unsigned flags; /* Symbol flags */ -#define SYMBOLFLAG_PERMANENT 1 /* Symbol may not be redefined */ +#define SYMBOLFLAG_PERMANENT 1 /* Symbol may not be redefined (i.e. a label) */ #define SYMBOLFLAG_GLOBAL 2 /* Symbol is global */ #define SYMBOLFLAG_WEAK 4 /* Symbol definition is weak */ #define SYMBOLFLAG_DEFINITION 8 /* Symbol is a global definition, not reference */ @@ -380,12 +380,15 @@ extern SYMBOL_TABLE undefined_st; /* The symbols which may be undefined */ int hash_name( char *label); +struct stream; + SYMBOL *add_sym( char *label, unsigned value, unsigned flags, SECTION *section, - SYMBOL_TABLE *table); + SYMBOL_TABLE *table, + struct stream *stream); SYMBOL *first_sym( SYMBOL_TABLE *table, SYMBOL_ITER *iter); diff --git a/tests/test-asciz.lst.ok b/tests/test-asciz.lst.ok index 213bf6f..f73e5fa 100644 --- a/tests/test-asciz.lst.ok +++ b/tests/test-asciz.lst.ok @@ -38,6 +38,7 @@ test-asciz.mac:19: ***ERROR Complex expression cannot be assigned to a symbol 20 000075 000 .even test-asciz.mac:21: ***ERROR Invalid expression in .WORD 21 000076 000001 .asciz :SOH: ; syntax error: colon not allowed +test-asciz.mac:22: ***ERROR Phase error: '.ASCIZ' test-asciz.mac:22: ***ERROR Illegal symbol definition .ASCIZ test-asciz.mac:22: ***ERROR Invalid expression in .WORD 22 .asciz :###: ; syntax error: colon not allowed diff --git a/tests/test-include.lst.ok b/tests/test-include.lst.ok index 0407d4e..7a2148a 100644 --- a/tests/test-include.lst.ok +++ b/tests/test-include.lst.ok @@ -45,6 +45,7 @@ test-include.mac:14: ***ERROR Bad .INCLUDE file name 14 .include test-include.mac:15: ***ERROR Bad .INCLUDE file name 15 .include NAME:1: ***ERROR Redefining permanent symbol 'LAB' + 1 000000 .narg lab ; redefinition +test-packed.mac:48->NAME:2: ***ERROR Redefining permanent symbol 'LAB' + 2 .nchr lab,// ; redefinition +test-packed.mac:48->NAME:3: ***ERROR Redefining permanent symbol 'LAB' + 3 .ntype lab,#3 ; redefinition + 49 .end + 49 Symbol table diff --git a/tests/test-packed.mac b/tests/test-packed.mac index 4dd3000..fe4f8b7 100644 --- a/tests/test-packed.mac +++ b/tests/test-packed.mac @@ -37,4 +37,13 @@ l5 =: 5 ; M error; why??? ; too long: .packed 12345678901234567890123456789012 +; In the original, .ntype must occur in a macro. +; As an extension, we allow it also outside macros. + .macro name arg1,arg2 + .narg lab ; redefinition + .nchr lab,// ; redefinition + .ntype lab,#3 ; redefinition + .endm + + name .end From ffd5159f3b75cad4dab028442be381f774b5b168 Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Thu, 11 Aug 2022 21:54:03 +0200 Subject: [PATCH 05/48] Improve error messages. Avoid the term "illegal". In case of syntax errors, more often indicate what was expected, instead of just complaining it was invalid. --- assemble.c | 34 ++++++++++++++++++---------------- assemble_aux.c | 2 +- macros.c | 4 ++-- rept_irpc.c | 8 ++++---- symbols.c | 10 +++++----- tests/test-asciz.lst.ok | 2 +- tests/test-jmp.lst.ok | 4 ++-- tests/test-rad50.lst.ok | 4 ++-- tests/test-undef.lst.ok | 2 +- 9 files changed, 36 insertions(+), 34 deletions(-) diff --git a/assemble.c b/assemble.c index 0566415..c19b236 100644 --- a/assemble.c +++ b/assemble.c @@ -54,10 +54,10 @@ static unsigned * assemble_rad50 ( value = parse_unary_expr(cp, 0); cp = value->cp; if (value->type != EX_LIT) { - report(stack->top, "expression must be constant\n"); + report(stack->top, "Expression must be constant\n"); radstr[len++] = 0; } else if (value->data.lit >= 050) { - report(stack->top, "invalid character value %o\n", value->data.lit); + report(stack->top, "Invalid character value %o\n", value->data.lit); radstr[len++] = 0; } else { radstr[len++] = value->data.lit; @@ -70,7 +70,7 @@ static unsigned * assemble_rad50 ( int ch = ascii2rad50(*cp++); if (ch == -1) { - report(stack->top, "invalid character '%c'\n", cp[-1]); + report(stack->top, "Invalid character '%c'\n", cp[-1]); radstr[len++] = 0; } else { radstr[len++] = ch; @@ -220,7 +220,7 @@ O 75 .endc cp = ncp; if (sym == NULL) - report(stack->top, "Illegal symbol definition %s\n", label); + report(stack->top, "Invalid symbol definition '%s'\n", label); free(label); @@ -284,7 +284,7 @@ O 75 .endc section must = current. */ if (!express_sym_offset(value, &symb, &offset)) { - report(stack->top, "Illegal ORG (for relocatable section)\n"); + report(stack->top, "Invalid ORG (for relocatable section)\n"); } else if (SYM_IS_IMPORTED(symb)) { report(stack->top, "Can't ORG to external location\n"); } else if (symb->flags & SYMBOLFLAG_UNDEFINED) { @@ -508,7 +508,7 @@ O 75 .endc label = get_symbol(cp, &cp, &islocal); if (label == NULL) { - report(stack->top, "Bad .NARG syntax\n"); + report(stack->top, "Bad .NARG syntax (symbol expected)\n"); return 0; } @@ -540,7 +540,7 @@ O 75 .endc label = get_symbol(cp, &cp, &islocal); if (label == NULL) { - report(stack->top, "Bad .NCHR syntax\n"); + report(stack->top, "Bad .NCHR syntax (symbol expected)\n"); return 0; } @@ -563,7 +563,7 @@ O 75 .endc label = get_symbol(cp, &cp, &islocal); if (label == NULL) { - report(stack->top, "Bad .NTYPE syntax\n"); + report(stack->top, "Bad .NTYPE syntax (symbol expected)\n"); return 0; } @@ -702,7 +702,8 @@ O 75 .endc label = get_symbol(cp, &cp, NULL); if (!label) { - report(stack->top, "Illegal .MCALL format\n"); + report(stack->top, + "Invalid .MCALL syntax (symbol expected)\n"); return 0; } @@ -717,7 +718,7 @@ O 75 .endc /* Do the actual macro library search */ if (!do_mcall (label, stack)) - report(stack->top, "MACRO %s not found\n", label); + report(stack->top, "MACRO '%s' not found\n", label); free(label); } @@ -1181,7 +1182,7 @@ O 75 .endc comma-separated symbols */ label = get_symbol(cp, &ncp, &islocal); if (label == NULL) { - report(stack->top, "Illegal .GLOBL/.WEAK syntax\n"); + report(stack->top, "Bad .GLOBL/.WEAK syntax (symbol expected)\n"); return 0; } @@ -1365,7 +1366,7 @@ O 75 .endc label = get_symbol(cp, &cp, &islocal); if (label == NULL) { - report(stack->top, "Bad .PACKED syntax: symbol name expected\n"); + report(stack->top, "Bad .PACKED syntax (symbol expected)\n"); return 0; } @@ -1413,7 +1414,8 @@ O 75 .endc cp = value->cp; if (value->type != EX_LIT) { if (op->value == I_MARK) { - report(stack->top, "Instruction requires " "simple literal operand\n"); + report(stack->top, + "Instruction requires simple literal operand\n"); store_word(stack->top, tr, 2, op->value); } else { @@ -1449,7 +1451,7 @@ O 75 .endc } if (op->value == I_JMP && (mode.type & 070) == 0) { - report(stack->top, "JMP Rn is illegal\n"); + report(stack->top, "JMP Rn is impossible\n"); /* But encode it anyway... */ } @@ -1694,7 +1696,7 @@ O 75 .endc } if (op->value == I_JSR && (mode.type & 070) == 0) { - report(stack->top, "JSR Rn,Rm is illegal\n"); + report(stack->top, "JSR Rn,Rm is impossible\n"); /* But encode it anyway... */ } @@ -1736,7 +1738,7 @@ O 75 .endc unsigned word; if (!get_fp_src_mode(cp, &cp, &mode)) { - report(stack->top, "Illegal addressing mode\n"); + report(stack->top, "Invalid addressing mode\n"); return 0; } diff --git a/assemble_aux.c b/assemble_aux.c index 941df82..52ef11e 100644 --- a/assemble_aux.c +++ b/assemble_aux.c @@ -823,7 +823,7 @@ void write_globals( unsigned offset; if (!express_sym_offset(xfer_address, &lsym, &offset)) { - report(NULL, "Illegal program transfer address\n"); + report(NULL, "Invalid program transfer address\n"); } else { gsd_xfer(&gsd, lsym->section->label, lsym->value + offset); } diff --git a/macros.c b/macros.c index efa2d1e..d5ded12 100644 --- a/macros.c +++ b/macros.c @@ -217,7 +217,7 @@ MACRO *defmacro( /* So, just quit defining arguments. */ break; #if 0 - report(str, "Illegal macro argument\n"); + report(str, "Invalid macro argument\n"); remove_sym(&mac->sym, ¯o_st); free_macro(mac); return NULL; @@ -229,7 +229,7 @@ MACRO *defmacro( /* Default substitution given */ arg->value = getstring(cp + 1, &cp); if (arg->value == NULL) { - report(stack->top, "Illegal macro argument\n"); + report(stack->top, "Invalid macro argument\n"); remove_sym(&mac->sym, ¯o_st); free_macro(mac); return NULL; diff --git a/rept_irpc.c b/rept_irpc.c index 3459709..98bf0fb 100644 --- a/rept_irpc.c +++ b/rept_irpc.c @@ -230,7 +230,7 @@ STREAM *expand_irp( label = get_irp_sym(cp, &cp, NULL); if (!label) { - report(stack->top, "Illegal .IRP syntax\n"); + report(stack->top, "Invalid .IRP syntax (symbol or expected)\n"); return NULL; } @@ -238,7 +238,7 @@ STREAM *expand_irp( items = getstring(cp, &cp); if (!items) { - report(stack->top, "Illegal .IRP syntax\n"); + report(stack->top, "Invalid .IRP syntax (string expected)\n"); free(label); return NULL; } @@ -360,7 +360,7 @@ STREAM *expand_irpc( label = get_irp_sym(cp, &cp, NULL); if (!label) { - report(stack->top, "Illegal .IRPC syntax\n"); + report(stack->top, "Invalid .IRPC syntax (label or