2 // RMAC - Reboot's Macro Assembler for all Atari computers
3 // 68KGEN.C - Tool to Generate 68000 Opcode Table
4 // Copyright (C) 199x Landon Dyer, 2011-2020 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source utilised with the kind permission of Landon Dyer
16 int kwnum = 1; /* current op# for kwgen output */
17 FILE * kfp; /* keyword file */
20 // Function prototypes
21 void error(char *, char *);
22 void procln(int, char **);
25 int main(int argc, char ** argv)
32 if ((argc == 2) && ((kfp = fopen(argv[1], "w")) == NULL))
33 error("Cannot create: %s", argv[1]);
35 while (fgets(ln, 256, stdin) != NULL)
37 lineno++; /* bump line# */
39 if (*ln == '#') /* ignore comments */
43 * Tokenize line (like the way "argc, argv" works)
44 * and pass it to the parser.
57 while (*s && !isspace(*s))
76 void procln(int namc, char ** namv)
80 // alias for previous entry
83 fprintf(kfp, "%s\t%d\n", namv[0], kwnum - 1 + 2000);
89 fprintf(stderr, "%d: missing fields\n", lineno);
93 // output keyword name
95 fprintf(kfp, "%s\t%d\n", namv[0], kwnum + 2000);
97 printf("/*%4d %-6s*/ {", kwnum, namv[0]);
99 printf("%s, %s, %s, ", namv[1], namv[2], namv[3]);
101 // enforce little fascist percent signs
104 for(i=1, j=0; i<25; i++)
108 if (namv[4][i] == '1' || isupper(namv[4][i]))
112 printf("0x%06x, ", j);
115 printf("%s, ", namv[4]);
117 if (namc >= 7 && *namv[6] == '+')
118 printf("%d, ", kwnum + 1);
122 printf("%s},\n", namv[5]);
128 void error(char * s, char * s1)
130 fprintf(stderr, s, s1);
131 fprintf(stderr, "\n");