The assembler can say where everything ended up

-S writes every label and the address it was given, in address order.

Nothing else knows that. A program on the disk is bytes; the monitor can
disassemble it but has no idea what any of it is called. So counting which
addresses a program calls says a great deal and names nothing - the answer
arrives as a column of numbers and somebody works out by hand which routine
each one is inside.

It was deferred when the native assembler was planned, as a listing and symbol
dump nobody needed yet. Finding out where the assembler spends its time is what
needed it: the top six call targets were addresses until this existed and are
numStep, numCompare, tokGet, srcNext, numAddByte and clsSameName with it.

Sorted by address rather than by name, because the question asked of it is
always "what is at this address".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-25 18:15:50 -04:00
co-authored by Claude Opus 5
parent af0360128b
commit 19ab36a201
4 changed files with 64 additions and 1 deletions
+12 -1
View File
@@ -102,6 +102,7 @@ void printUsage(const char *programName) {
printf(" -o <file> Write the output to this path instead of alongside the source.\n");
printf(" -I <dir> Look in this directory for included files. May be given more than once.\n");
printf(" -M <file> Write the source files this output depends on, as a make rule.\n");
printf(" -S <file> Write every label and the address it was given, in address order.\n");
printf(" -h, --help Display this help message.\n");
}
@@ -171,15 +172,17 @@ int main(int argc, char *argv[]) {
{"output", required_argument, 0, 'o'},
{"include", required_argument, 0, 'I'},
{"depend", required_argument, 0, 'M'},
{"symbols", required_argument, 0, 'S'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0 }
};
char *outputFileName = NULL;
char *dependencyFileName = NULL;
char *symbolFileName = NULL;
int option_index = 0;
int opt;
while ((opt = getopt_long(argc, argv, "o:I:M:h", long_options, &option_index)) != -1) {
while ((opt = getopt_long(argc, argv, "o:I:M:S:h", long_options, &option_index)) != -1) {
switch (opt) {
case 'o':
outputFileName = strdup(optarg);
@@ -190,6 +193,9 @@ int main(int argc, char *argv[]) {
case 'M':
dependencyFileName = strdup(optarg);
break;
case 'S':
symbolFileName = strdup(optarg);
break;
case 'h':
printUsage(argv[0]);
return 0;
@@ -249,6 +255,11 @@ int main(int argc, char *argv[]) {
writeDependencyFile(dependencyFileName, outputFileName);
free(dependencyFileName);
}
// Before the cleanup, which is what frees the label table this reads.
if (symbolFileName) {
writeSymbolFile(symbolFileName);
free(symbolFileName);
}
assemblerCleanup(intermediateArray, index, outputFileName);
return 0;
}