Newsgroups: comp.lang.asm370 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.edu!ux1.cso.uiuc.edu!phil From: phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) Subject: Re: Postholes Message-ID: <1991Apr18.191258.94@ux1.cso.uiuc.edu> Organization: University of Illinois at Urbana References: <1991Apr16.004355.22971@redsox.bsw.com> Date: Thu, 18 Apr 1991 19:12:58 GMT Lines: 83 campbell@redsox.bsw.com (Larry Campbell) writes: >Why is it (he wonders out loud) that the only machines on which people still >(in this day and age) seem to use assembly language are IBM 360s? There is programming on IBM PC's. >I can't remember who said this, but it's apropos: "Programming in assembly >language is like digging postholes with a teaspoon. Sure, it takes longer, >but you have complete control over every spoon of dirt." It depends on WHAT KIND OF HOLE you are digging. A posthole is NOT an appropriate kind of hole to use a teaspoon on, but an archeological dig could be. I'm not saying that ALL uses of assembler are appropriate, but some are. >Is it just because IBM doesn't ship any decent compilers? I mean, what >am I missing? Why do people put up with this stuff? In many cases the compilers generate far less than optimal code for an application where speed is essential (loops that run billions of times). In other cases the provided high level language libraries are deficient. I notice that very very little assembler language programming is done on UNIX systems. In part this is due to the fact that UNIX makes it easy to do system level functions in C and other languages. But there is also the draw to make a program portable and that draw is enhanced by the fact that it really is easy to do within UNIX platforms. When developing code for VM/CMS or MS-DOS, for instance, you know the assembler code is going to work on the intended platforms anyway. I believe it is a combination of poor compilers, poor run time libraries, and weak operating systems. For instance a couple years ago I was experimenting with the Mandlebrot set. I wrote the iteration in FORTRAN and had it optimized. I looked at the code it generated and saw it using an excess of load and store operations that I was sure were not needed. So I tried to code it entirely in registers. It was not that easy because as it turned out, the results from one iteration resulted in a couple of the values transposed in a pair of registers. But I just simply coded a pair of interations with the second one working with the registers swapped in context. Here is the code I wrote for the Mandelbrot set power raising loop. All intermediate values are in registers and the memory references that are present are just contants. The code ran about twice as fast as that generated by the FORTRAN VS compiler with optimization (which suggests that registers are still faster than cache). ITERATE DS 0H <<< here to iterate one point *********************************************************************** LDR FPR4,FPR2 y MDR FPR4,FPR0 x*y ADR FPR4,FPR4 2*x*y AD FPR4,Q Y = 2*x*y + Q MDR FPR0,FPR0 x**2 MDR FPR2,FPR2 y**2 LDR FPR6,FPR0 (x**2) ADR FPR6,FPR2 (x**2+y**2) CD FPR6,ESC diverging? BCR HIGH,R7 yes --> SDR FPR0,FPR2 x**2 - y**2 AD FPR0,P X = x**2 - y**2 + P ALR R6,R1 count *********************************************************************** LDR FPR2,FPR4 Y MDR FPR2,FPR0 X*Y ADR FPR2,FPR2 2*X*Y AD FPR2,Q y = 2*X*Y + Q MDR FPR0,FPR0 X**2 MDR FPR4,FPR4 Y**2 LDR FPR6,FPR0 (x**2) ADR FPR6,FPR4 (x**2+y**2) CD FPR6,ESC diverging? BCR HIGH,R7 yes --> SDR FPR0,FPR4 X**2 - Y**2 AD FPR0,P x = X**2 - Y**2 + P ALR R6,R1 count *********************************************************************** BCT R3,ITERATE --> go again if needed BR R7 all done now --> -- /***************************************************************************\ / Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu | Guns don't aim guns at \ \ Lietuva laisva -- Brivu Latviju -- Eesti vabaks | people; CRIMINALS do!! / \***************************************************************************/