Changed to ANSI C prototypes. Removed Amiga/Manx C hacks.

This commit is contained in:
Eric Smith 2003-09-12 05:05:44 +00:00
parent e6e1e0ba2b
commit 286e07ab31
5 changed files with 55 additions and 91 deletions

35
dis.h
View File

@ -10,12 +10,8 @@ enum boot_mode { UNKNOWN, RAW_BINARY, ATARI_LOAD, C64_LOAD, ATARI_BOOT };
extern int base_address, vector_address;
extern int asmout;
#ifndef AMIGA
extern unsigned char f[];
extern unsigned char d[];
#else
extern unsigned char *d,*f;
#endif
#define getword(x) (d[x] + (d[x+1] << 8))
#define getbyte(x) (d[x])
@ -100,3 +96,34 @@ typedef union {
} VALUE;
extern VALUE token;
/* in scanner generated from lex.l: */
int yylex (void);
/* in initopts.c: */
void initopts (int argc, char *argv[]);
/* in print.c: */
void dumpitout (void);
int pchar (int c);
char *lname (int i);
int print_label (int i);
void print_bytes (int addr);
int print_inst(int addr);
int print_data (int i);
void print_refs (void);
/* in ref.c: */
void save_ref (int refer, int refee);
void save_name (int loc, char *name);
/* in main.c: */
void crash (char *p) __attribute__ ((noreturn));
void get_predef (void);
void loadboot (void);
void loadfile (void);
void c64loadfile (void);
void binaryloadfile (void);

View File

@ -6,6 +6,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include "dis.h"
@ -32,9 +33,7 @@ void usage (void)
exit (1);
}
initopts(argc,argv)
int argc;
char *argv[];
void initopts (int argc, char *argv[])
{
int ai;
char *ca;

55
main.c
View File

@ -26,13 +26,9 @@ int jtab2_count = 0;
VALUE token;
#ifdef AMIGA
unsigned char *d,*f; /* Manx has a bug preventing us from declaring arrays >64K */
extern unsigned char *calloc();
#else
unsigned char d[0x10000]; /* The data */
unsigned char f[0x10000]; /* Flags for memory usage */
#endif
#define RUNLOC 0x2e0
#define INITLOC 0x2e2
@ -43,10 +39,6 @@ void crash (char *p)
fprintf(stderr, "%s: %s\n", progname, p);
if (cur_file != NULL)
fprintf(stderr, "Line %d of %s\n", lineno+1, cur_file);
#ifdef AMIGA
free(d);
free(f);
#endif
exit(1);
}
@ -211,17 +203,8 @@ void do_jtab2 (void)
main(argc, argv)
int argc;
char *argv[];
int main (int argc, char *argv[])
{
int i;
#ifdef AMIGA
d = calloc(0x10000,1);
f = calloc(0x10000,1);
#endif
initopts(argc, argv);
if (npredef > 0) {
cur_file = predef[0];
@ -256,20 +239,11 @@ f = calloc(0x10000,1);
dumpitout();
#ifdef AMIGA
free(d);
free(f);
#endif
exit(0);
}
get_predef()
void get_predef (void)
{
int loc;
int size;
@ -370,7 +344,7 @@ get_predef()
}
}
loadboot()
void loadboot (void)
{
struct boot_hdr {
unsigned char flags;
@ -391,11 +365,6 @@ loadboot()
if (!fp) {
fprintf(stderr, "Cant open %s\n", file);
#ifdef AMIGA
free(d);
free(f);
#endif
exit(1);
}
@ -415,7 +384,7 @@ free(f);
}
loadfile()
void loadfile (void)
{
FILE *fp;
int base_addr;
@ -430,11 +399,6 @@ loadfile()
if (!fp) {
fprintf(stderr, "Cant open %s\n", file);
#ifdef AMIGA
free(d);
free(f);
#endif
exit(1);
}
for(;;) {
@ -488,7 +452,7 @@ free(f);
}
c64loadfile()
void c64loadfile (void)
{
FILE *fp;
unsigned int base_addr,i;
@ -499,11 +463,6 @@ c64loadfile()
if (!fp) {
fprintf(stderr, "Cant open %s\n", file);
#ifdef AMIGA
free(d);
free(f);
#endif
exit(1);
}
@ -519,7 +478,7 @@ c64loadfile()
}
binaryloadfile()
void binaryloadfile (void)
{
FILE *fp;
unsigned int i;

38
print.c
View File

@ -1,12 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <unistd.h>
#include "dis.h"
char *strcpy();
char *strcat();
dumpitout()
void dumpitout (void)
{
int i;
@ -52,17 +56,14 @@ dumpitout()
print_refs();
}
pchar(c)
int c;
int pchar (int c)
{
if (isascii(c) && isprint(c))
return(c);
return('.');
}
char *
lname(i)
int i;
char *lname (int i)
{
static char buf[20];
char t;
@ -96,7 +97,7 @@ int i;
return (buf);
}
print_label(i)
int print_label (int i)
{
if (f[i] & (NAMED | JREF | SREF | DREF))
{
@ -107,8 +108,7 @@ print_label(i)
return (0);
}
print_bytes(addr)
int addr;
void print_bytes (int addr)
{
register struct info *ip;
@ -133,8 +133,7 @@ int addr;
}
print_inst(addr)
int addr;
int print_inst(int addr)
{
int opcode;
register struct info *ip;
@ -201,7 +200,7 @@ int addr;
}
print_data(i)
int print_data (int i)
{
int count;
int j;
@ -233,7 +232,7 @@ print_data(i)
return (count);
}
print_refs()
void print_refs (void)
{
char tname[50];
char cmd[200];
@ -242,13 +241,8 @@ print_refs()
register int i;
int npline;
#ifndef AMIGA
(void)sprintf(tname, "dis.%d", getpid());
(void)sprintf(cmd, "sort %s; rm %s", tname, tname);
#else
(void)sprintf(tname, "dis.%ld", FindTask(0L));
(void)sprintf(cmd, "Sort from %s to %s", tname, &tname[3] );
#endif
fp = fopen(tname, "w");
if (!fp)
@ -285,13 +279,5 @@ print_refs()
printf("%-8s Value References\n", "Symbol");
(void)fflush (stdout);
#ifndef AMIGA
(void)system(cmd);
#else
(void)Execute(cmd,0L,0L);
(void)sprintf(cmd, "Type %s",&tname[3]);
(void)Execute(cmd,0L,Output());
DeleteFile(tname);
DeleteFile(&tname[3]);
#endif
}

13
ref.c
View File

@ -13,10 +13,7 @@ struct hashslot {
struct hashslot hashtbl[HTSIZE]; /* the hash table */
struct hashslot *
hash(loc, allocate)
int loc;
int allocate;
struct hashslot *hash (int loc, int allocate)
{
int probes;
register struct hashslot *hp;
@ -45,9 +42,7 @@ int allocate;
/*NOTREACHED*/
}
save_ref(refer, refee)
int refer;
int refee;
void save_ref (int refer, int refee)
{
struct ref_chain *rc;
struct hashslot *hp;
@ -59,9 +54,7 @@ int refee;
hp->ref = rc;
}
save_name(loc, name)
int loc;
char *name;
void save_name (int loc, char *name)
{
struct hashslot *hp;