Page 2 of 4
Re: Learn some assembly
Posted: Sun Feb 15, 2009 8:59 am
by jjp
jacmoe wrote:nikki wrote:Some times you can also inline some assembly into your C++ for quick hax.

I trust my optimising compiler more than I trust hand-written inline assembly.

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.
Re: Learn some assembly
Posted: Sun Feb 15, 2009 9:56 am
by Kojack
Assembly can do things c++ can't. Try calling an interrupt or reading the cpu clock counter without using assembly at some point.
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.
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
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.

Re: Learn some assembly
Posted: Sun Feb 15, 2009 1:52 pm
by Nauk
nikki wrote:You gotta just be clever then.
Anyway, I was stressing more on the learning and fun aspects.
Assembly coding makes you feel like a real man

beats growing a beard by far and to make another silly statement I think the claim that compilers make the better assembly code is a conspirative mass-excuse to have a legit reason to avoid learning and having to work with it. Back to serious, compilers will probably write the better assembly compared to a starter, but you can look and learn their weak-points and try to improve them and 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.
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:
Kojack wrote:
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
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.

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.
Re: Learn some assembly
Posted: Sun Feb 15, 2009 2:05 pm
by nikki
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.
I'm just using gvim, bash, fasm/nasm and ld (under Linux), and it's fine.

Re: Learn some assembly
Posted: Sun Feb 15, 2009 2:29 pm
by jjp
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.
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).
Re: Learn some assembly
Posted: Sun Feb 15, 2009 2:43 pm
by Kojack
Remember the Amiga API and the 4 big reference manuals?
Here's volume 1 from my Shelf Of Mystery.

All the books were useful, but the first volume covered most of the stuff you need. (My friend over the road had the others, I just had the first book)
Re: Learn some assembly
Posted: Sun Feb 15, 2009 4:59 pm
by nikki
Kojack wrote:Remember the Amiga API and the 4 big reference manuals?
Here's volume 1 from my Shelf Of Mystery.

All the books were useful, but the first volume covered most of the stuff you need. (My friend over the road had the others, I just had the first book)
The lighting in that image doesn't seem right.

Re: Learn some assembly
Posted: Sun Feb 15, 2009 6:33 pm
by Nauk
Kojack wrote:Remember the Amiga API and the 4 big reference manuals?
Here's volume 1 from my Shelf Of Mystery.

All the books were useful, but the first volume covered most of the stuff you need. (My friend over the road had the others, I just had the first book)
I wish I would have kept all the old stuff /envy

- I still have an old roll of thermo paper with the c-source of my text-editor printed out, that's all that is left.
nikki wrote: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.
I'm just using gvim, bash, fasm/nasm and ld (under Linux), and it's fine.

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:
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/
Re: Learn some assembly
Posted: Sun Feb 15, 2009 6:43 pm
by Nauk
doubt that "myriads faster" is not a strong exaggeration most of the time.
I was using that wording to underline a point, but yes it was clearly exaggerated

- I have no actual comparisons but still 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? What would be interesting to see is some real hard fact benchmarks on the subject, like this and that algorithm in hand-optimized assembly vs optimized C, C++, D, etc.
Re: Learn some assembly
Posted: Sun Feb 15, 2009 6:57 pm
by jjp
Nauk 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?
I'd say they have to find some sort of justification for themselves putting a lot of time into learning assembly

Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:02 pm
by jacmoe
Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:10 pm
by Nauk
jjp wrote:Nauk 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?
I'd say they have to find some sort of justification for themselves putting a lot of time into learning assembly

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. Sure many things are faster and machines are much more powerful, especially graphics hardware, still I don't get rid of the impression APIs get more and more bloated, slow, resources being wasted and the actual speed of software didn't rise in direct proportion to the increase of hardware power we had during that time. So if compilers are really producing that good code even taking into account a setback for "bad" c++ code, then that should not be the case, or is that argument flawed?
Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:21 pm
by jacmoe
If you dig assembly, why not use an OS written in assembly?
MenuetOS
Eh, Hardcore-Nikki?
Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:26 pm
by jacmoe
Yes, I found it!
Easy Code Cat
The joy of assembly programming and RAD, all at the same time.
Good ASM page:
http://www.jorgon.freeserve.co.uk/
Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:34 pm
by Nauk
Those are some seriously cool links & finds Jacmoe, you sure are an overabundance when it comes to digging out usefullness from all different corners of the net.

Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:42 pm
by Kojack
The lighting in that image doesn't seem right.
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.

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...
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
You're not the only one.
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...

Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:45 pm
by nikki
jacmoe wrote:If you dig assembly, why not use an OS written in assembly?
MenuetOS
Eh, Hardcore-Nikki?
O rly? I'd already seen that a
month back. You're late.
Nauk, I read the 'PC Assembly' Paul Carter book. Was pretty good.
Re: Learn some assembly
Posted: Sun Feb 15, 2009 7:53 pm
by jjp
Kojack wrote:Assembly won't help, it's the operating system that causes most of it.
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:Although maybe windows should be written in assembly...

Here I really hope you are not being serious
Nauk 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.
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 recompilation
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.
Re: Learn some assembly
Posted: Sun Feb 15, 2009 8:48 pm
by Kojack
Forget assembly operating systems, here's a really freaky one: Medos 2 on the Lilith.
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*
.....................
Re: Learn some assembly
Posted: Sun Feb 15, 2009 11:15 pm
by nullsquared
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.
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.
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.
Re: Learn some assembly
Posted: Sun Feb 15, 2009 11:48 pm
by Karan
Kojack wrote: Although maybe windows should be written in 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.)
And
VMS was even completely written in assembler.
Re: Learn some assembly
Posted: Sun Feb 15, 2009 11:49 pm
by jjp
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.
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?

Re: Learn some assembly
Posted: Sun Feb 15, 2009 11:51 pm
by jacmoe
My first bigger programming project was in Pascal. Not bad.

I later became an Object Pascal (Delphi) addict.. I even threw in some assembly, because it was fairly easy to mix assembly and pascal.

Re: Learn some assembly
Posted: Mon Feb 16, 2009 2:20 am
by syedhs
Hmm isn't the prime reason C++ compilation is slow even on fast pc because of template? Try compile a plain .C file - it is stupid blindingly fast!

Re: Learn some assembly
Posted: Mon Feb 16, 2009 2:59 am
by reptor
It sounds a bit like some people aren't considering that there are devices for which you need to code in assembly. You can't choose between C/C++ and assembly, the choice is made for you by the hardware designer.
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.