Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!alberta!calgary!radford From: radford@calgary.UUCP (Radford Neal) Newsgroups: net.arch Subject: Re: C as an aid writing assembler Message-ID: <132@vaxb.calgary.UUCP> Date: Tue, 20-May-86 15:32:18 EDT Article-I.D.: vaxb.132 Posted: Tue May 20 15:32:18 1986 Date-Received: Sat, 24-May-86 17:57:02 EDT References: <201@pyuxv.UUCP> <3700003@uiucdcsp> Organization: U. of Calgary, Calgary, Ab. Lines: 39 Summary: *I* don't write assembler from high-level language... In article <3700003@uiucdcsp>, johnson@uiucdcsp.CS.UIUC.EDU writes: > > I consider designing assembler code using a high-level language to be > "motherhood". I have always done it that way (since I wrote my first > big assembly program in 1976), I thought most "modern" programmers did > it that way, and I teach all my students to do it that way. Am I > hopelessly naive? Yes. The modern programmer only writes in assembly language if he needs to utilize machine features not possible from a high level language or he needs to get that last bit of speed. In neither case is writing the program in C first especially helpful. Note that nobody writes "big" assembly language programs anymore. For example, the last chunk of assembler (VAX) I wrote was for catching a Unix signal, forking, letting the parent continue, and doing a core dump (via setting the trace trap bit in the PSL) in the child after fiddling the stack frames to reflect the situation before the signal in the parent, so the debugger will print out the right stack trace, etc. Part of this was in C, but the part that wasn't was completely unexpressible in C. The last (relatively) large piece of assembler (68000) I wrote was a set of bit-map manipulation routines. This was in assembler for efficiency. It used techniques such as completely unrolling a single-instruction loop (executed at most about 50 times) and branching into it at the right place, based on the instructions all being two bytes in size. Not the sort of this one does in C, or that one does in assembler if you start from a C program. It's fast though. All this may not be true if you're stuck writing assembler on a machine without an adequate high level language, but I presume that this is no longer common. It also doesn't directly apply when you're writing a large assembler program because you're learning about assembly language. Starting from C might be good in that case. Then again, maybe it would just lead to the student not leaning anything about machine architecture that isn't expressible in in C. Radford Neal