Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!overload!dillon From: dillon@overload.Berkeley.CA.US (Matthew Dillon) Newsgroups: comp.sys.amiga.programmer Subject: Re: Lemmings - a tutorial Part V (last) Message-ID: Date: 1 Apr 91 19:24:45 GMT References: <1991Mar31.003933.1483@mintaka.lcs.mit.edu> <1991Apr1.020748.26863@mintaka.lcs.mit.edu> Organization: Not an Organization Lines: 64 In article <1991Apr1.020748.26863@mintaka.lcs.mit.edu> rjc@geech.gnu.ai.mit.edu (Ray Cromwell) 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? 512K is not a lot of RAM to go and waste memory all the >>time. A 7.14 MHz 68000 isn't fast enough to waste all the extra cycles, if >>you are striving for performance. > > Obviously you have no idea of how advanced today's optimizing compilers >are. The code you stepped through must have been produced by some >1970's MetaComco compiler or something. But FYI, most of todays compilers I agree, you haven't looked at the output from a good compiler... GCC is one of the best, though on an Amiga it runs the bejeezes slow compiling something. You will ALWAYS be able to write assembly that goes faster, but compared to a good C programmer the result will not go *that* much faster, only a little faster. Not that I am advocating you write the game in C, clearly you simply do not want to accept any arguments in favor of C, but I'll try once to convince you. >can pass arguements in registers, allocate memory without stack, eliminate >the frame registers, and even do all the non-obvious tricks of sign extension, >etc. Check out the code I've included at the end compiled by GCC. > >>In practice, assembler is quite good at both data structures and event >>driven programming. If you haven't tried it, check it out and then >>comment again. > > I have tried it, without a great Macro assembler and some nice Macros, >it's still a pain. And assembler can't even come close to object oriented >programming such as data abtraction, inheritance, operator/function overloading >and streams. Assembler is just overkill for mostly everything. Assembler >has it's place, but if you program in assembler 100% of the time, your >a masochist. (Even on the C64 I routinely used compiled basic to implement It should be interesting to note that one of the BEST development paths for a game is to write the thing in C first... because you can write the game MUCH faster.. weeks instead of months, in fact, then convert critical routines to assembly. The end result is something that will generally go as fast or FASTER than doing it all in assembly from stage one, because if you do it in C you can make MAJOR changes to the algorithms quickly, whereas you must basically hardwire everything in assembly, making it nearly impossible to change a major core algorithm without rewriting the whole thing. In fact, you can make several MAJOR changes to the C code without comming close to the amount of time it takes to write the thing entirely in assembly. Nobody gets the algorithm right the first time... half way through writing the thing up you always figure out a way to do it better. -Matt -- Matthew Dillon dillon@Overload.Berkeley.CA.US 891 Regal Rd. uunet.uu.net!overload!dillon Berkeley, Ca. 94708 USA