mirror of
https://github.com/open-simh/simtools.git
synced 2026-02-26 16:54:31 +00:00
Change delimiters of local symbol blocks to be more like page 3-10 of the manual.
Also, to make Kermit sources work, only increase the local symbol block counter if there actually was a local symbol used in the block. This way, conditional inclusions (which include source text only in the first pass) will have less potential for de-synchronisation between the passes. After all, if the generated internal local symbol names do not match, phase errors will result (showing themselves as strange label redefinition problems).
This commit is contained in:
38
assemble.c
38
assemble.c
@@ -126,8 +126,9 @@ static int assemble(
|
||||
free(label);
|
||||
|
||||
/* See if local symbol block should be incremented */
|
||||
if (!enabl_lsb && !local)
|
||||
lsb++;
|
||||
if (!enabl_lsb && !local) {
|
||||
lsb = get_next_lsb();
|
||||
}
|
||||
|
||||
cp = skipwhite(ncp);
|
||||
opcp = cp;
|
||||
@@ -358,6 +359,9 @@ static int assemble(
|
||||
return 0;
|
||||
} else {
|
||||
go_section(tr, sect_stack[sect_sp]);
|
||||
if (!enabl_lsb) {
|
||||
lsb = get_next_lsb();
|
||||
}
|
||||
sect_sp--;
|
||||
}
|
||||
return 1;
|
||||
@@ -647,7 +651,7 @@ static int assemble(
|
||||
enabl_ama = 1;
|
||||
else if (strcmp(label, "LSB") == 0) {
|
||||
enabl_lsb = 1;
|
||||
lsb++;
|
||||
lsb = get_next_lsb();
|
||||
} else if (strcmp(label, "GBL") == 0)
|
||||
enabl_gbl = 1;
|
||||
free(label);
|
||||
@@ -661,9 +665,10 @@ static int assemble(
|
||||
label = get_symbol(cp, &cp, NULL);
|
||||
if (strcmp(label, "AMA") == 0)
|
||||
enabl_ama = 0;
|
||||
else if (strcmp(label, "LSB") == 0)
|
||||
else if (strcmp(label, "LSB") == 0) {
|
||||
lsb = get_next_lsb();
|
||||
enabl_lsb = 0;
|
||||
else if (strcmp(label, "GBL") == 0)
|
||||
} else if (strcmp(label, "GBL") == 0)
|
||||
enabl_gbl = 0;
|
||||
free(label);
|
||||
cp = skipdelim(cp);
|
||||
@@ -882,6 +887,9 @@ static int assemble(
|
||||
return 1;
|
||||
|
||||
case P_ASECT:
|
||||
if (!enabl_lsb) {
|
||||
lsb = get_next_lsb();
|
||||
}
|
||||
go_section(tr, &absolute_section);
|
||||
return 1;
|
||||
|
||||
@@ -993,6 +1001,9 @@ static int assemble(
|
||||
}
|
||||
}
|
||||
|
||||
if (!enabl_lsb) {
|
||||
lsb = get_next_lsb();
|
||||
}
|
||||
go_section(tr, sect);
|
||||
|
||||
return 1;
|
||||
@@ -1534,6 +1545,23 @@ static int assemble(
|
||||
return do_word(stack, tr, cp, 2);
|
||||
}
|
||||
|
||||
int get_next_lsb(
|
||||
void)
|
||||
{
|
||||
if (lsb_used) {
|
||||
lsb_used = 0;
|
||||
if (enabl_debug && lstfile) {
|
||||
fprintf(lstfile, "get_next_lsb: lsb: %d becomes %d (= next_lsb)\n", lsb, next_lsb);
|
||||
}
|
||||
return next_lsb++;
|
||||
} else {
|
||||
if (enabl_debug && lstfile) {
|
||||
fprintf(lstfile, "get_next_lsb: lsb: stays %d\n", lsb);
|
||||
}
|
||||
return lsb;
|
||||
}
|
||||
}
|
||||
|
||||
/* assemble_stack assembles the input stack. It returns the error
|
||||
count. */
|
||||
|
||||
|
||||
@@ -13,5 +13,7 @@
|
||||
int assemble_stack(
|
||||
STACK *stack,
|
||||
TEXT_RLD *tr);
|
||||
int get_next_lsb(
|
||||
void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,9 @@ int radix = 8; /* The current input conversion radix */
|
||||
|
||||
|
||||
int lsb = 0; /* The current local symbol section identifier */
|
||||
int last_lsb = 0; /* The last block in which a macro
|
||||
int lsb_used = 0; /* Whether there was a local symbol using this lsb */
|
||||
int next_lsb = 0; /* The number of the next local symbol block */
|
||||
int last_macro_lsb = 0; /* The last block in which a macro
|
||||
automatic label was created */
|
||||
|
||||
int last_locsym = 32768; /* The last local symbol number generated */
|
||||
|
||||
@@ -28,7 +28,9 @@ extern int pass; /* The current assembly pass. 0 = first pass */
|
||||
extern int stmtno; /* The current source line number */
|
||||
extern int radix; /* The current input conversion radix */
|
||||
extern int lsb; /* The current local symbol section identifier */
|
||||
extern int last_lsb; /* The last block in which a macro
|
||||
extern int lsb_used; /* Whether there was a local symbol using this lsb */
|
||||
extern int next_lsb; /* The number of the next local symbol block */
|
||||
extern int last_macro_lsb; /* The last block in which a macro
|
||||
automatic label was created */
|
||||
|
||||
extern int last_locsym; /* The last local symbol number generated */
|
||||
|
||||
@@ -322,7 +322,9 @@ int main(
|
||||
pass = 0;
|
||||
stmtno = 0;
|
||||
lsb = 0;
|
||||
last_lsb = -1;
|
||||
next_lsb = 1;
|
||||
lsb_used = 0;
|
||||
last_macro_lsb = -1;
|
||||
last_locsym = 32767;
|
||||
last_cond = -1;
|
||||
sect_sp = -1;
|
||||
@@ -370,7 +372,9 @@ int main(
|
||||
pass = 1;
|
||||
stmtno = 0;
|
||||
lsb = 0;
|
||||
last_lsb = -1;
|
||||
next_lsb = 1;
|
||||
lsb_used = 0;
|
||||
last_macro_lsb = -1;
|
||||
last_locsym = 32767;
|
||||
pop_cond(-1);
|
||||
sect_sp = -1;
|
||||
|
||||
4
macros.c
4
macros.c
@@ -462,11 +462,11 @@ STREAM *expandmacro(
|
||||
/* Now go back and fill in defaults */ {
|
||||
int locsym;
|
||||
|
||||
if (last_lsb != lsb)
|
||||
if (last_macro_lsb != lsb)
|
||||
locsym = last_locsym = 32768;
|
||||
else
|
||||
locsym = last_locsym;
|
||||
last_lsb = lsb;
|
||||
last_macro_lsb = lsb;
|
||||
|
||||
for (macarg = mac->args; macarg != NULL; macarg = macarg->next) {
|
||||
arg = find_arg(args, macarg->label);
|
||||
|
||||
6
parse.c
6
parse.c
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "util.h"
|
||||
#include "rad50.h"
|
||||
#include "listing.h"
|
||||
#include "assemble_globals.h"
|
||||
|
||||
|
||||
@@ -510,10 +511,15 @@ char *get_symbol(
|
||||
char *newsym = memcheck(malloc(32)); /* Overkill */
|
||||
|
||||
sprintf(newsym, "%ld$%d", strtol(symcp, NULL, 10), lsb);
|
||||
if (enabl_debug && lstfile) {
|
||||
fprintf(lstfile, "lsb %d: %s -> %s\n",
|
||||
lsb, symcp, newsym);
|
||||
}
|
||||
free(symcp);
|
||||
symcp = newsym;
|
||||
if (islocal)
|
||||
*islocal = SYMBOLFLAG_LOCAL;
|
||||
lsb_used++;
|
||||
} else {
|
||||
free(symcp);
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user