Hi,
Being new to the fascinating ARM world, I am going through various documentation and reading material.
I read that the ARM Cortex-M processors (or I think it applies to all the Cortex processors) are entirely C programmable. This means that assembly code is not required for start-up code and for ISRs.
I am curious to find out what prohibits the earlier ARM processors (or even other architectures) to write the start-up code in C? Are these any specific instructions? One which I found was the WFI (Wait For Interrupt) which can't have an equivalent in C. But that is not a start-up or ISR instruction.
Thanks for your support !
Gopal
Thanks for the useful examples and information .
One question: the stack array is declared as "char". I think C compiler could allocated this in non-word aligned addresses. And for AAPCS requirement you might possibly want to make the stack aligned to double word boundaries. So would it be better to declare it as a double word array?
uint64_t stack[64]; // 512 bytes
or use some other attribute to force double word data alignment?
regards,
Joseph
(I didn't have enough coffee today so I might have miss something )
You're correct, I forgot the alignment attribute in this "example" (e.g. alignas), though it's probably better not to take the example too serious anyway since, as I mentioned it's rather brittle. Code that requires optimization to be enabled and crashes if it's not would typically be frowned upon I think.
I'm no fan of the mandatory dword stack alignment. When targeting cortex-m3 processors where dword alignment has absolutely no benefit I don't want to waste stack space. If I ever move my code to a processor that does care, I'll recompile. The alignment assumption is, if I'm not mistaken, indicated in an attribute in the compiled object so if someone accidently tries to link together code with incompatible assumptions it should give a linker error.