delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/22/09:48:06

Message-Id: <m0xk3UW-000S2aC@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: "Anthony.Appleyard" <MCLSSAA2 AT fs2 DOT mt DOT umist DOT ac DOT uk>, DJGPP AT delorie DOT com
Date: Mon, 22 Dec 1997 11:50:56 +0000
MIME-Version: 1.0
Subject: Re: how to make switch(){ } compile as lookup table always?
In-reply-to: <4B0C721CA8@fs2.mt.umist.ac.uk>

"Anthony.Appleyard" <MCLSSAA2 AT fs2 DOT mt DOT umist DOT ac DOT uk> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019