Need Assembly lang. to learn C?

Blair P. Houghton bhoughto at pima.intel.com
Fri May 24 13:48:54 AEST 1991


In article <1991May22.094917.28322 at rodan.acs.syr.edu> ldstern at rodan.acs.syr.edu (Larry Stern) writes:
>least a working knowledge of Assembly will help produce a better understanding
>of the C language and tighter C code.

I've had it.

I've started to respond to this thread three times, but
always ended up sounding like I wanted a language-religious
argument, so I forgot it.  But this one is the killer.

Please, please, please, once you've learned assembler and
the inner workings of a computer, please, please, please,
forget all of it and don't even try to mimic it in your
C code.

There is _nothing_ in C that even remotely resembles
assembly language or the internal construction of a cpu or
memory.  Comp.lang.c spends much of its time debunking the
myth of optimizing performance through minor code changes.
You can make your algorithms run better by removing
syntactic elements, but if so, then your algorithm is being
optimized, not your program.  Even then, it is likely that
any compiler would have recognized the optimization and
done it for you, so you gain nothing but programming
headaches from trying to think like the computer (and most
compilers are capable of optimizations that you'd never
dream of, and apply them regardless of whether you ask for
them, in the normal course of 'optimizing' your code from
an ascii representation into a sequence-of-voltage-vectors
representation.)

Tighter code comes from an understanding of the syntax
of the language, not from any sort of hardware mimicry.
In fact, it's also a classic result that 'tighter' code
is a Trap and/or Pitfall just waiting to catch you.
Syntactic clarity is key; bits and bytes come along for
the ride.

Plus (and here's one you should throw at your prospective
instructor), most assembly languages have little idea what
the machine is really doing, anyway.  If you want to
understand computer internals, take a computer engineering
course, and learn to design a microcode or to interface a 
peripheral to a bus.  Plenty of so-called "low-level"
operations are the inciters of kilowatts of transistor
switching.

Much C code could have been saved from obsolescence and
revision (and the costs those things imply) if it had only
been written logically and artfully, instead of being
crowbarred into doing the compiler's job.

				--Blair
				  "Just my ~ $0.0000010011110111 worth..."



More information about the Comp.unix.questions mailing list