Part Number:TMS320C5517
Tool/software: TI C/C++ Compiler
Hi,
I was instantiating a large class containing multiple large sub classes (Class ~40Kbytes).
I am using placement new, as the class is too big for the standard allocator, so I provide a buffer from external memory.
example (myBuf is a void * to external memory):
myClass = new (myBuf) BigClass;
When I trace through this instantiation with the disassembly I get the following
The code goes through calling the constructors for the various sub classes, and initialised arrays,
but after a point the offset from the base address (0x400000, where the buffer in external RAM starts) becomes negative, and it tries to write to 0x38xxxx which is not in valid memory space.
See the AMAR *+AR0(#xxxx) calls below to see what I mean:
BigClass:
01291b: 4efd AADD #-3,SP
01291d: c404 MOV T0,*SP(#02h)
01291f: eb0085 MOV XAR0,dbl(*SP(#00h))
012922: ed00bf MOV dbl(*SP(#00h)),XAR3
012925: 90b0 MOV XAR3,AC0
012927: 041011 BCC C$L76,AC0 != #0
01292a: 768ef848 MOV #-28936,T0
01292e: 6c034117 CALL operator new
012932: 9080 MOV XAR0,AC0
012934: eb0008 MOV AC0,dbl(*SP(#00h))
012937: 6d000f34 BCC C$L77,AC0 == #0
C$L76:
01293b: 08dcab CALL message_interface
01293e: ed00af MOV dbl(*SP(#00h)),XAR2
012941: ec31be01f80c AMAR *(#01f80ch),XAR3
012947: eb41b5 MOV XAR3,dbl(*AR2)
01294a: ed008f MOV dbl(*SP(#00h)),XAR0
01294d: b40f7578 AMAR *+AR0(#7578h) <= offset is 0x7578 + 0x400000 = OKAY
012951: 08f266_3f14 CALL SDateTimeData || MOV #-1,T0
012956: ed008f MOV dbl(*SP(#00h)),XAR0
012959: 7a00010a MOV #1 << #16,AC0
01295d: 7600f858 MOV #248,T1
012961: 7e057900 OR #1401,AC0,AC0
012965: b40f7640 AMAR *+AR0(#7640h) <= offset is 0x7640 + 0x400000 = OKAY
012969: 6c031068_3da4 CALL __anew || MOV #10,T0
01296f: ed008f MOV dbl(*SP(#00h)),XAR0
012972: 7600a258 MOV #162,T1
012976: 7a00010a MOV #1 << #16,AC0
01297a: b40f7ff0 AMAR *+AR0(#7ff0h) <= offset is 0x7ff0 + 0x400000 = OKAY
01297e: 7e058700 OR #1415,AC0,AC0
012982: 6c031068_3da4 CALL __anew || MOV #10,T0
012988: ed008f MOV dbl(*SP(#00h)),XAR0
01298b: 7600ae58 MOV #174,T1
01298f: 7a00010a MOV #1 << #16,AC0
012993: b40f8644 AMAR *+AR0(#-79bch) <== this seems to be where XAR0 offset backwards to invalid memory 0x3F8644?
012997: 7e059500 OR #1429,AC0,AC0
01299b: 6c031068_3d34 CALL __anew || MOV #3,T0
0129a1: ed008f MOV dbl(*SP(#00h)),XAR0
0129a4: 76007258 MOV #114,T1
0129a8: 7a00010a MOV #1 << #16,AC0
0129ac: b40f884e AMAR *+AR0(#-77b2h)
0129b0: 7e05a300 OR #1443,AC0,AC0
0129b4: 6c031068_3d34 CALL __anew || MOV #3,T0
There is no error in the code execution, and I just find that the last part of my class structure is not properly constructed!
(Interestingly in code composer studio, when I view the memory location of these areas, it gives the correct value, which is confusing when you are debugging (i.e. CCS shows that the variable is at 0x408664, but the assembler is trying to write to 0x3F8644).
Is this a known limitation of the compiler? I am using TI compiler 4.4.1 and TI BIOS 5.4.2.