Generated assembly for switch statement

Submitted by Anonymous
on December 28, 2006 - 8:28am

If you write a switch statement in C with many cases, the gcc doesn't build a cascade of conditional jumps as it would do for if/then/else or some small switch statements. Instead it does one jump to a location, which is dynamically determined like this:

805f0e1: jmp DWORD PTR [eax*4+134674476]

Of course, this is for efficiency, but does anyone know a way to turn this off and make gcc generate a normal cascade like if/then/else? I need this for an assembly-analyser, because these dynamically determined jumps are evil in analysing :)

-fno-jump-tables might do the

Anonymous (not verified)
on
December 28, 2006 - 9:19am

-fno-jump-tables might do the trick. :)

nice, it works greatly! thank

Anonymous (not verified)
on
December 29, 2006 - 7:05am

nice, it works greatly! thank you very much :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.