Getting the stack pointer on VxWorks/MIPS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux