Hello,
i have a problem with the C2000 Code Generation Tools 5.2.7. When using the compiler option --opt_for_space it is possible that invalid code is produced. Normally the epilog of a function looks like this:
SUBB SP,#22
MOVL XAR3,*--SP
MOVL XAR2,*--SP
MOVL XAR1,*--SP
SPM #0
If opt_for_space is enabled the compiler is using the function "_epilog_c28x_2" in some circumstances. In this function the P register is used to modify the stack pointer. But when the modified value is written back into SP, this value can be modified by the PM bits in status register ST0. The function does not ensure that PM is set to 1 (= no shift).
_epilog_c28x_2:
MOV PL, @SP
SUBUL P, @XAR0
MOV @SP, P
MOVL XAR3,*--SP
MOVL XAR2,*--SP
MOVL XAR1,*--SP
LB *XAR7
The line "MOV @SP, P" produces the error (see images below)
Is this a known problem? Is it fixed in newer code generation tools versions? I looked into the defect history but found nothing.
Best regards
Simon