Long Branches

ark at alice.UUCP ark at alice.UUCP
Mon Jan 19 15:00:32 AEST 1987


In article <3950006 at nucsrl.UUCP>, ram at 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.

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.



More information about the Comp.lang.c mailing list