--- /dev/null
+head: mccpm nascom
+
+mccpm: mccpm.c
+ cc -o mccpm mccpm.c
+
+nascom: nascom.c
+ cc -o nascom nascom.c
+
+install:
+ @echo Nothing is installed
+
+clean:
+ rm nascom mccpm
+
+pr:
+ @pr `pwd`/Makefile `pwd`/mccpm.c `pwd`/nascom.c
+
+opr:
+ make pr | opr
--- /dev/null
+This directory contains files mccpm.c and nascom.c.
+The first one downloads the mc/cpm
+computer, using the standard Intel hex-dump format.
+The output appears on standard output.
+The latter does the same for the Nascom.
--- /dev/null
+/*
+ * dit programma leest een a.out file
+ * voor een kleine uP (adres space = 64K)
+ * en levert aan de standaard output een
+ * download formaat voor de MCCPM computer.
+ *
+ */
+
+#define MAXBYTE 24
+#include <stdio.h>
+char hex[] = "0123456789ABCDEF";
+FILE *fp, *fopen();
+char **s;
+int bytes, bytcnt, checksum;
+unsigned pc;
+unsigned offset;
+unsigned htou();
+
+
+main (argc,argv)
+int argc;
+char *argv[];
+ {
+ if (argc > 3)
+ fatal ("usage: %s filename [start-adres]\n",argv[0]);
+ offset = 0;
+ if (argc == 3)
+ if (!(offset = htou(argv[2])))
+ fatal ("adres error %s\n", argv[2]);
+ if ((fp = fopen (*++argv,"r")) == NULL)
+ fatal ("can't open %s\n",*argv);
+ else {
+ s = argv;
+ convert ();
+ fclose (fp);
+ }
+ }
+
+convert ()
+ {
+ int c;
+ do
+ {
+ pc = getword ();
+ pc -= offset;
+ bytes = getword ();
+ bytes = getword ();
+ while (bytes != 0)
+ {
+ bytcnt = (bytes < MAXBYTE) ? bytes : MAXBYTE;
+ bytes -= bytcnt;
+ checksum = 0;
+ Irecord ();
+ }
+ c = getc (fp);
+ ungetc (c, fp);
+ }
+ while (c != EOF);
+ printf (":00000001FF\n");
+ }
+
+
+Irecord ()
+ {
+ printf (":");
+ outbyte (bytcnt);
+ bytcnt += 4;
+ outbyte (pc >> 8);
+ outbyte (pc);
+ outbyte (0);
+ record ();
+ }
+
+
+record ()
+ {
+ while (bytcnt != 0)
+ {
+ outbyte (getbyte ());
+ pc ++;
+ }
+ outbyte (-checksum);
+ putchar ('\n');
+ putchar (0);
+ putchar (0);
+ }
+
+outbyte (b)
+int b;
+ {
+ checksum = (checksum + b) & 0xFF;
+ putchar (hex[(b>>4) & 0xF]);
+ putchar (hex[b & 0xF]);
+ -- bytcnt;
+ }
+
+getword ()
+ {
+ int c;
+ c = getbyte ();
+ return ((getbyte () << 8) | c );
+ }
+
+getbyte ()
+ {
+ int c;
+ if ((c = getc (fp)) == EOF) fatal ("end of %s\n",*s);
+ return (c);
+ }
+fatal (s,a)
+ {
+ printf (s,a);
+ exit (-1);
+ }
+
+/* convert a string of hex digits to an unsigned 16 bit number */
+
+unsigned htou(t)
+char *t;
+{
+unsigned n = 0;
+char c;
+while(c = *t++){
+ if(c >= '0' && c <= '9')
+ c -= '0';
+ else if(c >= 'a' && c <= 'f')
+ c -= 'a' - 10;
+ else if(c >= 'A' && c <= 'F')
+ c -= 'A' - 10;
+ else
+ return(0);
+ n = n * 16 + c;
+ }
+return(n);
+}
--- /dev/null
+/*
+ * Download Z80 load module into the NASCOM
+ *
+ * Johan Stevenson, Vrije Universiteit, Amsterdam
+ */
+#include <stdio.h>
+#include <assert.h>
+#include <sgtty.h>
+#include <signal.h>
+
+int check;
+int nascom = 1;
+int nl = '\037';
+int zero = 0;
+int disp = 0;
+
+char hex[] = "0123456789ABCDEF";
+
+struct sgttyb ttynormal;
+struct sgttyb ttyraw;
+int rawmode = 0;
+
+stop(code) {
+ if (rawmode)
+ stty(1, &ttynormal);
+ exit(code);
+}
+
+main(argc,argv) char **argv; {
+ register unsigned nd,pc;
+ register char *s;
+
+ while (argc > 1 && argv[1][0] == '-') {
+ switch (argv[1][1]) {
+ case 'u':
+ /* unix output */
+ nascom = 0;
+ nl = '\n';
+ break;
+ case 'e':
+ /* fill EPROM. make minimal change */
+ zero = 0xFF;
+ break;
+ case 'd':
+ /* displacement at load time */
+ disp = atoi(&argv[1][2]);
+ break;
+ }
+ argc--;
+ argv++;
+ }
+ s = "a.out";
+ if (argc == 2)
+ s = argv[1];
+ else if (argc != 1) {
+ fprintf(stderr,"usage: %s [flags] [object file]\n",argv[0]);
+ stop(-1);
+ }
+ if (freopen(s,"r",stdin) == NULL) {
+ fprintf(stderr,"%s: can't open %s\n",argv[0],s);
+ stop(-1);
+ }
+ if (nascom) {
+ signal(SIGHUP, SIG_IGN);
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, stop);
+ signal(SIGTERM, stop);
+ if (gtty(1, &ttynormal) < 0) {
+ fprintf(stderr, "no tty\n");
+ stop(-1);
+ }
+ rawmode++;
+ ttyraw = ttynormal;
+ ttyraw.sg_flags |= RAW;
+ ttyraw.sg_ispeed = B1200;
+ ttyraw.sg_ospeed = B1200;
+ stty(1, &ttyraw);
+ sleep(5);
+ }
+ for (;;) {
+ pc = get2c(stdin);
+ if (feof(stdin))
+ break;
+ nd = get2c(stdin);
+ nd = get2c(stdin);
+ if (nd > 256) {
+ fprintf(stderr,"bad format on %s\n",s);
+ stop(1);
+ }
+ while (nd > 8) {
+ data(8,pc);
+ nd -= 8;
+ pc += 8;
+ }
+ if (nd > 0)
+ data(nd,pc);
+ assert(feof(stdin) == 0);
+ }
+ putchar('.');
+ putchar(nl);
+ if (nascom)
+ sleep(5);
+ stop(0);
+}
+
+data(nd,pc) {
+ register i;
+
+ check = 0;
+ pc += disp;
+ byte(pc>>8);
+ byte(pc);
+ for (i = 0; i < nd; i++) {
+ putchar(' ');
+ byte(getc(stdin));
+ }
+ while (i < 8) {
+ putchar(' ');
+ byte(zero);
+ i++;
+ }
+ putchar(' ');
+ byte(check);
+ putchar(nl);
+}
+
+byte(b) {
+
+ check += b;
+ putchar(hex[(b>>4) & 017]);
+ putchar(hex[b & 017]);
+}
+
+get2c(f) FILE *f; {
+ register c;
+
+ c = getc(f);
+ return((getc(f) << 8) | c);
+}