Hi,
I need to :
1. Inline an assembly code that modifies Stack pointer directly (__asm directive is not allowed to modify stack pointer) in a C++ file.
What is the best option? A function call to a label is not an option since I need to manually update Stack Pointer. I need to inline.
I read I can create SRC file. Can I create SRC from the C++ compiler ? if so what is the Directive/Flag? --SRC didn't work.
#prama asm was unrecognized pragma. perhaps because I'm not creating SRC.
Thanks.
I need to work around a HW bug by manipulating Stack, Stack Pointer, LR and other ARM core registers manually. I'm using ARM compiler/linker/assembler.
This needs to be inlined since a function call will modify my LR.
What I need is a way to inline an assembly code that is capable of modifying SP, Stack and other core registers. __ASM inline doesn't allow modification of Stack.
Possible solution:
1. I read #pragma ASM is one option. But requires SRC, I don't know what the compiler flag is to generate SRC file. Can you point me to the right info?
2. A way to inline a function/label in .s file.
3. Open to suggestions...
__set_PSP(stack) and __set_MSP(stack) both will change the appropriate Stack pointer. They also are "inlined" and do not change the LR. The LR was never mentioned in the original question.
CMSIS-CORE provides "inlined" access to many registers. The above is the best way to modify the stack pointer inline without modifying the LR.
What is SRC?
What core and errata are you talking about, please cite, the respondents here aren't psychic, and you are being far to vague and non-specific. Give an example where these needed to be applied to provide some use case context. ie if you don't muddle the LR/SP then the core explodes.
Chronic failures in the core are typically addressed by compiler code generators, and options, to resolve critical instruction sequences, or interactions, etc.
Add whatever functions you want into the startup_arch.s file, EXPORT the names you wish to call from C/C++ source code.
Thanks Robert,
You are correct. LR was not mentioned. I will be using intrinsic to manipulate SP and such.
www.keil.com/.../armcc_chr1359124993137.htm
How about pushing R0-R7 into Stack? I need to do that manually as well. Didn't see a intrinsic for that.
What I did was wrote a function to push a single register (specified as an argument) and call it eight times for all eight registers.
It all compiled and linked fine.
didn't work though. Then I realised it was a dumb idea and I didn't have sufficient of understanding what was required.
When I did acquire the knowledge, I found it was totally the wrong way to do it. And the added advantage of understanding it was that I then knew how to do it and didn't need to post any cryptic questions on any forums.
Thanks for your useful and very helpful answer Keith...
Regardless , I worked around the problem.
And of course cannot be bothered to explain what that workaround (or, for that matter, the actual problem) was. Do you really think that's the right approach to thanking the public for trying to help you?
Unnecessary comments like yours and Keith are disappointing to see in threads. I appreciate people (other folks that helped on this thread) who genuinely attempt to help instead of mocking. A simple "can you post your findings" would do.
You have to read the whole thread to see what the problem was. In case you don't want to be bothered with it or give you more reason to post comments like before... read below:
GCC allows for inline assembly that modifies Stack(push/pop and SP). ARM RVCT doesn't allow it.
1. I needed to save LR,and content of R0-R7 onto stack. Don't ask "why you need to do that". It was a HW issue work around. 2. Calling an assembly routine will modify LR so I wanted to figure out a way to inline a function in .s file to avoid modifying LR .
What I ended up doing is calling a subroutine with LR passed as a parameter. And that subroutine pushed passed LR and other registers onto stack.