Xref: utzoo comp.lang.c++:2065 comp.lang.c:14255 comp.lang.forth:650 comp.lang.fortran:1510 comp.lang.misc:2141 Path: utzoo!attcan!uunet!husc6!mailrus!ames!ncar!dinl!noren From: noren@dinl.uucp (Charles Noren) Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.forth,comp.lang.fortran,comp.lang.misc Subject: Re: Assembly or .... Message-ID: <791@dinl.mmc.UUCP> Date: 23 Nov 88 17:18:28 GMT References: <1388@aucs.UUCP> Reply-To: noren@dinl.UUCP (Chuck Noren) Organization: Martin Marietta I&CS, Denver CO. Lines: 56 In article <1388@aucs.UUCP> Andreas Pikoulas write: >I would like to ask them if it really worth it to spend time to >learn assembly language... It is very much worth while to learn assembly language. Reasons: 1. Sometimes (although rarely) speed is absolutly crucial. No matter how much you optimize your compiler switches, you cannot be absolutly assured you are getting the best performance (unless you observe the assembly or machine executable output of the compiler). Even if the compiler gives you acceptable performance now, will a future upgrade of the compiler do something that will slow it down in the future? Assembly lanaguage gives you absolute control. 2. Assembly gives your more options to interface to your operating system, service interrupts, and control hardware. It is true I can do all of this in most C's (even in many Pascal's), but there is a price. Often the C compiler forces you to do things in certain ways. Example, to service an interrupt in Turbo C, the Turbo C compiler will save all the registers, let you perform the operation, the restore all the registers. In assembly, you can save just the registers you need, perform a quick operation, the restore the used registers. There may be ways around this in C, but often these use undocumented features of the compiler or other features which are subject to change. I have been bitten by this many times when a new upgrade came to a compiler or operating system. 3. Assmembly language gives you a better understanding of the architecture of the machine you are working on, in fact it forces you to learn the architecture. If you are going to spend any time working on the machine this kind of knowledge will be of subtle but great benifit. This kind of knowledge can improve your high level language coding in a variety of ways (yes, you do want to make sure your coding is as much machine independent as possible). For instance, in C you can use register variables. But what are the practical implications if your machine has a limited number of general purpose registers? On the x86 class machines there are a variety of memory models. What are the real implications of using small, medium, large? Knowing the assembly language will give you those insights. Why can't you do a straight compare of pointers in C for equality in most memory models of x86 computers (but you can in some other CPU families)? Knowledge of assembly will give you this answer (o.k., knowldge of the machine architecture gives you this answer, but knowledge of the assembly language forces you to learn the details of the architecture). 4. It is good to know several different classes of languages. It expands a person's thinking and approaches to solving problems. This is a long winded reply. I hope this helps. -- Chuck Noren NET: ncar!dinl!noren US-MAIL: Martin Marietta I&CS, MS XL8058, P.O. Box 1260, Denver, CO 80201-1260 Phone: (303) 971-7930