This is not something I have come across before, but have not used the
Greenhills compiler. I will need to investigate more - if you find more
information then please post again here. If another register is added
to the list then the stack will be misaligned when vTaskSwitchContext is
called - so if you add more add another 2, not another 1.
The manual does not indicate there is an issue with having a single
register. Quoting from the manual:
“Is a list of one or more registers to be loaded or stored, enclosed in
braces. It can contain register ranges. It must be comma separated if it
contains more than one register or register range”
and
“Restrictions
In these instructions:
Rn must not be PC
reglist must not contain SP
in any STM instruction, reglist must not contain PC
in any LDM instruction, reglist must not contain PC if it contains LR
reglist must not contain Rn if you specify the writeback suffix.”
If you write an STM or LDM instruction with only one register in reglist, the assembler automatically substitutes the equivalent STR or LDR instruction. Be aware of this when comparing disassembly listings with source code.
You can use the --diag_warning 1645 assembler command-line option to check when an instruction substitution occurs.
I just scanned through for all occurrences of the instruction and come
across statements like this:
“If the list contains more than one register, the instruction is
assembled to encoding T1 or T2. If the
list contains exactly one register, the instruction is assembled to
encoding T1 or T3.”
but later…
“Encoding T2 does not support a list containing only one register. If an
STM instruction with just one
register
This seems to back up your assertion - the instruction is just changed
to an equivalent.
Hi guys thank you for the ideas i have tried to replace the instructions with the respective LDR and STR instructions but it goes directly into a hardfault, so we have decided to stay with the STMDB and LDMIA instructions and ignore the warning for now.
Looking at the assembly generated with the Green Hills compiler it looks like it is leaving in the STMDB and LDMIA commands.
If any of you have the assembly from keil i would love to see what it does to this instruction, i will try with GCC myself later today, and report back here with the code it generates.
0x000058F8 F84D3D04 STR r3,[sp,#-0x04]!
In any case I think it preferable to push two registers as in fact that
would result in an 8-byte stack alignment inside vTaskSwitchContext() -
in case future compiler versions object to something in that function
with only a four byte alignment.