Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!pt.cs.cmu.edu!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.lang.c Subject: Re: Long Branches Message-ID: <531@aw.sei.cmu.edu.sei.cmu.edu> Date: Mon, 19-Jan-87 16:38:57 EST Article-I.D.: aw.531 Posted: Mon Jan 19 16:38:57 1987 Date-Received: Tue, 20-Jan-87 05:09:15 EST References: <3950006@nucsrl.UUCP> <6552@alice.uUCp> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (PUT YOUR NAME HERE) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 29 In article <6552@alice.uUCp> ark@alice.UUCP writes: >In article <3950006@nucsrl.UUCP>, ram@nucsrl.UUCP writes: >> >> I have a problem in using the C compiler and VAX assembler in our local >> 4.3BSD(VAX) site. I have a program which has a huge(>900lines) case statement. >> >> /* Whoever said that programmers(pro) don't use case/switch */ >> >> The assembler chokes on (>32K long) long branches. Apparently >> there is a flag "-J" for such purposes (in the assembler) >> which does not seem to work. > >The trouble is that a case statement does not generate jump instructions >on the VAX. Instead it generates a CASE instruction. This instruction >also comes in three flavors: byte, word, and longword offsets. It would >not be enough for the assembler to translate the CASEW the compiler >probably generates into a CASEL: the jump table must be translated from >words to longwords too. Sorry, the B/W/L forms refer to the size of the INDEX into the case statement. The displacements are always encoded as 16-bit relative offests. >Portable solutions? I suppose the best bet is to make the switch statement >smaller. One way to do this might be to replace some of the bigger cases >by jumps to code outside the switch statement itself. Ick. Replace the code in the case arms by routine calls. A monolithic chunk of code more than 32k bytes long might even be improved by this change.