This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Getting the stack pointer on VxWorks/MIPS


Hello all,

I found a nice looking piece of code for VxWorks that can help to track
memory problems, however, the code has some 64K asm in it, I wanted to try
to get the routine to work on MIPS using inline asm.

The old code is commented out at the top, and my attempt at replacing it is
underneath, I've tried to combine x86 inline asm g++ tutorials I have
googled and MIPS assembler tutorials, and I don't imagine I am too far off
the mark.

Can anyone offer any help?


long getStackPointer(void)
{
 /* assembly routine to return stack pointer value */
 /*
	static const short code_array[] = {
	
0x4e56, 0000,		// LINK.W  A6,#0
	
0x200F,			// MOVE.L  A7,D0
	
0x4e5e,			// ULNK    A6
	
0x4e75			// RTS
                                   };

 	return (((long(*)()) code_array)());
 */

	static long n_stack_address;
 
	asm	(
			"move %%29, %0\n"			// $29 and
$sp mean the same thing
			:"=r"(n_stack_address)
		);

	return n_stack_address;
}// end getStackPointer


Many thanks for any help!

Regards,

Gareth

*******************************
* http://planetearthworm.com/ *
*******************************


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]