1 /* $Id: nascom.c,v 2.6 1994/06/24 12:58:29 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
7 * Download Z80 load module into the NASCOM
9 * Johan Stevenson, Vrije Universiteit, Amsterdam
10 * Adapted (untested) to new ack.out format by
11 * Ceriel Jacobs, Vrije Universiteit, Amsterdam
25 char hex[] = "0123456789ABCDEF";
29 struct sgttyb ttynormal;
34 struct outsect sect[MAXSECT];
42 main(argc,argv) char **argv; {
49 while (argc > 1 && argv[1][0] == '-') {
57 /* fill EPROM. make minimal change */
61 /* displacement at load time */
62 disp = atoi(&argv[1][2]);
72 fprintf(stderr,"usage: %s [flags] [object file]\n",progname);
76 fprintf(stderr,"%s: can't open %s\n",progname,s);
80 signal(SIGHUP, SIG_IGN);
81 signal(SIGINT, SIG_IGN);
82 signal(SIGQUIT, stop);
83 signal(SIGTERM, stop);
84 if (gtty(1, &ttynormal) < 0) {
85 fprintf(stderr, "no tty\n");
90 ttyraw.sg_flags |= RAW;
91 ttyraw.sg_ispeed = B1200;
92 ttyraw.sg_ospeed = B1200;
97 if (ohead.oh_flags & HF_LINK) {
98 fprintf(stderr,"%s: %s contains unresolved references\n",progname,s);
101 rd_sect(sect, ohead.oh_nsect);
102 for (i = 0; i < ohead.oh_nsect; i++) {
104 pc = sect[i].os_base;
105 while (sect[i].os_size) {
106 unsigned int sz = 8096, fl;
107 extern char *calloc();
111 if (sz > sect[i].os_size) sz = sect[i].os_size;
112 sect[i].os_size -= sz;
113 pbuf = buf = calloc(sz, 1);
114 if (fl = sect[i].os_flen) {
115 if (fl > sz) fl = sz;
116 sect[i].os_flen -= fl;
118 rd_emit(buf, (long) fl);
121 data(8, (int) pc, buf);
127 data(sz, (int) pc, buf);
149 for (i = 0; i < nd; i++) {
166 putchar(hex[(b>>4) & 017]);
167 putchar(hex[b & 017]);
172 fprintf(stderr, "%s: Read error\n", progname);