--- hatari/src/uae-cpu/build68k.c 2019/04/01 07:09:16 1.1 +++ hatari/src/uae-cpu/build68k.c 2019/04/09 08:53:27 1.1.1.9 @@ -1,26 +1,28 @@ /* - * UAE - The Un*x Amiga Emulator + * UAE - The Un*x Amiga Emulator - CPU core * * Read 68000 CPU specs from file "table68k" and build table68k.c * * Copyright 1995,1996 Bernd Schmidt + * + * Adaptation to Hatari by Thomas Huth + * + * This file is distributed under the GNU General Public License, version 2 + * or at your option any later version. Read the file gpl.txt for details. */ - +const char Build68k_fileid[] = "Hatari build68k.c : " __DATE__ " " __TIME__; #include #include +#include -/* -#include "config.h" -#include "options.h" -#include "sysconfig.h" -*/ -#include "sysdeps.h" #include "readcpu.h" + static FILE *tablef; static int nextch = 0; + static void getnextch(void) { do { @@ -60,14 +62,10 @@ int main(int argc, char **argv) { int no_insns = 0; -/* - printf ("#include \"sysconfig.h\"\n"); - printf ("#include \"config.h\"\n"); - printf ("#include \"options.h\"\n"); -*/ + /*printf ("#include \"sysconfig.h\"\n");*/ printf ("#include \"sysdeps.h\"\n"); printf ("#include \"readcpu.h\"\n"); - printf ("struct instr_def defs68k[] = {\n"); + printf ("const struct instr_def defs68k[] = {\n"); #if 0 tablef = fopen("table68k","r"); if (tablef == NULL) { @@ -82,7 +80,6 @@ int main(int argc, char **argv) int cpulevel, plevel, sduse; int i; - char patbits[16]; char opcstr[256]; int bitpos[16]; int flagset[5], flaguse[5]; @@ -117,6 +114,7 @@ int main(int argc, char **argv) case 'r': currbit = bitr; break; case 'R': currbit = bitR; break; case 'z': currbit = bitz; break; + case 'p': currbit = bitp; break; default: abort(); } if (!(bitmask & 1)) { @@ -128,7 +126,6 @@ int main(int argc, char **argv) bitmask |= 1; if (nextch == '1') bitpattern |= 1; - patbits[i] = nextch; getnextch(); } @@ -165,6 +162,7 @@ int main(int argc, char **argv) switch(nextch){ case '-': flagset[i] = fa_unset; break; case '/': flagset[i] = fa_isjmp; break; + case '+': flagset[i] = fa_isbranch; break; case '0': flagset[i] = fa_zero; break; case '1': flagset[i] = fa_one; break; case 'x': flagset[i] = fa_dontcare; break; @@ -210,7 +208,11 @@ int main(int argc, char **argv) if (nextch != ':') abort(); - fgets(opcstr, 250, tablef); + if (fgets(opcstr, 250, tablef) == NULL) { + perror("fgets"); + return -1; + } + getnextch(); { int j; @@ -218,12 +220,12 @@ int main(int argc, char **argv) char *opstrp = opcstr, *osendp; int slen = 0; - while (isspace(*opstrp)) + while (isspace((unsigned)(*opstrp))) opstrp++; osendp = opstrp; while (*osendp) { - if (!isspace (*osendp)) + if (!isspace ((unsigned)(*osendp))) slen = osendp - opstrp + 1; osendp++; }