We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello again.
As I am very interested in learning ARM architecture, I would have few questions regarding assembly programming. Questions refer primarily to programming Cortex-M processors, because they are the only one which I am using (at least for now).
So... Do you program in C or assembly and why that? How do you suggest to start learning assembly programming? Do you think that the gain of execution time is big enough to justify time spent for assembly programming instead of C programming (with full optimization). Because in my case, processing time is quite important. Do you maybe only use intrinsics in special cases? Or inline/embedded assembly?
Every hint is very welcome and appreciated. Thank you in advance.
Regards,
Matic
I do totally agree with peterharris.
The most efficient way I found is to write C code with intrinsics for all non-C operations (parallel arithmetic, saturation, bit/bytes reversing ...).
Also, be aware that C code final execution efficiency depends on you compiler choice and on the optimization options you use.
From my point of view, you may beat a compiler writing assembly but it would probably take you 10 times the effort.
A very simple process that you can use to be sure that your C code is efficient is to look at compiler output (disassembly listing) and to improve your C to reach better performance.
The only exception I have in mind is for Embedded Operating Systems where you need to switch contextes and directly manipulate special registers ! But this kind of code doesn't change every morning !!
Of course, I explained this in details on my blog because I went through the same questions than you do !
> A very simple process that you can use to be sure that your C code is efficient is to look at compiler output (disassembly listing) and to improve your C to reach better performance.
A usefull tool for such stuff: Compiler Explorer
This tool seems to work only with GCC compilers. Even with full optimization, I never managed to get comparable code efficiency (compared to Keil or IAR compilers).
Therefore, from my experience, if someone tries to get the most from its Cortex-M4, they should not go towards GCC.
In addition, all compilers I know allow to generate assembly listing with interlaced C source during standard compilation, you just need to ask nicely !
Thanks. I already looked at your blog and it seems very informative. I will definitely go through your posts.