Skip to content

Commit 374f3bd

Browse files
committed
Support for reading and writing tape errors and gaps.
1 parent 7c96b5e commit 374f3bd

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

dis.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,16 @@ extern void check_checksum (word_t);
109109
extern void rewind_word (FILE *f);
110110
extern void write_word (FILE *, word_t);
111111
extern void flush_word (FILE *);
112+
extern void (*tape_hook) (int code);
112113
extern int get_7track_record (FILE *f, word_t **buffer);
113114
extern int get_9track_record (FILE *f, word_t **buffer);
114115
extern void write_7track_record (FILE *f, word_t *buffer, int);
115116
extern void write_9track_record (FILE *f, word_t *buffer, int);
116117
extern void write_tape_mark (FILE *f);
117118
extern void write_tape_eof (FILE *f);
118119
extern void write_tape_eot (FILE *f);
120+
extern void write_tape_gap (FILE *f, unsigned code);
121+
extern void write_tape_error (FILE *f, unsigned code);
119122
extern word_t get_core_word (FILE *f);
120123
extern void write_core_word (FILE *f, word_t word);
121124
extern void read_raw_at (FILE *f, struct pdp10_memory *memory,

main.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@
2222
#include "opcode/pdp10.h"
2323
#include "memory.h"
2424

25+
static void
26+
tape_special (int code)
27+
{
28+
switch ((code >> 24) & 0xFF)
29+
{
30+
case 0x80:
31+
fprintf (output_file, "Tape error %06x.\n", code & 0xFFFFFF);
32+
break;
33+
case 0xFF:
34+
fprintf (output_file, "Tape gap (%06x).\n", code & 0xFFFFFF);
35+
break;
36+
default:
37+
fprintf (output_file, "Tape special (%08x).\n", code);
38+
break;
39+
}
40+
}
41+
2542
static void
2643
usage (char **argv)
2744
{
@@ -93,6 +110,8 @@ main (int argc, char **argv)
93110

94111
init_memory (&memory);
95112

113+
tape_hook = tape_special;
114+
96115
if (!input_file_format)
97116
guess_input_file_format (file);
98117
input_file_format->read (file, &memory, cpu_model);

tape-word.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ static int reclen = 0;
2323
static int beginning_of_tape = 1;
2424
static int marks = 0;
2525

26+
static void tape_special (int code);
27+
static int get_tape_record (FILE *f, word_t **buffer);
28+
29+
void (*tape_hook) (int code) = tape_special;
30+
2631
static int
2732
get_byte (FILE *f)
2833
{
@@ -84,6 +89,22 @@ static void write_reclen (FILE *f, int n)
8489
marks = 0;
8590
}
8691

92+
static void tape_special (int code)
93+
{
94+
switch ((code >> 24) & 0xFF)
95+
{
96+
case 0x80:
97+
fprintf (stderr, "Tape error %06x.\n", code & 0xFFFFFF);
98+
break;
99+
case 0xFF:
100+
fprintf (stderr, "Tape gap (%06x).\n", code & 0xFFFFFF);
101+
break;
102+
default:
103+
fprintf (stderr, "Tape special (%08x).\n", code);
104+
break;
105+
}
106+
}
107+
87108
int get_9track_record (FILE *f, word_t **buffer)
88109
{
89110
int i, x, reclen;
@@ -92,6 +113,12 @@ int get_9track_record (FILE *f, word_t **buffer)
92113
reclen = get_reclen (f);
93114
if (reclen == 0)
94115
return 0;
116+
else if (reclen & 0x80000000)
117+
{
118+
tape_hook (reclen);
119+
return get_tape_record (f, buffer);
120+
}
121+
95122
if (reclen % 5)
96123
{
97124
fprintf (stderr, "Not a CORE DUMP tape image.\n"
@@ -182,6 +209,12 @@ int get_7track_record (FILE *f, word_t **buffer)
182209
reclen = get_reclen (f);
183210
if (reclen == 0)
184211
return 0;
212+
else if (reclen & 0x80000000)
213+
{
214+
tape_hook (reclen);
215+
return get_tape_record (f, buffer);
216+
}
217+
185218
if (reclen % 6)
186219
{
187220
fprintf (stderr, "Not a 7-track tape image.\n"
@@ -312,6 +345,18 @@ write_tape_eot (FILE *f)
312345
write_tape_mark (f);
313346
}
314347

348+
void
349+
write_tape_gap (FILE *f, unsigned code)
350+
{
351+
write_reclen (f, 0xFF000000 | (code & 0xFFFFFF));
352+
}
353+
354+
void
355+
write_tape_error (FILE *f, unsigned code)
356+
{
357+
write_reclen (f, 0x80000000 | (code & 0xFFFFFF));
358+
}
359+
315360
static void
316361
flush_record (FILE *f)
317362
{

0 commit comments

Comments
 (0)