Using &LABEL

Mister Snufilupagus arnold at gatech.UUCP
Thu Sep 20 02:23:14 AEST 1984


> 	In response to the idea of switches implementing jump tables, I would
> 	like to know how many C compilers really generate jump tables.

The Georgia Tech C compiler for Prime computers implements switches as
a CGT instruction.  Guess what this is.  Yes, believe it or not, a Computed
GOTO instruction, in the hardware! (yuch, barf...)

It is exactly a jump table, implemented in the micro code.  Very fast.  You
put the value in the A register.  The next word contains the number of one
word addresses following the CGT, and the data itself.  The A register
is used as the index into the list of addresses following the instruction:

	LDA  <something>
	CGT
	DATA	<number of addresses + 1>
	ADDR1
	ADDR2
	ADDR3
	....

So at least one compile does use jump tables.  The Cyber Pascal compiler
will also generate a jump table in certain conditions, which are fairly
common, especially in student code.
-- 
Arnold Robbins
CSNET: arnold at gatech	ARPA:	arnold%gatech.csnet at csnet-relay.arpa
UUCP: { akgua, allegra, hplabs, ihnp4 }!gatech!arnold

Can you tell me how to get, how to get to Sesame Street?



More information about the Comp.lang.c mailing list