Though there are cases where even modern compilers don't "get" how to produce the most efficient code. But apart from the fact that this rarely matters at all I guess most of the time it is wiser then to modify the C/C++ code to make optimization easier for the compiler, instead of coding in assembly.jacmoe wrote:I trust my optimising compiler more than I trust hand-written inline assembly.nikki wrote:Some times you can also inline some assembly into your C++ for quick hax.
Learn some assembly
-
jjp
- Silver Sponsor

- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
- Contact:
Re: Learn some assembly
- Kojack
- OGRE Moderator

- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 538
Re: Learn some assembly
Compilers are better than humans at generating assembly 99% of the time, but there are still cases where you can take advantage of assembly. Especially with special cpu features like SSE, 3dNow, or non x86 platforms like ARM. When compiling for an OMAP3530, will gcc optimise your code to use the Cortex A8 core combined with the NEON simd coprocessor and TMS320C64x+ dsp core to achieve the best floating point maths performance? Nope, you'll have to do it by hand.
Take at look at the following Ogre files: asm_math.h, OgreOptimisedUtil.cpp, OgrePlatformInformation.cpp, OgreSIMDHelper.h
They all contain inline assembly. I'm sure it's not there just for fun.
Thanks to them choosing Cambridge University's Tripos as the basis for the Amiga operating system, Amigas were fully preemptive multitasking and multithreaded 6 years before linux, 10 years before microsoft and 14 years before apple.Oh man, C64, Amiga & Co, I just this week talked with a friend about how much it sucked the Amiga universe stopped thanks to Commodores brilliant mis-management back then and from that point on everyone was stuck in the 10 years behind in time Microsoft universe with 16 lousy colours and no multitasking at all
- Nauk
- Gnoll
- Posts: 653
- Joined: Thu May 11, 2006 9:12 pm
- Location: Bavaria
- x 36
- Contact:
Re: Learn some assembly
Assembly coding makes you feel like a real mannikki wrote:You gotta just be clever then.
Anyway, I was stressing more on the learning and fun aspects.
Another one for the fun aspect, are their any good assembly IDEs? I have been looking at a couple and they either been upsetting my antivirus software or were at a very incomplete stage.
/Offtopic-rant:
Remember the Amiga API and the 4 big reference manuals? I did quite a lot C coding back then (around 1986), and it was pleasant and easy to work with it the functionality seemed logical, reasonable and foremost inspiring. When I looked 10 years later first time at Microsofts WinAPI the first thought was "Are you kidding me, well now I at least know why there is so much rubbish and bad quality out there" - WinAPI is as inspiring as doing a tax-declaration. Still puzzles me how they ever got to become the dominating power - well not really, it's a lot about backyard marketing and the never to underestimate brilliance of the human flock, or like an old joke says "Eat shit - millions of flies can't be wrong" - without that Hitler, Bush and Windows would have never happened.Kojack wrote:Thanks to them choosing Cambridge University's Tripos as the basis for the Amiga operating system, Amigas were fully preemptive multitasking and multithreaded 6 years before linux, 10 years before microsoft and 14 years before apple.Oh man, C64, Amiga & Co, I just this week talked with a friend about how much it sucked the Amiga universe stopped thanks to Commodores brilliant mis-management back then and from that point on everyone was stuck in the 10 years behind in time Microsoft universe with 16 lousy colours and no multitasking at all
ARTIFEX TERRA 3D - Artist-friendly, free and easy WYSIWYG realtime outdoor scene Editor & Painter
New loader now with Ogre::Terrain support: Addons for Artifex on SourceForge
MOC - Minimal Ogre Collision & Mousepicking
Simple TerrainMaterialGenerator for the use of standard Ogre material with Ogre::Terrain
Support me on Patreon
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
Re: Learn some assembly
I'm just using gvim, bash, fasm/nasm and ld (under Linux), and it's fine.Nauk wrote:Another one for the fun aspect, are their any good assembly IDEs? I have been looking at a couple and they either been upsetting my antivirus software or were at a very incomplete stage.
-
jjp
- Silver Sponsor

- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
- Contact:
Re: Learn some assembly
I doubt that "myriads faster" is not a strong exaggeration most of the time. And: with the time spent on doing micro-optimizations in assembly they probably could have thought of algorithmic improvements at a higher level.. with more gains but without the drawbacks caused by doing stuff in assembly. If I know my algorithm operates at the lower bound of what can be achieved in terms of complexity, no optimizations at a higher level seem possible any more, I need the speed and the algorithm performs worse than it could/should - then I would take a look at assembly. Otherwise I consider it a waste of time (talking about the context of using assembly for performance reasons).Nauk wrote:I have read several articles now where semi-experienced assembly coders, lets say 2 years + coding experience claim that their code runs myriads faster than optimized C++ and I don't think they are making it up just to get attention or because it is fun lieing.
- Kojack
- OGRE Moderator

- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 538
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
Re: Learn some assembly
The lighting in that image doesn't seem right.
- Nauk
- Gnoll
- Posts: 653
- Joined: Thu May 11, 2006 9:12 pm
- Location: Bavaria
- x 36
- Contact:
Re: Learn some assembly
I wish I would have kept all the old stuff /envy
I was hoping for a little more comfort, anyway here is a site I bookmarked that I found helpful to get into it, also has some further reference links:nikki wrote:I'm just using gvim, bash, fasm/nasm and ld (under Linux), and it's fine.Nauk wrote:Another one for the fun aspect, are their any good assembly IDEs? I have been looking at a couple and they either been upsetting my antivirus software or were at a very incomplete stage.
http://www.drpaulcarter.com/pcasm/index.php
and here another one to a pretty useful cheat-sheet translated into several languages:
http://www.jegerlehner.ch/intel/
ARTIFEX TERRA 3D - Artist-friendly, free and easy WYSIWYG realtime outdoor scene Editor & Painter
New loader now with Ogre::Terrain support: Addons for Artifex on SourceForge
MOC - Minimal Ogre Collision & Mousepicking
Simple TerrainMaterialGenerator for the use of standard Ogre material with Ogre::Terrain
Support me on Patreon
- Nauk
- Gnoll
- Posts: 653
- Joined: Thu May 11, 2006 9:12 pm
- Location: Bavaria
- x 36
- Contact:
Re: Learn some assembly
I was using that wording to underline a point, but yes it was clearly exaggerateddoubt that "myriads faster" is not a strong exaggeration most of the time.
ARTIFEX TERRA 3D - Artist-friendly, free and easy WYSIWYG realtime outdoor scene Editor & Painter
New loader now with Ogre::Terrain support: Addons for Artifex on SourceForge
MOC - Minimal Ogre Collision & Mousepicking
Simple TerrainMaterialGenerator for the use of standard Ogre material with Ogre::Terrain
Support me on Patreon
-
jjp
- Silver Sponsor

- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
- Contact:
Re: Learn some assembly
I'd say they have to find some sort of justification for themselves putting a lot of time into learning assemblyNauk wrote:what makes me wonder is, that it is usually people that take the time to work themselves up to a proficient level start claiming that, I mean there must be a grain of truth behind it?
- jacmoe
- OGRE Retired Moderator

- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Learn some assembly
http://www.winasm.net/winasm-studio-downloads.html
http://www.negatory.com/asmstudio/
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- Nauk
- Gnoll
- Posts: 653
- Joined: Thu May 11, 2006 9:12 pm
- Location: Bavaria
- x 36
- Contact:
Re: Learn some assembly
Haha, or thatjjp wrote:I'd say they have to find some sort of justification for themselves putting a lot of time into learning assemblyNauk wrote:what makes me wonder is, that it is usually people that take the time to work themselves up to a proficient level start claiming that, I mean there must be a grain of truth behind it?
ARTIFEX TERRA 3D - Artist-friendly, free and easy WYSIWYG realtime outdoor scene Editor & Painter
New loader now with Ogre::Terrain support: Addons for Artifex on SourceForge
MOC - Minimal Ogre Collision & Mousepicking
Simple TerrainMaterialGenerator for the use of standard Ogre material with Ogre::Terrain
Support me on Patreon
- jacmoe
- OGRE Retired Moderator

- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Learn some assembly
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- jacmoe
- OGRE Retired Moderator

- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Learn some assembly
Easy Code Cat
The joy of assembly programming and RAD, all at the same time.
Good ASM page:
http://www.jorgon.freeserve.co.uk/
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- Nauk
- Gnoll
- Posts: 653
- Joined: Thu May 11, 2006 9:12 pm
- Location: Bavaria
- x 36
- Contact:
Re: Learn some assembly
ARTIFEX TERRA 3D - Artist-friendly, free and easy WYSIWYG realtime outdoor scene Editor & Painter
New loader now with Ogre::Terrain support: Addons for Artifex on SourceForge
MOC - Minimal Ogre Collision & Mousepicking
Simple TerrainMaterialGenerator for the use of standard Ogre material with Ogre::Terrain
Support me on Patreon
- Kojack
- OGRE Moderator

- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 538
Re: Learn some assembly
It's a book sitting on my black recliner lounge chair, almost at midnight, in a badly lit room with a fluorescent light directly overhead, photographed with a telephoto zoom lens and flash on my canon dslr.The lighting in that image doesn't seem right.
I don't like using the flash, but I didn't think it was worth getting the tripod out to photo a book which is off topic.
Without the flash the exposure time was about 2 seconds, even with image stabilising I can't hold it that steady.
Anyway...
You're not the only one.I sometimes have the impression which of course might be a very subjective one and wrong, but some things still take as long as they did years ago, apps should have a lightning fast response time by now, still there are many cases normal desktop apps lag, feel slow
I believe that with each version software should be made to work faster and better on the same hardware. In version 2 of something you find the bottlenecks, have had time to research new algorithms, learnt new optimising tricks, etc. Like how games on a console years after release are much more technically advanced than when the console is brand new, because the coders learn to take advantage of what they have better. But Windows doesn't go like that. Instead of optimising what's there, they just add more on top, requiring better hardware to keep the old stuff going.
Assembly won't help, it's the operating system that causes most of it. Although maybe windows should be written in assembly...
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
-
jjp
- Silver Sponsor

- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
- Contact:
Re: Learn some assembly
Are you being serious? Of course there is a lot of room for better operating systems but it is not the case that operating systems would slow down applications in a significant way.Kojack wrote:Assembly won't help, it's the operating system that causes most of it.
Here I really hope you are not being seriousKojack wrote:Although maybe windows should be written in assembly...
Hard disks haven't gotten much faster. That is one major point where bad responsiveness originates from. C++ compile times are high because C++ compilers are that good at optimizing. Take a C++ compiler from 10 years ago and it will run super fast in comparison. But the code produced will be a lot worse. And C++ isn't exactly a language designed for fast compilation times. Work with C# (for example) and you won't be having any forced breaks due to recompilationNauk wrote:Haha, or that- Ok lets roll it up from the other end: Looking at the last 2 decades, I sometimes have the impression which of course might be a very subjective one and wrong, but some things still take as long as they did years ago, apps should have a lightning fast response time by now, still there are many cases normal desktop apps lag, feel slow, or look at compile times: I still can have a cup of coffee for a full recompile.
Also, you're not really getting the whole picture here. If you'd compare equally complex software from today and from 10 years ago you might as well note some differences in terms of reliability and security, for example.
- Kojack
- OGRE Moderator

- Posts: 7157
- Joined: Sun Jan 25, 2004 7:35 am
- Location: Brisbane, Australia
- x 538
Re: Learn some assembly
Back around 1981 Niklaus Wirth (creator of Algol W, Pascal, Modula, Modula 2, Oberon, Oberon2, Component Pascal, and other things which haunt my nightmares) built a computer called the Lilith. Hmm, everybody made computers named after women back then: the Lilith, the Apple Lisa (named after Steve Jobs' daughter), even the Amiga was first called the Lorraine, but was changed to Amiga which is the spanish word for girlfriend (but it kept female names inside, the custom chips were called Agnes, Denise and Paula) and came alphabetically before Apple and Atari.
Anyway, the Lilith was a computer designed to run the new Wirth language Modula 2. The operating system was called Medos 2, and was written in Modula 2 (it had a windowed gui and mouse control, years before Apple released the Lisa or Mac). The cpu was even freakier, the cpu didn't use assembly, it directly ran M-Code, the vm style byte code generated by the Modula 2 compiler. It was also 4 bit and had no registers, it used a 16 word stack instead. It ran at 7MHz.
Now that's an odd computer.
It's also my idea of hell, since at university I was forced to sit through a year of Modula 2 coding, even though I already had a computer engineering associate diploma from a different college and 14 years coding experience. Argh! But the department head was on the Modula 2 international committee, so he forced most subjects to be Modula 2 related, despite being used nowhere in the real world.
No! The memories are coming back! Please make them stop!!!!!!!!!!!!!
*loud thud*
.....................
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
Re: Learn some assembly
My problem is that I'm not seeing any profiled results. If I see something like "C++ version takes 0.0312 milliseconds on average but the assembly version takes 0.0131 milliseconds on average", then that's cool.Nauk wrote: I have read several articles now where semi-experienced assembly coders, lets say 2 years + coding experience claim that their code runs myriads faster than optimized C++ and I don't think they are making it up just to get attention or because it is fun lieing.
But in other cases, people write assembly and tell you it's faster, even though they haven't written an equivalent C/C++ version and profiled it.
- Karan
- Halfling
- Posts: 62
- Joined: Wed Sep 17, 2008 1:59 pm
- Location: Berlin, Germany
Re: Learn some assembly
About 10% of Windows are written in assembly if I remember that correctly from my operating systems course. Mostly the low-level stuff (HAL etc.)Kojack wrote: Although maybe windows should be written in assembly...
And VMS was even completely written in assembler.
-
jjp
- Silver Sponsor

- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
- Contact:
Re: Learn some assembly
Now I am glad that I didn't have the "pleasure" to use any of these - but Algol wasn't all that bad, was it?Kojack wrote:Back around 1981 Niklaus Wirth (creator of Algol W, Pascal, Modula, Modula 2, Oberon, Oberon2, Component Pascal, and other things which haunt my nightmares) built a computer called the Lilith.
- jacmoe
- OGRE Retired Moderator

- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Learn some assembly
I later became an Object Pascal (Delphi) addict.. I even threw in some assembly, because it was fairly easy to mix assembly and pascal.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- syedhs
- Silver Sponsor

- Posts: 2703
- Joined: Mon Aug 29, 2005 3:24 pm
- Location: Kuala Lumpur, Malaysia
- x 51
Re: Learn some assembly
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
-
reptor
- Ogre Magi
- Posts: 1120
- Joined: Wed Nov 15, 2006 7:41 pm
- Location: Finland
- x 5
Re: Learn some assembly
Other programming languages just are not possible to use then.
Assembly programming is very much a very useful skill, you just need to be doing the right job to benefit from it.
When you shoot the assembly programming down as an unnecessary thing, consider that while it may be completely useless to you, that doesn't mean it is useless for everyone.
