Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!cornell!batcomputer!braner From: braner@batcomputer.TN.CORNELL.EDU (braner) Newsgroups: net.micro.amiga,net.micro.atari16 Subject: Re: C compiler bugs Message-ID: <678@batcomputer.TN.CORNELL.EDU> Date: Mon, 21-Jul-86 18:39:23 EDT Article-I.D.: batcompu.678 Posted: Mon Jul 21 18:39:23 1986 Date-Received: Thu, 24-Jul-86 00:34:06 EDT References: <888@ucbcad.BERKELEY.EDU> Reply-To: braner@batcomputer.UUCP (braner) Organization: Theory Center, Cornell University, Ithaca NY Lines: 194 Xref: mnetor net.micro.amiga:3972 net.micro.atari16:1363 [] Yes, nobody seems to get floating-point right!! I am very disgusted because I'm into scientific computation. I am very anxious to see a FP chip connected to the ST!! I am here reposting a fix to the Megamax FP comparision bug. Since I've done this it has worked fine. But beware: Megamax gives you NO error messages upon division-by-0 and similar errors - you just get garbage, and occasionally crashes. ---------------------------------------------------------------- I took a close look, using the mmdis disassembler, at the double.o file (extracted from the double.l library with the mmlib program.) Only one (1) byte is wrong, looks like a typo. In the routine _fcom, where it says BSET #31,D1 it should say D2. To patch it, use the following 'bth' and 'htb' programs: Bth.prg translates the bytes of any file into both hex and ASCII representation. The output can be edited on any text editor, and then fed into the htb program to get it back into binary. (Only the hex part needs to be changed, the ASCII part is treated as a comment.) (Yes, Virginia, there is no way to assemble the output of mmdis!) In this case, tell bth.prg to read double.l. In the output file, look (on line 47) for the sequence "46 82 46 83 08 C1". Change the C1 to C2. Run it through htb.prg to create newdbl.l, and your done. From now on, mmlink yourprog.o newdbl.l. You can fix the single-precision float.o in syslib the same way - look for the same sequence and do the same change. -------------------------------------------------------------------- /* BTH - a program to create a hex file from a binary file. by Moshe braner, 860613. */ #include #define hinibble(b) (((b)>>4) & 0x0F) #define lonibble(b) ((b) & 0x0F) #define tohex(b) ((b)<0xA ? ((b)+'0') : ((b)-0xA+'A')) main() { register int c, b, i, t; int n, m; FILE *infp, *outfp; char infname[80], outfname[80]; char col[16]; printf("\n\nBinary To Hex conversion program. MB 8606.\n\n"); printf("Enter name of source file: ",stdout); gets(infname); /* open file with "br" to avoid skipping of '\r's by Megamax library */ if ((infp=fopen(infname,"br")) == NULL) { printf("cannot open source file!\n"); exit(0); } printf("Enter name of output file: "); gets(outfname); if ((outfp=fopen(outfname,"w")) == NULL) { printf("cannot open output file!\n"); exit(0); } m = 0; for (n=0; ; n++) { b=getc(infp); if (b != EOF) col[m++] = b; if ((b==EOF && m>0) || m>=16) { for (i=0; i=' ' && c<='~') putc(c, outfp); else putc('.', outfp); } putc('\n', outfp); m = 0; } if (b == EOF) break; } printf("\nRead and translated %d bytes.\n", n); } ------------------------------------------------------------------ /* HTB - program to create a binary file from a hex file. by Moshe braner, 860606. */ #include #define ishex(c) ((c>='0'&&c<='9')||(c>='A'&&c<='F')||(c>='a'&&c<='f')) /* the following macro assumes ishex(c) and ASCII: */ #define hexval(c) ((c<'A')?(c-'0'):((c<'a')?(c-'A'+0xA):(c-'a'+0xA))) main() { register int c, b, n; FILE *infp, *outfp; char infname[80], outfname[80]; printf("\n\nHex To Binary conversion program. MB 8606.\n\n"); printf("Enter name of source file: ",stdout); gets(infname); if ((infp=fopen(infname,"r")) == NULL) { printf("cannot open source file!\n"); exit(0); } printf("Enter name of output file: "); gets(outfname); /* open file with "bw" to avoid translation of '\n's to \r\n by Megamax library */ if ((outfp=fopen(outfname,"bw")) == NULL) { printf("cannot open output file!\n"); exit(0); } n = 0; while ((c=getc(infp)) != EOF) { /* rest of line after '*' is a comment: */ if (c == '*') { while ((c=getc(infp)) != '\n' && c != EOF); continue; } /* read one or two characters for one output byte: */ if (ishex(c)) { b = hexval(c); if ((c=getc(infp)) == EOF) break; if (ishex(c)) b = 16*b + hexval(c); if (putc(b,outfp) != b) { printf("error writing file!\n"); exit(0); } n++; } } printf("\nWrote %d bytes.\n", n); } -------------------------------------------------------------------- Another Megamax bug: after you open a file for reading using fopen("r"), you SOMETIMES get some extra garbage at the end of the file. It is some characters that appear near the end of the file, repeated in a garbled order. I got around it by using fopen("br") and doing the CRLF-->LF conversion myself. -------------------------------------------------------------------- While we're at it, did anybody find out how to get IO redirection to work right for C programs compiled with Megamax and used under Micro C-Shell? (Even though it works when using a program as .ttp from the desk top, the same program when invoked from microcsh as "progname > outfile" gives two bombs.) Somebody from Megamax posted a claim that it works, but it does NOT! (I use a 1040STf, completely off a (RA)M-disk. Monochrome.) I wrote Megamax (twice) and Beckemeyer, but got no answers. I also wish microcsh was not so DRI oriented - e.g. 'echo' is a separate program on disk, but a DRI-specific 'cc' is taking up space in the microcsh core. How about having an environment variable that tells microcsh which compiler is used? (and activates the appropriate IO redirection scheme...) -------------------------------------------------------------------- - Moshe Braner Corson Hall, Cornell University, Ithaca NY 14853 (607) 272-3487 For electronic mail, my address is: braner@amvax.tn.cornell.edu (ARPANET) braner%amvax.tn.cornell.edu@WISCVM.BITNET (Bitnet) {decvax,ihnp4,cmcl2,vax135}!cornell!amvax!braner (USENET) ------------------------------------------------------------------