Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!ami-cg!cg From: cg@ami-cg.UUCP (Chris Gray) Newsgroups: comp.sys.amiga.programmer Subject: Re: Good programmers and assembly language (very long) Message-ID: Date: 4 Apr 91 17:56:40 GMT References: <7214@harrier.ukc.ac.uk> <2220@pdxgate.UUCP> Organization: Not an Organization Lines: 59 In article <2220@pdxgate.UUCP> bairds@eecs.cs.pdx.edu (Shawn L. Baird) writes: [lots of other stuff deleted] >Writing in assembler in Unix is a sin? Gee boss, parts of the OS are >written in assembler, guess we'd better junk it! Just how did a >seperate convention for 68000 assembly come about, if nobody ever uses >assembly with Unix? Assembly is used in commerical Unix products that >need the extra speed it offers. About the only reason public domain >products don't use it is it's inherent unportability. Why does Sun >try to remain binary compatible through most of their line? Because, >some of the stuff can't just be ported and recompiled on a new machine. Last I checked the Sun Unix kernal had a couple of hundred lines of code in assembler. Stuff to fiddle with the MMU, setup interrupt vectors, etc. I don't believe ANY of the user-level utilities are written in assembler. (I believe troff was in PDP-11 assembler waaaaay back, but no longer.) >I believe that there is some capability in the Sparc Stations to run >older Sun executables. Not that I know of, unless they went to the trouble of writing an emulator. The instruction sets aren't even similar. >Here's a small list of things that I can come up with that require >knowledge of assembly: writing an OS, writing device drivers, writing >_fast_ programs (for instance, Sculpt-3D had to be fast. They didn't >use the best algorithms in the world, however, so it should have been >faster), writing compilers (yeah, those things you use in preference >to assembly). It's a good thing you say "knowledge of assembly" or I could really flame you! Most OS's nowadays are written by groups of people. Most of those people probably never program in assembly, and don't need to have. (Most probably have, but that's just because of the timing of their careers.) Writing a device driver for UNIX requires looking at sample source much more than it requires any assembly knowledge - I found the undocumented UNIX internal conventions (like for 'select'!) much more troublesome than straightforward fiddling with a couple of registers. I don't believe I've ever seen a current UNIX device driver that had any assembler in it. I've written a half dozen compilers in my time, and seen a few others. None had any assembler parts in them (older IBM mainframe ones did, and I hear Turbo stuff on MSDOS is in assembler, however). The only assembler I did for my entire Draco compiler/libraries/etc was some run-time support stuff (like doing 32 bit mul/div on the 68000). You definitely need to know the CPU to write a code generator for it, and having programmed in assembler is a definite asset for hand coding a code generator. However, some of the research and retargettable compilers nowadays have automatically produced code generators and optimizers - the programmer need only read the CPU manual and convert the instruction descriptions to the proper form - the software does the rest. I must agree, though, that knowing a bit about assembler programming is a useful skill for programmers who will be coming at all close to the machine. It's not clear that scientists doing numerical simulations and graphics need it, however. -- Chris Gray alberta!ami-cg!cg or cg%ami-cg@scapa.cs.UAlberta.CA