mirror of
https://github.com/open-simh/simtools.git
synced 2026-01-14 07:39:37 +00:00
Include undefined symbols in the symbol table for listing purposes.
MACRO11 V05.05 does this:
```
.MAIN. MACRO V05.05 Sunday 18-APR-2021 16:29 Page 1
1
2 000000 012700 000000G mov #lab1,r0
3
4 .dsabl gbl
5
U 6 000004 012700 000000 mov #lab2,r0
7
8 000001 .end
.MAIN. MACRO V05.05 Sunday 18-APR-2021 16:29 Page 1-1
Symbol table
LAB1 = ****** GX LAB2 = ******
. ABS. 000000 000 (RW,I,GBL,ABS,OVR)
000010 001 (RW,I,LCL,REL,CON)
Errors detected: 1
*** Assembler statistics
Work file reads: 0
Work file writes: 0
Size of work file: 34 Words ( 1 Pages)
Size of core pool: 9260 Words ( 35 Pages)
Operating system: RSX-11M/M-PLUS
Elapsed time: 00:00:00.01
GBL,GBL/-SP=GBL
```
This commit is contained in:
parent
d0445ef8f4
commit
7bbcbba5f5
@ -800,12 +800,12 @@ static int assemble(
|
||||
if (!label) {
|
||||
report(stack->top, "Missing .(I)IF condition\n");
|
||||
} else if (strcmp(label, "DF") == 0) {
|
||||
value = parse_expr(cp, EVALUATE_UNDEF);
|
||||
value = parse_expr(cp, EVALUATE_DEFINEDNESS);
|
||||
cp = value->cp;
|
||||
ok = eval_defined(value);
|
||||
free_tree(value);
|
||||
} else if (strcmp(label, "NDF") == 0) {
|
||||
value = parse_expr(cp, EVALUATE_UNDEF);
|
||||
value = parse_expr(cp, EVALUATE_DEFINEDNESS);
|
||||
cp = value->cp;
|
||||
ok = eval_undefined(value);
|
||||
free_tree(value);
|
||||
|
||||
@ -194,7 +194,8 @@ unsigned get_register(
|
||||
|
||||
/*
|
||||
implicit_gbl is a self-recursive routine that adds undefined symbols
|
||||
to the "implicit globals" symbol table.
|
||||
to the "implicit globals" symbol table, or alternatively adds the
|
||||
symbol as an UNDEFINED symbol.
|
||||
*/
|
||||
|
||||
void implicit_gbl(
|
||||
@ -203,15 +204,18 @@ void implicit_gbl(
|
||||
if (pass)
|
||||
return; /* Only do this in first pass */
|
||||
|
||||
if (!enabl_gbl)
|
||||
return; /* Option not enabled, don't do it. */
|
||||
|
||||
switch (value->type) {
|
||||
case EX_UNDEFINED_SYM:
|
||||
{
|
||||
if (!(value->data.symbol->flags & SYMBOLFLAG_LOCAL)) { /* Unless it's a
|
||||
local symbol, */
|
||||
add_sym(value->data.symbol->label, 0, SYMBOLFLAG_GLOBAL, &absolute_section, &implicit_st);
|
||||
if (enabl_gbl) {
|
||||
/* Either make the undefined symbol into an implicit global */
|
||||
add_sym(value->data.symbol->label, 0, SYMBOLFLAG_GLOBAL, &absolute_section, &implicit_st);
|
||||
} else {
|
||||
/* or add it to the symbol table, purely for listing purposes. */
|
||||
add_sym(value->data.symbol->label, 0, SYMBOLFLAG_UNDEFINED, &absolute_section, &symbol_st);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -323,6 +327,11 @@ int complex_tree(
|
||||
{
|
||||
SYMBOL *sym = tree->data.symbol;
|
||||
|
||||
/* This check may not be needed; so far it made no difference. */
|
||||
if (sym->flags & SYMBOLFLAG_UNDEFINED) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((sym->flags & (SYMBOLFLAG_GLOBAL | SYMBOLFLAG_DEFINITION)) == SYMBOLFLAG_GLOBAL) {
|
||||
text_complex_global(tx, sym->label);
|
||||
} else {
|
||||
|
||||
6
extree.c
6
extree.c
@ -281,7 +281,7 @@ EX_TREE *evaluate(
|
||||
|
||||
/* Change some symbols to "undefined" */
|
||||
|
||||
if (flags & EVALUATE_UNDEF) {
|
||||
if (flags & EVALUATE_DEFINEDNESS) {
|
||||
int change = 0;
|
||||
|
||||
/* I'd prefer this behavior, but MACRO.SAV is a bit too primitive. */
|
||||
@ -296,6 +296,10 @@ EX_TREE *evaluate(
|
||||
if ((sym->flags & (SYMBOLFLAG_GLOBAL | SYMBOLFLAG_DEFINITION)) == SYMBOLFLAG_GLOBAL)
|
||||
change = 1;
|
||||
|
||||
/* A symbol marked as undefined is undefined */
|
||||
if (sym->flags & SYMBOLFLAG_UNDEFINED)
|
||||
change = 1;
|
||||
|
||||
if (change) {
|
||||
res = new_temp_sym(tp->data.symbol->label, tp->data.symbol->section,
|
||||
tp->data.symbol->value);
|
||||
|
||||
2
extree.h
2
extree.h
@ -69,6 +69,6 @@ EX_TREE *evaluate(
|
||||
EX_TREE *tp,
|
||||
int flags);
|
||||
|
||||
#define EVALUATE_UNDEF 1
|
||||
#define EVALUATE_DEFINEDNESS 1
|
||||
|
||||
#endif
|
||||
|
||||
@ -205,6 +205,7 @@ void prepare_pass(int this_pass, STACK *stack, int nr_files, char **fnames)
|
||||
enabl_lcm = 0;
|
||||
enabl_lsb = 0;
|
||||
enabl_ama = opt_enabl_ama;
|
||||
enabl_gbl = 1;
|
||||
}
|
||||
|
||||
int main(
|
||||
|
||||
8
parse.c
8
parse.c
@ -1133,7 +1133,7 @@ EX_TREE *parse_unary(
|
||||
sym = lookup_sym(label, &system_st);
|
||||
}
|
||||
|
||||
if (sym != NULL) {
|
||||
if (sym != NULL && !(sym->flags & SYMBOLFLAG_UNDEFINED)) {
|
||||
tp = new_ex_tree();
|
||||
tp->cp = cp;
|
||||
tp->type = EX_SYM;
|
||||
@ -1144,7 +1144,11 @@ EX_TREE *parse_unary(
|
||||
}
|
||||
|
||||
/* The symbol was not found. Create an "undefined symbol"
|
||||
reference. */
|
||||
reference. These symbols are freed in free_tree(),
|
||||
in contrast to the symbol used in EX_SYM.
|
||||
implicit_gbl() will either make it an implicit global,
|
||||
or an undefined non-global symbol.
|
||||
*/
|
||||
sym = memcheck(malloc(sizeof(SYMBOL)));
|
||||
sym->label = label;
|
||||
sym->flags = SYMBOLFLAG_UNDEFINED | local;
|
||||
|
||||
@ -208,7 +208,10 @@ SYMBOL *add_sym(
|
||||
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);
|
||||
return sym;
|
||||
}
|
||||
/* Check for compatible definition */
|
||||
else if (sym->section == section && sym->value == value) {
|
||||
sym->flags |= flags; /* Merge flags quietly */
|
||||
|
||||
@ -16,6 +16,7 @@ TESTS="test-asciz \
|
||||
test-enabl-lcm \
|
||||
test-endm \
|
||||
test-float \
|
||||
test-gbl \
|
||||
test-if \
|
||||
test-impword \
|
||||
test-include \
|
||||
|
||||
26
tests/test-gbl.lst.ok
Normal file
26
tests/test-gbl.lst.ok
Normal file
@ -0,0 +1,26 @@
|
||||
1 ;;;;
|
||||
2 ;
|
||||
3 ; Test that .dsabl gbl at the end of the source does not carry
|
||||
4 ; over to the beginning of the next pass.
|
||||
5 ; This is actually guaranteed automatically, since it is used in pass 1 only.
|
||||
6 ; The symbol should however be entered into the symbol table as UNKNOWN.
|
||||
7 ;
|
||||
8
|
||||
9 000000 012700 000000G mov #lab1,r0 ; ok: implicitly global (imported)
|
||||
10 .dsabl gbl
|
||||
test-gbl.mac:11: ***ERROR Invalid expression (complex relocation)
|
||||
11 000004 012700 000000 mov #lab2,r0 ; error: undefined
|
||||
12
|
||||
13 .end
|
||||
13
|
||||
|
||||
|
||||
Symbol table
|
||||
|
||||
. ******R 001 LAB1 = ****** GX LAB2 = ******
|
||||
|
||||
|
||||
Program sections:
|
||||
|
||||
. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV)
|
||||
000010 001 (RW,I,LCL,REL,CON,NOSAV)
|
||||
13
tests/test-gbl.mac
Normal file
13
tests/test-gbl.mac
Normal file
@ -0,0 +1,13 @@
|
||||
;;;;
|
||||
;
|
||||
; Test that .dsabl gbl at the end of the source does not carry
|
||||
; over to the beginning of the next pass.
|
||||
; This is actually guaranteed automatically, since it is used in pass 1 only.
|
||||
; The symbol should however be entered into the symbol table as UNKNOWN.
|
||||
;
|
||||
|
||||
mov #lab1,r0 ; ok: implicitly global (imported)
|
||||
.dsabl gbl
|
||||
mov #lab2,r0 ; error: undefined
|
||||
|
||||
.end
|
||||
Loading…
x
Reference in New Issue
Block a user