Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!sol.ctr.columbia.edu!emory!hubcap!ncrcae!ncr-sd!se-sd!cns!dltaylor From: dltaylor@cns.SanDiego.NCR.COM (Dan Taylor) Newsgroups: comp.sys.amiga.programmer Subject: Re: Assembly Language & Programming Message-ID: <886@cns.SanDiego.NCR.COM> Date: 9 Apr 91 02:53:00 GMT References: Organization: NCR Corp. SE-San Diego Lines: 44 In colin_fox@outbound.wimsey.bc.ca (Colin Fox) writes: >computer. If you were programming on a mini or mainframe, you shouldn't care >what the hardware looks like, but on a home computer, it makes a difference. I've got news for all the C-types ( I know, strong typing is for weak minds ) out there. I write 99% C, since I work in the UNIX environment, now, but I've also made as living a an assembly language programmer, and may do it again. Anyway, I've heard C-types say that the language should always produce the best code, no matter the platform, but that's just not possible. Current example: Stepping through a received data packet, checking header parameters that are bits in various bytes (SNA). I was asked by a colleague, "why use "cp++", when header[various constant offsets] works better?" The source was on a 68K, moving to an '86, and his experience is '86. So, I showed him the timing for a post-increment address-register- indirect, on a 68K, and he said "Oh!". The array-offset form is cleaner/faster on an '86, though, since it does't have the 68K address modes. So, the C source makes some decisions for the compiler that are pretty hard to optimize around. And some C source will work better on some processors than others, even roughly equivalent CPU's. Furthermore, just because the code runs on a mainframe, or super-mini, doesn't mean that code size is irrelevant. A small mis-optimization may make your code cross page boundaries unnecessarily, so, you get to go to disk for that page. Even mainframe drives are slower than Amiga CHIP RAM. It is nice to have some hardware background, in any low-level language like C. It is imperative to have a good knowledge of algorithms in ANY language. While you can, eventually, code all algorithms in assembly, some of them fall very nicely out of higher-level languages. The good programmers can, therefore, use the most optimum (speed/size/project schedule/etc.) languageS, emphasis on the PLURAL, for the task, and have enough education and experience to discern which is which. My 2 pfennig. By the way, some compilers/libraries are optimised for benchmarks. What does your "strcmp()" or "memcmp()" do when passed identical addresses, which is hardly common practice, EXCEPT in benchmarks? Dan Taylor * My opinions, not NCR's *