Does anyone have an example of how to inline Assembly instructions for PPC440GX processor?
Thanks,
Does anyone have an example of how to inline Assembly instructions for PPC440GX processor?
Thanks,
It's compiler-specific.
If you understand what you're doing, you're not learning anything.
ok, how about for gcc compiler?
Have you even tried google?
http://www.google.com/search?hl=en&q...=Google+Search
If you understand what you're doing, you're not learning anything.
Similarly, you also then need to search for some processor reference manuals so you know what opcodes to use, what the names of the registers are etc etc.
Or maybe you can tell us why you feel the need for assembly language at all?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
There is an assembly instruction in PPC440GX manual, that counts leading 1's and 0's of any unsigned long integer.
My boss asked me to research this posibility, so that we do not write a separate "C" routine with a loop that would count leading 1's.
With this implementation I'll have just 3 instructions excecuted once, instead of 4 instructions excecuted up to 32 times.
Ah, good old premature optimisation at work.
Have you done any profiling to determine just how significant this particular part of the problem is?
How about looking at this thread for more ideas without having to resort to assembler just to get at an instruction which will only save a small amount of time.
> instead of 4 instructions excecuted up to 32 times.
Or how about two comparisons and up to 8 times - any better?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
If you disassembled that piece of code, it would turn out to be more than just 2 comparisons up to 8 times.
In addition to setting up the variables, and the loop, there are 2 increments, a shift, and a 2 compare. While it looks pretty in C, it is still quite inefficient when compared to the 1 specialized assembly instruction that does exactly what I am looking for.
Um....then read the manual for the processor. It's not like we have every processor's opcodes memorized. The processor manual should show you everything you need to know including instruction timings and so forth.
You have code which works - stop worrying about it and work on another part of the project thats not implemented yet, or has bugs, or needs more features, or is far more time critical than this.
How many hours / days / weeks are you going to spend getting this 3-line assembler insert to work ?
I'm guessing your 'cost' to the company - salary, taxes, insurance, overheads etc are somewhere between $50 and $100 per hour. They'll be the most expensive lines in the whole system - better put them in a nice frame and hang them on the wall for all to admire.
> My boss asked me to research this posibility
Say "yes it's possible, but it's going to be expensive".
What you're not likely to get is a nice free lunch where someone takes the time to do your job of looking stuff up in the manual and reading a few howto's for your commercial benefit.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
But isn't that taking into account not using optimization? The compiler can probably optimize better than you could. Especially since you don't even know how to use it. Chances are you're better off optimizing something else - like an algorithm. You'd save a great deal more doing that than trying to optimize some little component.Originally Posted by edunia11
Last edited by Frobozz; 09-13-2006 at 02:15 AM.
The basic problem is he's let the PHB near the manual and he's gone "hey, what about ...."
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.