hi all,
I am on the learning stage of LPC2148 and I have done basic programs like interrupts ... ADC ... TIMER/COUNTER. But all the code I have written is in C Language.
Though I had written some basic progarams of LED in assembly but not the interrupt part.
Could any one here tell me what are the rules to write the assembly code for interrupts i.e. for FIQ, IRQ and NV IRQ.
If possible plz guide me with some source code.
I am using KEIL uvision 4.
Arvind Shrivastava
There is no difference. All you need to make sure is that you do the right thing - namely, acknowledge the interrupt, don't loop etc. - just like in C. Why bother with assembly? time critical stuff? code size? isn't the optimization of the compiler good enough? something?
"Why bother with assembly?"
Be serious.
It is still possible for a proficient writer of assembler to produce faster and smaller code than can be created by the best compilers.
And it's possible for a carpenter or sculptor to do a better job with just a knife than with all the power tools in this world.
A good assembler programmer beats a compiler for most processors. For some processors, the complexity of the processor pipeline is so high that it takes an exceptional assembler programmer - or one with all the time in the world - to keep up.
But an important issue is: Program in assembler to learn assembler? Or program in assembler because it's cool? Or program in assembler because it's needed? Quite a lot of projects manages quite well without any assembler involved, since it's very few times when you get a significant improvement (i.e. where the size or speed difference really matters) from using assembler.
"But an important issue is: Program in assembler to learn assembler? Or program in assembler because it's cool? Or program in assembler because it's needed?"
It is a very useful for an embedded engineer to be aware of what goes on under the hood so they can understand what the compiler is doing and how they might effectively carry out debugging tasks - You just need to look at the numerous posts on this forum regarding 'lost watch variables' and optimizations to see the need for such things.
Unfortunately the want or need to understand assembler seems to be dying and is considered to be terribly un-cool. It often get's the "no-one needs assembler anymore". That's not good for future developments.
But there is a bit of level difference between speaking assembler fluently, and just read it decently. Less people needs to be fully up-to-speed writing in assembler now than 10 years ago.
Guys! ... Please dont argue for which is better 'C'(HLL) or assembly ... I had just asked if some one can guide me for writing interrupt routines in assembly.
No doubt Assembly is the best but requires more exposure and experience then high level language for writing OPTTIMIZED & efficient code.
Hope some some guidance will come out form you all beautifull minds.
The simplest course of action for you to pursuit is:
1. Write it in C, compile with minimum optimization and observe the generated compiler code (see "listing" tab). 2. Have the assembly guide at hand as reference.
S Steve said:
It is a very useful for an embedded engineer to be aware of what goes on under the hood so they can understand what the compiler is doing and how they might effectively carry out debugging tasks.
---
Totally agree with that concept, and not just for programming. If only my wife could be persuaded to understand what was going on "under the hood". She might then have realised that the "funny sound coming from my engine when I go up the hill" was actually an expensive to fix slipping, soon to be burnt out, clutch!
View all questions in Keil forum