Skip to content

Commit

Permalink
Support for reading and writing tape errors and gaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Apr 13, 2022
1 parent a54fde6 commit d756320
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dis.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ extern void by_five_octets (FILE *f, int position);
extern void by_eight_octets (FILE *f, int position);
extern void write_word (FILE *, word_t);
extern void flush_word (FILE *);
extern void (*tape_hook) (int code);
extern int get_7track_record (FILE *f, word_t **buffer);
extern int get_9track_record (FILE *f, word_t **buffer);
extern void write_7track_record (FILE *f, word_t *buffer, int);
extern void write_9track_record (FILE *f, word_t *buffer, int);
extern void write_tape_mark (FILE *f);
extern void write_tape_eof (FILE *f);
extern void write_tape_eot (FILE *f);
extern void write_tape_gap (FILE *f, unsigned code);
extern void write_tape_error (FILE *f, unsigned code);
extern word_t get_core_word (FILE *f);
extern void write_core_word (FILE *f, word_t word);
extern void read_raw_at (FILE *f, struct pdp10_memory *memory,
Expand Down
19 changes: 19 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
#include "opcode/pdp10.h"
#include "memory.h"

static void
tape_special (int code)
{
switch ((code >> 24) & 0xFF)
{
case 0x80:
fprintf (output_file, "Tape error %06x.\n", code & 0xFFFFFF);
break;
case 0xFF:
fprintf (output_file, "Tape gap (%06x).\n", code & 0xFFFFFF);
break;
default:
fprintf (output_file, "Tape special (%08x).\n", code);
break;
}
}

static void
usage (char **argv)
{
Expand Down Expand Up @@ -93,6 +110,8 @@ main (int argc, char **argv)

init_memory (&memory);

tape_hook = tape_special;

if (!input_file_format)
guess_input_file_format (file);
input_file_format->read (file, &memory, cpu_model);
Expand Down
45 changes: 45 additions & 0 deletions tape-word.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ static int reclen = 0;
static int beginning_of_tape = 1;
static int marks = 0;

static void tape_special (int code);
static int get_tape_record (FILE *f, word_t **buffer);

void (*tape_hook) (int code) = tape_special;

static int
get_byte (FILE *f)
{
Expand Down Expand Up @@ -84,6 +89,22 @@ static void write_reclen (FILE *f, int n)
marks = 0;
}

static void tape_special (int code)
{
switch ((code >> 24) & 0xFF)
{
case 0x80:
fprintf (stderr, "Tape error %06x.\n", code & 0xFFFFFF);
break;
case 0xFF:
fprintf (stderr, "Tape gap (%06x).\n", code & 0xFFFFFF);
break;
default:
fprintf (stderr, "Tape special (%08x).\n", code);
break;
}
}

int get_9track_record (FILE *f, word_t **buffer)
{
int i, x, reclen;
Expand All @@ -92,6 +113,12 @@ int get_9track_record (FILE *f, word_t **buffer)
reclen = get_reclen (f);
if (reclen == 0)
return 0;
else if (reclen & 0x80000000)
{
tape_hook (reclen);
return get_tape_record (f, buffer);
}

if (reclen % 5)
{
fprintf (stderr, "Not a CORE DUMP tape image.\n"
Expand Down Expand Up @@ -182,6 +209,12 @@ int get_7track_record (FILE *f, word_t **buffer)
reclen = get_reclen (f);
if (reclen == 0)
return 0;
else if (reclen & 0x80000000)
{
tape_hook (reclen);
return get_tape_record (f, buffer);
}

if (reclen % 6)
{
fprintf (stderr, "Not a 7-track tape image.\n"
Expand Down Expand Up @@ -310,6 +343,18 @@ write_tape_eot (FILE *f)
write_tape_mark (f);
}

void
write_tape_gap (FILE *f, unsigned code)
{
write_reclen (f, 0xFF000000 | (code & 0xFFFFFF));
}

void
write_tape_error (FILE *f, unsigned code)
{
write_reclen (f, 0x80000000 | (code & 0xFFFFFF));
}

static void
flush_record (FILE *f)
{
Expand Down

0 comments on commit d756320

Please sign in to comment.