From 7769ca9172101b2b1b75336ffd8856d92a2a16d1 Mon Sep 17 00:00:00 2001 From: Aaron Taylor Date: Wed, 11 Nov 2020 04:26:20 -0800 Subject: [PATCH] Added misc file 'custom_bitstream.c' that creates paper tape with repeating memory pattern. --- custom_bitstream.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 custom_bitstream.c diff --git a/custom_bitstream.c b/custom_bitstream.c new file mode 100644 index 0000000..144a5ac --- /dev/null +++ b/custom_bitstream.c @@ -0,0 +1,43 @@ +/* + * © 2020 Aaron Taylor + * See LICENSE.txt file for copyright and license details. + */ + +/* + * Outputs a file compatible with PDP-11 paper tape loader. + * File will load memory with integer counting (ex: 0, 1, 2, ..., NUMWORDS-2, NUMWORDS-1). + * Load starts at 01000 and ends at 01000 + NUMWORDS - 1. + */ + +#include +#include +#include + +#define NUMWORDS 20000 + +void main( int argc, char ** argv ) { + uint16_t * packet = malloc((2*NUMWORDS) + 16); + /* + * +16 comes from: + * 3 for start of first packet header + * 1 for first checksum plus padding byte + * 4 for second packet header + checksum on empty packet + * Then double because PDP-11 word is 2 byte. + */ + packet[0] = 1; /* Standard header */ + packet[1] = (2*NUMWORDS) + 6; /* Size of packet, including header but excluding checksum */ + packet[2] = 01000; /* Address to load packet */ + packet[NUMWORDS+3] = 0; /* Empty checksum. SIMH complains but still loads the image. */ + packet[NUMWORDS+4] = 1; /* Start of next packet, standard header */ + packet[NUMWORDS+5] = 6; /* Size of packet (just the header since blank body */ + packet[NUMWORDS+6] = 01000; /* Blank body means start execution at this address */ + packet[NUMWORDS+7] = 0; /* Empty checksum. SIMH complains but still loads the image. */ + + uint16_t i; + for(i=0; i < NUMWORDS; i++) packet[i+3] = i; /* Start at 0 so first instruction halts machine */ + + FILE * fp; + fp = fopen("testimg.pdp11","w+"); + fwrite(packet,(2*NUMWORDS)+16,1,fp); + fclose(fp); +} -- 2.20.1