a56: parameters of this strtol() differ from strtol() in stdlib.h - rename it to...
[linux-libre-firmware.git] / a56 / torom.c
1 /*******************************************************
2  *
3  *  a56 - a DSP56001 assembler
4  *
5  *  Written by Quinn C. Jensen
6  *  July 1990
7  *
8  *******************************************************\
9
10 /*
11  * Copyright (C) 1990-1994 Quinn C. Jensen
12  *
13  * Permission to use, copy, modify, distribute, and sell this software
14  * and its documentation for any purpose is hereby granted without fee,
15  * provided that the above copyright notice appear in all copies and
16  * that both that copyright notice and this permission notice appear
17  * in supporting documentation.  The author makes no representations
18  * about the suitability of this software for any purpose.  It is
19  * provided "as is" without express or implied warranty.
20  *
21  */
22 static char *Copyright = "Copyright (C) 1990-1994 Quinn C. Jensen";
23
24 /*
25  *  This program converts the a56.out assembler output file into
26  *  raw binary, suitable for conversion to S-records for an EPROM burner.
27  *
28  */
29
30
31 #define MAX 256
32
33 main(argc,argv)
34 int argc;
35 char *argv[];
36 {
37         char buf[MAX];
38         int curaddr = 0;
39         int line = 0;
40
41         while(gets(buf)) {
42                 char seg;
43                 int addr, data;
44                 line++;
45                 if(sscanf(buf, "%c%x%x", &seg, &addr, &data) == 3) {
46                         if(seg == 'I') {
47                                 break;
48                         } else {
49                                 if(addr < curaddr) {
50                                         fatal("%s: input line %d: can't go back\n", argv[0], line);
51                                 } else if(addr != curaddr) {
52                                         while(curaddr < addr) {
53                                                 putword(0);
54                                                 curaddr++;
55                                         }
56                                 }
57                                 putword(data);
58                                 curaddr++;
59                         }
60                 }
61         }
62 }
63
64 putword(data)
65 int data;
66 {
67         putchar(data >>  0 & 0xFF);
68         putchar(data >>  8 & 0xFF);
69         putchar(data >> 16 & 0xFF);
70 }