16-bit stack on HC908 CodeWarrior

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

16-bit stack on HC908 CodeWarrior

Jump to solution
2,068 Views
antgalimbe
Contributor I
I have tried to move the stack pointer in a Tiny program outside the zero-page memory but I have discovered that the program crash.
I see the disasseble of the C-code and I discovered that the C-compiler of Codewarrior assume the stack in zero-page.
Is possible to tell to the compiler to assume the stack outside the zero-page?
The actual project run on HC908JL8.
Labels (1)
Tags (1)
0 Kudos
1 Solution
378 Views
CompilerGuru
NXP Employee
NXP Employee
The memory model only defines the default way how data are allocated.
If you want the stack to be outside the zero page, I would suggest to use the small memory model. With this, normal, non qualified pointers will be 16 bit and they can therefore point to objects on the stack.
Then place your globals explicitely into a section in the zero page
Put a

#pragma DATA_SEG SHORT _DATA_ZEROPAGE

before the declaration and before the definition of them, and terminate the area with a

#pragma DATA_SEG DEFAULT

PS: To switch the memory model, you have to adapt the compiler/assembler memory model option and to pick the right library. Create a project witht the new project wizard to get a sample, if needed.

Daniel

View solution in original post

0 Kudos
3 Replies
378 Views
CrasyCat
Specialist III

Hello

According to the HC08 compiler manual "In the TINY memory model, all data including stack must fit into the zero page."

This is the definition of the memory model and cannot be changed.

CrasyCat

0 Kudos
378 Views
antgalimbe
Contributor I
Thanks for your answer. My hope was to find an option to allow only the stack outside the zero-page and not all the data.
0 Kudos
379 Views
CompilerGuru
NXP Employee
NXP Employee
The memory model only defines the default way how data are allocated.
If you want the stack to be outside the zero page, I would suggest to use the small memory model. With this, normal, non qualified pointers will be 16 bit and they can therefore point to objects on the stack.
Then place your globals explicitely into a section in the zero page
Put a

#pragma DATA_SEG SHORT _DATA_ZEROPAGE

before the declaration and before the definition of them, and terminate the area with a

#pragma DATA_SEG DEFAULT

PS: To switch the memory model, you have to adapt the compiler/assembler memory model option and to pick the right library. Create a project witht the new project wizard to get a sample, if needed.

Daniel
0 Kudos