Skip to content

Commit e010f9f

Browse files
committed
File format to output SIMH deposit commands.
"dump -Osimh" will convert an input file to a series of SIMH deposit commands. If there is a start address, there will also be a GO command at the end.
1 parent b197001 commit e010f9f

File tree

5 files changed

+68
-1
lines changed

5 files changed

+68
-1
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 -Ilibword
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 csave-file.o hiseg-file.o
7+
tenex-file.o csave-file.o hiseg-file.o simh-file.o
88

99
LIBWORD = libword/libword.a
1010

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Most tools that work with executable programs support these formats:
5757
- TOPS-10 highseg sharable .SHR and nonsharable .HGH format.
5858
- TOPS-20 and TOPS-10 sharable save .EXE files.
5959
- TENEX sharable save .SAV files.
60+
- SIMH deposit commands; output only.
6061

6162
In addition, some mini and micro computer program formats are supported:
6263

dis.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ extern struct file_format raw_file_format;
6969
extern struct file_format rim10_file_format;
7070
extern struct file_format sblk_file_format;
7171
extern struct file_format shr_file_format;
72+
extern struct file_format simh_file_format;
7273
extern struct file_format tenex_file_format;
7374

7475
extern void usage_file_format (void);

file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ static struct file_format *file_formats[] = {
4343
&rim10_file_format,
4444
&sblk_file_format,
4545
&shr_file_format,
46+
&simh_file_format,
4647
&tenex_file_format,
4748
NULL
4849
};

simh-file.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/* Copyright (C) 2024 Lars Brinkhoff <[email protected]>
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+
/*
17+
File format to output SIMH deposit commands.
18+
19+
Converts a core image to file to a series of SIMH deposit commands.
20+
If there is a start address, there will also be a GO command at the end.
21+
*/
22+
23+
#include <stdio.h>
24+
#include <stdlib.h>
25+
#include <string.h>
26+
27+
#include "dis.h"
28+
#include "memory.h"
29+
30+
static void
31+
write_location (FILE *f, struct pdp10_memory *memory, int address)
32+
{
33+
word_t data = get_word_at (memory, address);
34+
if (data >= 0)
35+
{
36+
data &= 0777777777777LL;
37+
fprintf (f, "d %06o %012llo\n", address, data);
38+
}
39+
}
40+
41+
static void
42+
write_simh (FILE *f, struct pdp10_memory *memory)
43+
{
44+
int i;
45+
46+
/* Memory contents, as deposit commands. */
47+
for (i = 0; i <= 0777777; i++)
48+
write_location (f, memory, i);
49+
50+
/* Start. */
51+
if (start_instruction <= 0)
52+
;
53+
else if (((start_instruction & 0777000000000LL) == JRST) ||
54+
start_instruction <= 0777777)
55+
fprintf (f, "go %06llo\n", start_instruction & 0777777);
56+
else
57+
fprintf (f, ";execute %012llo\n", start_instruction);
58+
}
59+
60+
struct file_format simh_file_format = {
61+
"simh",
62+
NULL,
63+
write_simh
64+
};

0 commit comments

Comments
 (0)