2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 static char rcsid[] = "$Id: dl.c,v 2.5 1994/06/24 13:03:47 ceriel Exp $";
9 char hex[] = "0123456789ABCDEF";
12 int bytes, bytcnt, checksum;
15 struct outsect sect[MAXSECT];
22 if (argc != 2) fatal ("usage: %s filename\n",argv[0]);
23 if (! rd_open (*++argv))
24 fatal ("can't open %s\n",*argv);
36 if (ohead.oh_flags & HF_LINK) {
37 fatal("%s contains unresolved references\n",s);
39 rd_sect(sect, ohead.oh_nsect);
40 for (i = 0; i < ohead.oh_nsect; i++) {
43 while (sect[i].os_size) {
44 unsigned int sz = 8096, fl;
45 extern char *calloc();
49 if (sz > sect[i].os_size) sz = sect[i].os_size;
50 sect[i].os_size -= sz;
51 pbuf = buf = calloc(sz, 1);
52 if (fl = sect[i].os_flen) {
54 sect[i].os_flen -= fl;
56 rd_emit(buf, (long) fl);
59 int p = bytcnt = sz < MAXBYTE ? sz : MAXBYTE;
70 printf ("S9030000FC\n");
80 outbyte ((int) (pc >> 16));
81 outbyte ((int) (pc >> 8));
92 outbyte ((int) (pc >> 8));
114 checksum = (checksum + b) & 0377;
115 putchar (hex[(b>>4) & 017]);
116 putchar (hex[b & 017]);
120 rd_fatal() { fatal("Read error\n"); }