Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!jato!jdickson From: jdickson@jato.jpl.nasa.gov (Jeff Dickson) Newsgroups: comp.sys.amiga.programmer Subject: Re: Lemmings - a tutorial Part V (last) Message-ID: <1991Apr2.183316.25110@jato.jpl.nasa.gov> Date: 2 Apr 91 18:33:16 GMT References: <781@tnc.UUCP> <1991Mar31.003933.1483@mintaka.lcs.mit.edu> Reply-To: jdickson@jato.Jpl.Nasa.Gov (Jeff Dickson) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 49 In article holgerl@amiux.UUCP (Holger Lubitz) writes: >In article mykes@amiga0.SF-Bay.ORG (Mike Schwartz) writes: >>As far as 'C' goes, I have stepped through enough disassembled 'C' code to >>see enough. How much RAM is wasted on LINK, UNLK instructions? How many >>cycles are wasted by pushing arguments on the stack to call a subroutine? >>How many cycles are wasted by calling a "glue" routine? How many cycles >>and bytes are wasted by fixing up the stack after each and every subroutine >>returns? How much stack do you need to allow for all the dynamic allocation >>of local variables? > >What kind of disassembled 'C' code did you step through ? I suppose >it was Greenhills C or some other ancient compiler. >Optimized code from recent C compilers like SAS 5.10a doesn't do this, if you >don't want it to. You can pass parameters through registers, eliminating the >need to pass them via stack and also making glue routines obsolete. >And dynamic allocation of local variables is nice to have as an aid in >structured programming - however, it is not needed. You can program in C >using only global variables and constants - just like you probably do when >programming in assembler. > >Best regards, >Holger > >-- >Holger Lubitz | holgerl@amiux.uucp >Kl. Drakenburger Str. 24 | holgerl@amiux.han.de >D-W-3070 Nienburg | cbmvax.commodore.com!cbmehq!cbmger!amiux!holgerl I'm not even going to atest that 'C' code is just as good as assembly. However, given a decent compiler, how sloppy, bulky, whatever - is largely up to you. I have written 'C' code that is nearly as compact and fast as it would be if it were written in assembly. I began my software ventures writing 8080 and Z80 assembly language programs. Back then, there was a real effort to write optimized programs, because the processor's speed was < 6MHZ and memory was limited to 64K. I wrote a source level debugger that used the PRN files Microsoft's M80 macro assembler produced. It was only 16K. Nowadays, processor speed and memory are not as important, and so most programmers don't care or take the time to write compact and efficient code. If you think that its ok to write half assed code, because an optimizer is going to clean it up for you - then you're in for a rude awakening. Also, beware that the library often is comprised of poorly written code. At least that's the way it is for the MANX 3.x libraries. I have my own library. The functions it contains suffice for most applications - not all. I make liberal use of Amiga.lib where applicable. -jeff