Other Parts Discussed in Thread: TMS320F28235
Tim Love suggested that I cross-post this, in case somebody recognizes this as a known bug.
I'm working with a TMS320F28235, writing assembler with CCS3.3, debugging with an XDS510LC. If I push the ACC when the SP is odd, it overwrites the previously pushed value. 32-bit pushes will word-align, and if the stack pointer is odd,
that means that the pushed value will destroy the word at the top of the stack.
Calling a subroutine with SP odd doesn't cause trouble, even though it's a 32-bit
push. The workaround is straightforward (keep the SP even), but I couldn't
find this bug in any discussion.
Here's a snippet:
KillDP: ;start with even SP (0x08 in this case)
PUSH DP ;SP now 0x09
PUSH ACC ;SP now 0x0B, but ACC written to memory 0x08:0x09, overwriting DP
POP ACC ;ACC restored properly, SP now 0x09
POP DP ;but DP value is now incorrect (has AL's value)
LRETR ;will return correctly, but with incorrect DP
I can watch this happening with the debugger, monitoring the SRAM as the PUSH ACC instruction overwrites the DP value. Seems more of a hardware bug than a tools
problem, but you never know.
SPRU430E states in section 2.2.5 (somewhat cryptically) that "When values are being saved to the stack, the SP is not forced to align with even or odd addresses.
Alignment is forced by the memory wrapper or peripheral-interface logic."
The obvious fix is to replace "PUSH DP" with "PUSH DP:ST1", but still, if this is a real hardware problem, it should be addressed, yes?
-Jim MacArthur