- "Need for Speed - C++ versus Assembly Language" - 9 Updates
- Error message when defining a static data member - 3 Updates
Bonita Montero <Bonita.Montero@gmail.com>: May 10 05:36PM +0200 > o Carry handling in the four operations. > o Overflow testing > o Interrupts This aren't many examples and these are rarely needed. |
Bonita Montero <Bonita.Montero@gmail.com>: May 10 06:04PM +0200 > | ((x & 0xff0000) >> 8) > | ((x & 0xff000000) >> 24); > } MSVC does the same. |
legalize+jeeves@mail.xmission.com (Richard): May 10 04:23PM [Please do not mail me a copy of your followup] Ian Collins <ian-news@hotmail.com> spake the secret code >I have seem quite a lot (too much!) hand rolled code (both ASM and C or >C++) that was a good idea at the time it was written, but a hindrance in >both performance and maintainability now. A good example here is the ancient DOS fractal rendering program FRACTINT, which I forked and modernized to Win32 as Iterated Dynamics. <https://github.com/legalizeadulthood/iterated-dynamics> I eliminated all the assembly code that was there to make it fast on a 286 (I am not kidding) and used the C equivalent code that was there for the unix port. The whole thing got significantly faster, even without any profiling. The assembly code used 16-bit instructions which are on the "legacy compatibility" portion of a modern processor, not the part that runs fast. Granted, this is an extreme example as you're not likely to have 20+ year old assembly in your code base. Or maybe you do.... -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
legalize+jeeves@mail.xmission.com (Richard): May 10 04:26PM [Please do not mail me a copy of your followup] Chris Vine <chris@cvine--nospam--.freeserve.co.uk> spake the secret code >> Brian >Brian, >I thought you might post this. I was kind of waiting for it. Unfortunately this whole sexual harrassment digresion is exactly the sort of off-topic soap box speech that Brian is giving. You're both off-topic, lack self control and presume moral superiority. -- "The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline> The Terminals Wiki <http://terminals-wiki.org> The Computer Graphics Museum <http://computergraphicsmuseum.org> Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com> |
scott@slp53.sl.home (Scott Lurndal): May 10 05:29PM >[Please do not mail me a copy of your followup] >Granted, this is an extreme example as you're not likely to have 20+ >year old assembly in your code base. Or maybe you do.... Even older in a couple of cases (mainly the boot code in the hypervisor which needs to start in real-mode, transition through protected mode, turn on paging then switch to long-mode). |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: May 10 10:03PM +0200 On 08-May-17 7:33 PM, Lynn McGuire wrote: > Neat ! I believe that ANY C++ compiler and linker duo can beat my hand > written assembly language. Its been decades since I wrote any assembly > language. It's not an achievement to write worse assembly code than a compiler (I haven't looked at the above, but that's your claim and my impression from the discussion). So I don't really understand your posting. But sometimes a little assembly is just what you need for speed. My main and only example is the humble trampoline function, to use as a C callback. It puts the address of a C++ object in the proper place (hopefully a register) for the C++ implicit `this` argument, and jumps – woohoo! we're jumping! – to a member function. Yes there are umpteen ways to do this in pure C++, including picking up that C++ object address from a global (maybe with thread local storage). Whatever. But the trampoline is sort of maximally efficient. The good puppy over at Stack Overflow, whose secret real name I once knew, I sort of collected the real names of many of the folks there, once tried to propose a feature for the standard library, with support for trampolines. As far as I know nothing came of it, except that he met some committee members. It may be that without someone to champion the proposal for him he had to use his real name, I don't know. Cheers!, - Alf |
David Brown <david.brown@hesbynett.no>: May 10 10:31PM +0200 On 10/05/17 18:04, Bonita Montero wrote: > MSVC does the same. Please do not quote my posts without proper attribution. Doing so is a massive breach of Usenet etiquette. |
jacobnavia <jacob@jacob.remcomp.fr>: May 10 11:14PM +0200 Le 10/05/2017 à 17:36, Bonita Montero a écrit : >> o Overflow testing >> o Interrupts > This aren't many examples and these are rarely needed. Yes. Asm is never *needed*, it is fun. Most programs are high level programs automatically translated, for instance C++. Prefetching, pipeline construction are difficult to do for a given C++ program. Since the language doesn't offer any way to do that, you rely on automatic translation. Or not. I don't really understand why this emphasis on C++. Yes, this is a C++ group etc. But... Many people think that constructing programs that use the bare instructions of the processor gives you a real perspective of what is going on there. Note that I am not in any way trying to say that C++ should be replaced by asm. Just that asm gives you insights. jacob |
David Brown <david.brown@hesbynett.no>: May 10 11:48PM +0200 On 10/05/17 23:14, jacobnavia wrote: >>> o Interrupts >> This aren't many examples and these are rarely needed. > Yes. Asm is never *needed*, it is fun. Sarcasm like this does not work well without additional clues that you get in spoken conversation. Most assembly that is written is /not/ needed. (Indeed, I believe that most code written in C could be better written in other languages.) But only most - for some purposes, assembly is the better or only choice. > Prefetching, pipeline construction are difficult to do for a given C++ > program. Since the language doesn't offer any way to do that, you rely > on automatic translation. And often the compiler can do a better job of it than an assembly programmer can. Failing that, implementation extensions can help (like __builtin_prefetch in gcc), and failing that, most compilers will let you make small inline function that wraps a piece of inline assembly. > Many people think that constructing programs that use the bare > instructions of the processor gives you a real perspective of what is > going on there. Here I agree with you - I think doing some assembly programming is good for a developer when they are learning to program - it gives them a much better understanding of what goes on under the hood. But that is for learning - /real/ work should be done mainly in other languages (not necessarily C or C++). And for serious low-level or high efficiency C or C++ development, it is good to be able to understand the generated assembly code, even if you can't write it. |
woodbrian77@gmail.com: May 10 09:55AM -0700 On Wednesday, May 10, 2017 at 7:47:34 AM UTC-5, Scott Lurndal wrote: > > It seems that I also can use braces: > >::std::vector< ::my_class::listentry >( ::my_class::list ); Interesting. > Or do as has been suggested and lose the leading "::". I really > hope you don't teach your students that practice, as it will cause > them problems once they hit the real world. I use a similar form as Stefan and am happy with it. Brian Ebenezer Enterprises - Enjoy programming again. http://webEbenezer.net |
scott@slp53.sl.home (Scott Lurndal): May 10 05:30PM >> hope you don't teach your students that practice, as it will cause >> them problems once they hit the real world. >I use a similar form as Stefan and am happy with it. You are atypical. |
woodbrian77@gmail.com: May 10 11:33AM -0700 On Wednesday, May 10, 2017 at 12:30:20 PM UTC-5, Scott Lurndal wrote: > >> them problems once they hit the real world. > >I use a similar form as Stefan and am happy with it. > You are atypical. Not really. Others love G-d and country and baseball. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment