16-bit stack on HC908 CodeWarrior

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

16-bit stack on HC908 CodeWarrior

跳至解决方案
2,728 次查看
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.
标签 (1)
标记 (1)
0 项奖励
回复
1 解答
1,038 次查看
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 项奖励
回复
3 回复数
1,038 次查看
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 项奖励
回复
1,038 次查看
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 项奖励
回复
1,039 次查看
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 项奖励
回复