This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UCD3138: Lab examples: inconsistence between linker command and asm loader

Part Number: UCD3138

hi, I'm having a closer look at Lab example cyclone.cmd and loadUCD3138.asm files

the linker command file says:

RAM_PGM_AREA	(RW) : org = 0x00019000, len = 0x00000080
RAM       		(RW) : org = 0x00019080, len = 0x00000DF0
STACKS    		(RW) : org = 0x00019E70, len = 0x00000190
	
.bss            : {} > RAM                       		 /* Global & Static vars	  */
.stack          : {                              		 /* total = 400 = 0x190       */
                    _StackUSER_  = .            + 184;   /* USER                      */
                    _StackFIQ_   = _StackUSER_  + 112;   /* FIQ                       */
	                _StackIRQ_   = _StackFIQ_   + 84;    /* IRQ                       */
                    _StackABORT_ = _StackIRQ_   + 4;     /* ABORT                     */
                    _StackUND_   = _StackABORT_ + 4;     /* UND                       */
                    _StackSUPER_ = _StackUND_   + 12;    /* SUPER                     */
	             } > STACKS                      		 /* Software System stack 	  */

while load assembler:

SUP_STACK_TOP   .equ	0x19ffc ;Supervisor mode (SWI stack) starts at top of memory
FIQ_STACK_TOP	.equ	0x19e00 ;allocate 256 bytes to supervisor stack, then do FIQ stack
IRQ_STACK_TOP	.equ	0x19d00 ;allocate 256 bytes to fiq stack, then start irq stack
USER_STACK_TOP	.equ	0x19b00 ;Allocate 512 bytes to irq stack, regular stack gets rest, down to variables

should the addresses and ranges from the linker match with those from assembler?

  • Hi Tomasz, yes they should.  The stack pointer is set in the load.asm file.  So the desired stack size should be put into the .cmd file so that the linker will warn you when the variables expand into the stack space.  It's not really necessary to put in all the other stack sizes in the .cmd files

    Probably you can change the load.asm to put use the _StackUSER labels from the .cmd file, but right now they're not connected.   The load.asm and the .cmd files were developed separately and have not been connected.  

  • ok, I'll clean it up and post solution for it. Could you please answer me one more question: in Code Composer you can also set the stack size in linker options. Is it user stack or all stacks together?

  • Tomasz, I don't know.  Whatever stack size is there is attached to the generic C start up function provided with the compiler.  That function was a monster that was ready to initialize C sharp and things like heap, so I butchered it into what you see in load.asm.  So I'm responsible for the disconnect on the stacks.  Although the standard initialization only initializes the user stack, I believe, so it doesn't handle what is necessary.