Author: Robert Hyatt
Date: 07:38:23 01/14/02
Go up one level in this thread
On January 13, 2002 at 16:27:01, Tom Kerrigan wrote: >On January 13, 2002 at 10:22:52, Robert Hyatt wrote: > >>1. You know more about the program than the compiler. No bounds-checking >>on "switch" type statements is necessary. > >What bounds checking or "switch type statements" are going on in a C program if >you don't explicitly put them in? How are you going to do a "safe" switch without bounds checking? The good examples I have seen do this via a jump table rather than a dozen compare and branches. And a jump table is unsafe without bounds checking unless you _know_ what the test variable will contain... > >>2. you know whether a value can be positive, negative, or both. The >>compiler can't. > >Why does this matter? Just deal with 32 bits (or whatever your word size is) and >call it good. And when you move chars to full-word values, do you sign-extend or not? Etc. Can you put 4 chars in one register and get away with it or will the sign be destroyed? Does it even have a sign in some cases? The compiler can't possibly know... > >>3. you know whether a value can exceed (say) 127 or not. The compiler can't. > >Again, why does this matter? Because it fits in 7 bits if it doesn't... > >>4. You know how many registers the CPU has and can design code around that, >>while C doesn't give you such control. > >You can change the C until it produces the assembly that you want. Hardly... > >>5. you know exactly which registers procedure "x" will destroy, so you don't >>have to save everything before calling it. If you are careful, you don't have >>to save _anything_. > >The really strict calling conventions that you're thinking of here are no longer >present in today's compilers. > >-Tom Have you looked at the output from a procedure call???
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.