.data initializes ram!

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

.data initializes ram!

1,153 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Thu Aug 15 12:45:51 MST 2013
.data is supposed to be uninitialized, Right?
 
.bss // is supposed to be initialized to zero, right?
.word 1 // .word in .bss section requires but ignores the argument of 1. .word 2 is still 1 word.

.data also changes .word
.word 1 // requires argument and initializes this word to 1.
.space 4 // allocates word but initializes it to zero.

So where does the doc show how to define data that is not initialized?
0 项奖励
回复
4 回复数

1,134 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Thu Aug 15 13:58:29 MST 2013
OK I understand this now.

My question should have been how do I allocate uninitialized, none zeroed ram with labels that the assembler creates and the linker can use?

Do I need a new post?
0 项奖励
回复

1,134 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Thu Aug 15 13:55:17 MST 2013
That is correct.

.data is initialised
.bss is zeroed

Only the heap and stack are uninitialised.

If you have data initialised to zero, that is because how it has been initialised in your program.

For more infor, look on Wikipedia
http://en.wikipedia.org/wiki/Data_segment
0 项奖励
回复

1,134 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cwpjr on Thu Aug 15 13:20:59 MST 2013
My code is assembly in a .s file.
Called from main();
Both .data and .bss are initialized to zero at the entry to main breakpoint in the debugger.
.data stuff is first, then .bss stuff.
Only the Ram after the .bss is uninitialized.
0 项奖励
回复

1,134 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mc on Thu Aug 15 13:01:00 MST 2013
Hi cwpjr,
Actually the global and static variables initialized in your program will go to .data segment. All these variables will have an initial value as assigned by you in your program(code).
global and static variables that are not initialized in your program will go to .bss segment. Because sometimes uninitialized variables could be dangerous, these variables are initialized
to zero by the tool .

Hope it helps.

0 项奖励
回复