mc9s08rd32dwe move the stack

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mc9s08rd32dwe move the stack

2,810 Views
jah
Contributor I
HI:

how do i move the stack to a new ram location?
where is it declared loaded?

thanks!
Labels (1)
0 Kudos
4 Replies

405 Views
peg
Senior Contributor IV
Hi jah,
The answer is by writing to the Stack Pointer Register.
It defaults to $00FF.
Usually use TXS as in:
 
*********** Move Stack to top of RAM ****************************************
  LDHX #RamLast+1  ;point to 1 past end of RAM
  TXS    ;SP<-(H:X-1)
If the question was, How do I do this in Codewarrior? please post in the Codewarrior Forum.
 
Regards
David
0 Kudos

405 Views
admin
Specialist II
Here's an example of a .prm file:
 
Code:
/* This is a linker parameter file for the QB4 */NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. */SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */    Z_RAM                  = READ_WRITE   0x0080 TO 0x00DF;    STACK0                 = READ_WRITE   0x00E0 TO 0x00FF                             FILL 0xAA;    ROM                    = READ_ONLY    0xEE00 TO 0xFDFF;    ROM1                   = READ_ONLY    0xFFB0 TO 0xFFBD;    ROM2                   = READ_ONLY    0xFFC2 TO 0xFFCF;ENDPLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */    DEFAULT_ROM,    ROM_VAR,    STRINGS                INTO  ROM; /* ROM1,ROM2 In case you want to use ROM1,ROM2 as well, be sure the option -OnB=b is passed to the compiler. */    FAR_RAM,    _DATA_ZEROPAGE,    MY_ZEROPAGE,    DEFAULT_RAM            INTO  Z_RAM;    SSTACK                 INTO  STACK0;END/* STACKSIZE 0x20 */STACKTOP                   0x00FFVECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */

 
The lines you need to be concerned about are:
 
"Stack0..." define you stack space
"SSTACK" tell the linker where your stack space is
"STACKTOP"  where the stack pointer will start.
 
Hope this helps,
Tomahawk
0 Kudos

405 Views
jah
Contributor I
thanks Tomahawk
0 Kudos

405 Views
Lundin
Senior Contributor IV
Check the .prm file and the CW manual.
0 Kudos