Author: Ed Schröder
Date: 10:31:39 01/14/02
Go up one level in this thread
On January 14, 2002 at 12:11:52, James Robertson wrote:
>Here are several questions I've been wondering about:
>
>1) How does one insert inline assembler statements into your code such that it
>can be compiled by gcc (obviously __asm doesn't work)?
James, welcome back.
>2) How is switch() code generated? For instance, if the compiler encounters:
>switch (var) {
>case 0: do_stuff0(); break;
>case 1: do_stuff1(); break;
>case 2: do_stuff2(); break;
}
A good compiler will make use of the "indirect call", that is it will generate a
table, store the memory address of the functions, and call the right routine
from the generated table. The advantage, it takes 1 instruction.
>will more efficient code be generated than if I write:
>switch (var) {
>case 297: do_stuff287; break;
>case 0: do_stuff0; break;
>case 9000: do_stuff9000; break;
>}
>
>If so, what does the compiler do to take advantage of the fact that 0, 1, and 2
>are consecutive numbers?
See above.
If you are using values that are in a reasonable range then create the table
yourself. I recently posted an example of that for generating moves, you will
have to search for that in the archive.
Ed
>3) How much overhead is added to a function call from a function pointer? Maybe
>none? How about if you index an array of function pointers?
>
>4) What are the syntax differences between console code written for Linux versus
>Unix (I don't have easy access to a Unix machine)?
>
>5) Just out of curiousity, when is VC7 being released?
>
>Ok, If anyone could help me with these I'd be grateful.
>Thanks!
>James
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.