Stack Address Change

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I am trying to force stack in a 256 byte part to start at a different address, eg. resize it.

   

 

   

In Compiler/Linker manual I can find a command line way to do it, but would rather have

   

this done by project settings.

   

 

   

-dram_end:<address>    Define the end of the data area. The startup file uses this argument to ini-
                                        tialize the value of the hardware stack.

   

 

   

How would I go about this ?

   

 

   

Regards, Dana.

0 Likes
7 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Dana, when you are using ImageCraft the stack begins at low address after the last global var and advances up to 0xff.

   

So if you define a placeholder var (global, uninitialized) you will get the wanted effect.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Actually I don't think thats true, my stack starts at 0x80 in a 256 byte part,

   

and globals + API >> 128 bytes.

   

 

   

There must be a way to set stack address......

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I found this in Help -> Documentation -> Compiler and Programming Documents -> C Language Compiler User Guide.pdf

   

 

   

Bob 

0 Likes
lock attach
Attachments are accessible only for community members.
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Hello Dana,

   

 

   

I have a simple workaround to force stack start address to a particular RAM location - but I do not recommend it, just if you are desperate 🙂 ..

   

 

   

Open 'boot.tpl' file in either designer or notepad. Most probably, Line 212 (or search for 'Set up the stack' - refer attached figure). You will find that stack pointer, SP being initialized there. It is all yours, just edit it to your need 🙂

   

 

   

For LMM devices, (with more than >256 bytes of RAM), you get an option in the compiler settings for moving the stack stack address in the last page of RAM - this also can be found and edited in boot.tpl.

   

 

   

Regards,

   

MSUR

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I saw that in tpl as well, but did not use because it states it is a temporary stack start

   

address. I wound up using script in custom.lkp file, and the command -dram_end:<address>

   

 

   

Regards, Dana.

0 Likes
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

For large memory models, yes it is temporary. For a 256 byte device, it is where stack starts.

   

 

   

Even for LMMs, if you do a CTRL+F and search 'stack' in the file, you will find all the stack related assignments. For LMMs, the extra stuffs, that are done are basically initialization of the various page pointers, IDX_PP, CUR_PP, STK_PP etc.

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Thanks MSUR for the clarification.

   

 

   

Seems to me Imagecraft could spend a little more time on documenting their

   

compiler/user manual and illustrated examples of linker mods and optimization

   

techniques. Also would be nice if someone brings stackwalk up to date as well.

   

 

   

Regards, Dana.

0 Likes