Skip to content

Commit 0b1c79d

Browse files
committed
In-core symbols for TOPS-10/20 save files.
1 parent 02091a2 commit 0b1c79d

File tree

2 files changed

+545
-15
lines changed

2 files changed

+545
-15
lines changed

info.c

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
#define STBFIL 2
3636
#define STBINF 3
3737

38+
/* Most metadata is not valid if all zeros or all ones. */
39+
#define GOOD(WORD) ((WORD) != -1 && \
40+
(WORD) != 0 && \
41+
(WORD) != 0777777LL && \
42+
(WORD) != 0777777777777LL)
43+
3844
word_t start_instruction;
3945
FILE *output_file;
4046

@@ -233,11 +239,13 @@ print_datime (FILE *f, word_t t)
233239
static void
234240
print_symbol (word_t word1, word_t word2)
235241
{
236-
char str[7];
242+
char str[7], *p;
237243
int flags = 0;
238244

239245
squoze_to_ascii (word1, str);
240-
fprintf (output_file, " Symbol %s = ", str);
246+
for (p = str; *p == ' '; p++)
247+
;
248+
fprintf (output_file, " Symbol %s = ", p);
241249
fprintf (output_file, "%llo (", word2);
242250

243251
if (word1 & SYHKL)
@@ -259,7 +267,7 @@ print_symbol (word_t word1, word_t word2)
259267
}
260268
fprintf (output_file, ")\n");
261269

262-
add_symbol (str, word2, flags);
270+
add_symbol (p, word2, flags);
263271
}
264272

265273
void
@@ -530,28 +538,43 @@ dmp_info (struct pdp10_memory *memory, int cpu_model)
530538
}
531539
}
532540

541+
void
542+
dec_symbols (struct pdp10_memory *memory, int address, int length)
543+
{
544+
fprintf (output_file, "Symbol table:\n");
545+
546+
while (length > 0)
547+
{
548+
word_t word1, word2;
549+
word1 = get_word_at (memory, address++);
550+
word2 = get_word_at (memory, address++);
551+
print_symbol (word1, word2);
552+
length -= 2;
553+
}
554+
}
555+
533556
void
534557
dec_info (struct pdp10_memory *memory,
535558
word_t entry_vec_len, word_t entry_vec_addr,
536559
int cpu_model)
537560
{
561+
word_t word;
562+
538563
if (entry_vec_addr == -1 || entry_vec_len == 0254000)
539564
{
540-
word_t word;
541-
542565
word = get_word_at (memory, JBSA) & 0777777;
543-
if (word != 0)
566+
if (GOOD (word))
544567
{
545568
fprintf (output_file, "Start address: %06llo\n", word);
546569
start_instruction = JRST + word;
547570
}
548571

549572
word = get_word_at (memory, JBREN) & 0777777;
550-
if (word != 0)
573+
if (GOOD (word))
551574
fprintf (output_file, "Reentry address: %06llo\n", word);
552575

553576
word = get_word_at (memory, JBVER);
554-
if (word != 0)
577+
if (GOOD (word))
555578
fprintf (output_file, "Version: %012llo\n", word);
556579
}
557580
else
@@ -572,15 +595,25 @@ dec_info (struct pdp10_memory *memory,
572595
disassemble_word (memory, get_word_at (memory, addr),
573596
addr, cpu_model);
574597

575-
fprintf (output_file, "Reentry instruction:\n");
576-
addr = entry_vec_addr + 1;
577-
disassemble_word (memory, get_word_at (memory, addr),
578-
addr, cpu_model);
579-
580-
fprintf (output_file, "Version: %012llo\n",
581-
get_word_at (memory, entry_vec_addr + 2));
598+
word = get_word_at (memory, ++addr);
599+
if (GOOD (word))
600+
{
601+
fprintf (output_file, "Reentry instruction:\n");
602+
disassemble_word (memory, word, addr, cpu_model);
603+
}
604+
605+
word = get_word_at (memory, ++addr);
606+
if (GOOD (word))
607+
{
608+
fprintf (output_file, "Version: %012llo\n", word);
609+
}
582610
}
583611
}
612+
613+
word = get_word_at (memory, 0116);
614+
if (GOOD (word))
615+
dec_symbols (memory, word & 0777777,
616+
01000000 - ((word >> 18) & 0777777));
584617
}
585618

586619
int

0 commit comments

Comments
 (0)