tags:

views:

509

answers:

3

I have a linker command file that assigns the top address of the stack into a variable

_stack = . + 0x80000;

I want to use this address in a 'c' program - I want to copy the stack to another location and then update the stack pointer to point to the new location before doing a destructive memory test on the orginal bank of RAM.

I'm finding that if I do something like

extern u32 *_stack;  
myFunction(_stack);

Then the function seems to get passed the value stored at the stack location

lwz r3,0(r8)

Rather than the address of the stack itself. Can anyone help?

A: 

*myFunction(&stack); should pass myFunction the address of the variable * stack. Else, it will pass the value contained in the variable *stack.

Paul Nathan
+4  A: 

Try

extern u32 _stack;
U32 * stackPtr;
stackPtr = &_stack;
Mark Ransom
+1  A: 

I believe the most natural [ie: correct] way to declare this is based on the notion of thinking of the stack as an array in memory with the stack pointer being a location within that array:

extern U32 _stack[];
U32 *stackPtr;
stackPtr = _stack;
Tall Jeff