Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!dogie.macc.wisc.edu!decwrl!ucbvax!ucdavis!uop!greg From: greg@uop.EDU (Greg Onufer) Newsgroups: comp.sys.m68k Subject: Re: Motorola S-Records Message-ID: <1690@uop.uop.EDU> Date: 22 Dec 89 00:28:14 GMT References: <2141@cmx.npac.syr.edu> <9128@wsucsa.uucp> Organization: University of the Pacific, Stockton, CA Lines: 97 Tohex, as posted, would not compile under SunOS 4.0. Here are the changes I made to get it to compile (I tested it a little and I am fairly sure it still works correctly, but I make no guarantees). *** tohex.c Thu Dec 21 16:22:25 1989 --- tohex.c.new Thu Dec 21 16:18:20 1989 *************** *** 49,55 **** int recsize; /* maximum data bytes/output record */ int chksum; /* output record checksum */ int toshex(), toihex(), totekhex(); /* conversion functions */ ! struct bhdr header; /* where we put the a.out header */ FILE *infile; /* input file descriptor */ main(argc, argv) --- 49,55 ---- int recsize; /* maximum data bytes/output record */ int chksum; /* output record checksum */ int toshex(), toihex(), totekhex(); /* conversion functions */ ! struct exec header; /* where we put the a.out header */ FILE *infile; /* input file descriptor */ main(argc, argv) *************** *** 65,86 **** } /* read the a.out file header */ ! if ( !fread(&header, sizeof (struct bhdr), 1, infile) ) { fprintf(stderr,"tohex: unable to read file header\n"); } ! if ( header.fmagic != FMAGIC ) { fprintf(stderr,"tohex: not an a.out file\n"); exit(1); } ! if ( header.rtsize || header.rdsize ) { fprintf(stderr, "tohex: input file not stripped\n"); exit(1); } /* print interesting trivia about the file */ ! fprintf(stderr, "entry point: %08X\n", header.entry); ! fprintf(stderr, "text size: %06X (%d)\n", header.tsize, header.tsize); ! fprintf(stderr, "data size: %06X (%d)\n", header.dsize, header.dsize); /* * if no starting address was specified use the entry --- 65,88 ---- } /* read the a.out file header */ ! if ( !fread(&header, sizeof (struct exec), 1, infile) ) { fprintf(stderr,"tohex: unable to read file header\n"); } ! if ( N_BADMAG(header) ) { fprintf(stderr,"tohex: not an a.out file\n"); exit(1); } ! if ( header.a_trsize || header.a_drsize ) { fprintf(stderr, "tohex: input file not stripped\n"); exit(1); } /* print interesting trivia about the file */ ! fprintf(stderr, "entry point: %08X\n", header.a_entry); ! fprintf(stderr, "text size: %06X (%d)\n", header.a_text, ! header.a_text); ! fprintf(stderr, "data size: %06X (%d)\n", header.a_data, ! header.a_data); /* * if no starting address was specified use the entry *************** *** 88,97 **** * appropriate for a.out files. */ if ( !oflag ) ! offset = header.entry; /* calculate size of input */ ! maxaddr = header.tsize + header.dsize; /* loop until out of input */ for ( addr= 0; addr <= maxaddr; ) { --- 90,99 ---- * appropriate for a.out files. */ if ( !oflag ) ! offset = header.a_entry; /* calculate size of input */ ! maxaddr = header.a_text + header.a_data; /* loop until out of input */ for ( addr= 0; addr <= maxaddr; ) { Cheers!greg