On Thu, Oct 09, 1997 at 08:23:46AM -0400, Alan G. Smith wrote: > But we must not believe the lie > that the compiler is generating tighter/faster code than we could by hand. The key here is the difference between "is generating" and "could by hand". It's true that, given enough time, an assembler programmer can write code at least as tight as a compiler can generate. It's also true that, given enough time, a compiler writer can tweak a compiler to equal hand-written code for any given example. But in practice, there never is enough time. So for the bulk of the code the compiler will generate better code than the programmer has time to write, and a programmer may hand-optimize small bits of code the compiler didn't quite do well enough. There are also a few things compilers can do that an assembler programmer would not dare. My favourite is the PDP-11 instruction that Dennis Ritchie's compiler would produce for something like var = 2; where var was a local variable, at an offset of 2 from the frame pointer. The instruction generated was mov (pc),2(r5) which exploits the PDP-11's ability to use the PC as an index register, so the constant 2 does double duty as the immediate value AND the frame pointer offset. Any assembler programmer who did anything like that for me would be fired. It's unmaintainable, but it's ok for the compiler to do since it will regenerate the code on each compilation, and if the offset and constant no longer match, will do something else instead. -- Clyde Smith-Stubbs | HI-TECH Software Email: clyde@htsoft.com | Phone Fax WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885 PGP: finger clyde@htsoft.com | AUS: +61 7 3354 2411 +61 7 3354 2422 --------------------------------------------------------------------------- ANSI C for the PIC! Now shipping! See www.htsoft.com for more info.