Added misc file 'custom_bitstream.c' that creates paper tape with repeating memory...
[pdp11-bin2load] / custom_bitstream.c
/*
* © 2020 Aaron Taylor <ataylor at subgeniuskitty dot com>
* 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 <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#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);
}