Message-Id: Comments: Authenticated sender is From: "Salvador Eduardo Tropea (SET)" Organization: INTI To: "Anthony.Appleyard" , DJGPP AT delorie DOT com Date: Mon, 22 Dec 1997 11:50:56 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: how to make switch(){ } compile as lookup table always? In-reply-to: <4B0C721CA8@fs2.mt.umist.ac.uk> Precedence: bulk "Anthony.Appleyard" wrote: > Please reply to me in person, as I had to unsubscribe from djgpp due to email > intray overload: I will be away from my email over Xmas and New Year. > > I have djgpp v2. A program contains a switch(c){ } statement which is obeyed > very many times. c can be from 0 to 511. How can I make djgpp compile the > switch() always as a lookup table of labels and not as a lot of time-wasting > tests and jumps even if the resulting lookup table would be very gappy? I > can't find anything about this in DJGPP\INFO\ or in the FAQ. In my editor the commands switch is really huge and gcc automagically makes a look-up table. The main problem can be if your values are: 1,2,3...100 (gap) 500,501,502...511 Then gcc will make 2 look-up tables and add a little code to use one or the other. I think you can't ask for an unconditional look-up table. Anyways, just using optimizations you get a good ratio of: size needed v.s. speed. SET ------------------------------------ 0 -------------------------------- Visit my home page: http://www.geocities.com/SiliconValley/Vista/6552/ Salvador Eduardo Tropea (SET). (Electronics Engineer) Alternative e-mail: set-sot AT usa DOT net - ICQ: 2951574 Address: Curapaligue 2124, Caseros, 3 de Febrero Buenos Aires, (1678), ARGENTINA TE: +(541) 759 0013