Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site axiom.UUCP
Path: utzoo!linus!axiom!smk
From: smk@axiom.UUCP (Steven M. Kramer)
Newsgroups: net.wanted,net.micro.68k
Subject: Re: MIT 68000 C cross compiler bugs
Message-ID: <496@axiom.UUCP>
Date: Tue, 21-Feb-84 23:31:04 EST
Article-I.D.: axiom.496
Posted: Tue Feb 21 23:31:04 1984
Date-Received: Wed, 22-Feb-84 04:44:16 EST
References: <194@dutesta.UUCP> <492@axiom.UUCP> <493@axiom.UUCP>
Organization: Axiom Technology, Newton MA
Lines: 34

Another bug in the MIT compiler is that it tries to handle switch
statements a little TOO fancy.  In a switch where the case values are
ordered and each next case is an increment of 1 (thereby making a
nice sequential range) [I forget if it has to start at 0 or not],
it generates a jump table rather than if-then code.  However, the
computation to decide what to use in the switch table is hard coded
to assume the table is right after the decision code.  An optimizer will
move the table around and the hard coded assembler is no longer
valid.  I haven't written the fix (which should use the label right
before the switch table rather than the hardcoded 6 offset from the pc)
yet, but it belongs in genswitch() in code.c and involves replacing the movw
and jmp statements with non-hardcoded assembler that uses the label
generated next (so the getlab() should be done before the movw
so it is available then and swlab is used below without another call to
getlab()).

	To get rid of the bug temporarily, you can simple comment out the
if (range ...
statement (which is most of the routine).  This fixes everything, albeit
the code is now not optimal.

	Whoever fixes the bug must also remember the if (range ...) statement
depends on the number of instructions in the fix, because of the fix is 10
lines long, the range check should be altered.

	If someone fixes this (it shouldn't take too long but I'm new to the
68000 and I would rather have a pro generate the best instructions here),
please send me the fixes.

	Credit goes to Mike Larson who discoved the bug.
-- 
	--steve kramer
	{allegra,genrad,ihnp4,utzoo,philabs,uw-beaver}!linus!axiom!smk	(UUCP)
	linus!axiom!smk@mitre-bedford					(MIL)