From: | David L Moore <dlmoore@ix.netcom.com> |
Newsgroups: | comp.compilers,comp.lang.c.moderated |
Date: | 5 Dec 1997 01:12:22 -0500 |
Organization: | Netcom |
References: | <clcm-19971204-0012@plethora.net> |
Keywords: | code |
Jakob wrote:
> [How to implement a case jump table]
A common technique is to divide the table up into compact segments on
which you will use an indexed jump and then select the appropriate
table with if statements. These can be arranged as a binary tree to
minimize the number of comparisons needed. If you have profile info,
you may be able to do better, but otherwise this is a pretty good
approach.
Control Data's Fortran compiler had a nice trick in it which should
not be lost to posterity. The inbuilt assembler contained a large
sparse indexed table for opcode recognition. The code for the
assembler was inserted into the empty space in the table. This worked
because the compiler would never spit out bad opcodes.
The table management was all done with pseudo-code (macros) at assembly
time!
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.