www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/11/19:02:55

From: korpela AT albert DOT ssl DOT berkeley DOT edu (Eric J. Korpela)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How is switch implemented?
Date: 11 Apr 1997 21:54:47 GMT
Organization: Cal Berkeley-- Space Sciences Lab
Lines: 24
Message-ID: <5imbv7$sop$1@agate.berkeley.edu>
References: <5hu99c$2t1 AT tuba DOT cs DOT indiana DOT edu>
NNTP-Posting-Host: albert.ssl.berkeley.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <5hu99c$2t1 AT tuba DOT cs DOT indiana DOT edu>,
Jeff Standish <jestandi AT cs DOT indiana DOT edu> wrote:
>I'm assuming that most intelligent compilers would try to use an jump
>table, but I don't know for certain, and I'm not in the mood to compile,
>disassemble, and try to read the machine code.

GCC does optimize such things as a jump table, but not all compilers
do so.  (I know of one compiler that does such things using a list of
DEC and JZ instructions (not for intel arch,))

>And I'm asking this in a more general sense, since in addition to DJGPP I
>also use Visual C++ (yes, yes, I know, spawn of the evil empire and all
>that...).

Borland C does it by using a Jump Table, and as BCC is the worst optimizing
compiler on the planet you can be pretty sure every other compiler will.
But just to make sure you could build your own jump table in C.

Eric
-- 
Eric Korpela                        |  An object at rest can never be
korpela AT ssl DOT berkeley DOT edu            |  stopped.
<a href="http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpela/w">
Click here for more info.</a>

- Raw text -


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