Skip to content

Commit 4383d20

Browse files
committed
TOPS-10/20 nonsharable/compressed SAVE file format.
1 parent 0b1c79d commit 4383d20

File tree

10 files changed

+13175
-4
lines changed

10 files changed

+13175
-4
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CFLAGS = -g -W -Wall
44
FILES = sblk-file.o pdump-file.o dmp-file.o raw-file.o exe-file.o \
55
mdl-file.o rim10-file.o fasl-file.o palx-file.o lda-file.o \
66
cross-file.o hex-file.o atari-file.o iml-file.o exb-file.o \
7-
tenex-file.o
7+
tenex-file.o csave-file.o
88

99
WORDS = aa-word.o bin-word.o cadr-word.o core-word.o data8-word.o \
1010
dta-word.o its-word.o oct-word.o pt-word.o sail-word.o tape-word.o \

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Most tools that work with executable programs support these formats:
4848
- Raw files.
4949
- Read-in mode.
5050
- Stanford WAITS .DMP files.
51+
- TOPS-10 and TOPS-20 nonsharable/compressed save .SAV files.
5152
- TOPS-20 and TOPS-10 sharable save .EXE files.
5253
- TENEX sharable save .SAV files.
5354

check.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ test_dis10 system.dmp "-Fdmp -Woct -mka10sail -Sall"
7373
test_dis10 dired.dmp "-6 -mka10sail -Wascii -Sddt"
7474
test_dis10 two.tapes "-r -Wtape"
7575
test_dis10 boot.exb "-Fexb -Wascii"
76+
test_dis10 cerber.sav "-Sall -Fcsave -Wascii"
7677

7778
test_itsarc arc.code
7879
test_ipak stink.-ipak-

csave-file.c

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/* Copyright (C) 2022 Lars Brinkhoff <lars@nocrew.org>
2+
3+
This program is free software: you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation, either version 2 of the License, or
6+
(at your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
16+
#include <stdio.h>
17+
#include <stdlib.h>
18+
19+
#include "dis.h"
20+
#include "memory.h"
21+
#include "symbols.h"
22+
23+
static void
24+
read_csave (FILE *f, struct pdp10_memory *memory, int cpu_model)
25+
{
26+
int address, length;
27+
word_t word;
28+
int i;
29+
30+
fprintf (output_file, "Nonsharable/compressed SAVE format\n");
31+
32+
while ((word = get_word (f)) & SIGNBIT)
33+
{
34+
word_t *data, *ptr;
35+
36+
length = 01000000 - ((word >> 18) & 0777777);
37+
address = (word & 0777777) + 1;
38+
39+
data = malloc (length * sizeof (word_t));
40+
if (data == NULL)
41+
{
42+
fprintf (stderr, "out of memory\n");
43+
exit (1);
44+
}
45+
46+
ptr = data;
47+
for (i = 0; i < length; i++)
48+
*ptr++ = get_word (f);
49+
add_memory (memory, address, length, data);
50+
}
51+
52+
length = (word >> 18) & 0777777;
53+
address = word & 0777777;
54+
55+
fprintf (output_file, "\n");
56+
dec_info (memory, length, address, cpu_model);
57+
}
58+
59+
void
60+
write_dec_symbols (struct pdp10_memory *memory)
61+
{
62+
}
63+
64+
static void
65+
write_block (FILE *f, struct pdp10_memory *memory, int address, int length)
66+
{
67+
word_t word;
68+
word = -length << 18;
69+
word |= address - 1;
70+
word &= WORDMASK;
71+
write_word (f, word);
72+
73+
while (length-- > 0)
74+
write_word (f, get_word_at (memory, address++));
75+
}
76+
77+
static void
78+
write_core (FILE *f, struct pdp10_memory *memory)
79+
{
80+
int start, length;
81+
int i, n;
82+
83+
for (i = 0; i < memory->areas; i++)
84+
{
85+
start = memory->area[i].start;
86+
length = memory->area[i].end - start;
87+
while (length > 0)
88+
{
89+
n = length > 512 ? 512 : length;
90+
write_block (f, memory, start, n);
91+
start += n;
92+
length -= n;
93+
}
94+
}
95+
}
96+
97+
static void
98+
write_csave (FILE *f, struct pdp10_memory *memory)
99+
{
100+
write_dec_symbols (memory);
101+
write_core (f, memory);
102+
write_word (f, JRST + (start_instruction & 0777777));
103+
}
104+
105+
struct file_format csave_file_format = {
106+
"csave",
107+
read_csave,
108+
write_csave
109+
};

dis.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ extern struct file_format *input_file_format;
6565
extern struct file_format *output_file_format;
6666
extern struct file_format atari_file_format;
6767
extern struct file_format cross_file_format;
68+
extern struct file_format csave_file_format;
6869
extern struct file_format dmp_file_format;
6970
extern struct file_format exb_file_format;
7071
extern struct file_format exe_file_format;
@@ -123,6 +124,7 @@ extern void write_raw_at (FILE *f, struct pdp10_memory *memory,
123124
int address);
124125
extern void write_sblk_core (FILE *f, struct pdp10_memory *memory);
125126
extern void write_sblk_symbols (FILE *f);
127+
extern void write_dec_symbols (struct pdp10_memory *memory);
126128
extern void sblk_info (FILE *f, word_t word0, int cpu_model);
127129
extern void dmp_info (struct pdp10_memory *memory, int cpu_model);
128130
extern void dec_info (struct pdp10_memory *memory,

file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct file_format *output_file_format = NULL;
2525
static struct file_format *file_formats[] = {
2626
&atari_file_format,
2727
&cross_file_format,
28+
&csave_file_format,
2829
&dmp_file_format,
2930
&exb_file_format,
3031
&fasl_file_format,

info.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,16 +562,35 @@ dec_info (struct pdp10_memory *memory,
562562

563563
if (entry_vec_addr == -1 || entry_vec_len == 0254000)
564564
{
565-
word = get_word_at (memory, JBSA) & 0777777;
565+
word = get_word_at (memory, JBREL);
566+
if (word != -1 && (word & 0777777) != 0)
567+
fprintf (output_file, "Highest lowseg location: %llo\n",
568+
word & 0777777);
569+
570+
word = get_word_at (memory, JBREL);
571+
if (GOOD (word))
572+
fprintf (output_file, "DDT from %o to %o\n",
573+
word & 0777777, (word >> 18) & 0777777);
574+
575+
word = get_word_at (memory, JBHRL);
576+
if (word != -1 && (word & 0777777) != 0)
577+
fprintf (output_file, "Highest hiseg location: %llo\n",
578+
word & 0777777);
579+
580+
if (entry_vec_addr != 0)
581+
word = entry_vec_addr;
582+
else
583+
word = get_word_at (memory, JBSA);
566584
if (GOOD (word))
567585
{
586+
word &= 0777777;
568587
fprintf (output_file, "Start address: %06llo\n", word);
569588
start_instruction = JRST + word;
570589
}
571590

572-
word = get_word_at (memory, JBREN) & 0777777;
591+
word = get_word_at (memory, JBREN);
573592
if (GOOD (word))
574-
fprintf (output_file, "Reentry address: %06llo\n", word);
593+
fprintf (output_file, "Reentry address: %06llo\n", word & 0777777);
575594

576595
word = get_word_at (memory, JBVER);
577596
if (GOOD (word))

jobdat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* Low segment job area. */
22
#define JB41 0041
3+
#define JBREL 0044
4+
#define JBDDT 0074
35
#define JBHRL 0115
46
#define JBSYM 0116
57
#define JBSA 0120

samples/cerber.sav

52.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)