We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 46408

13.4 EDK - How to access registers in SDK C-Code


Some registers, especially the dedicated ones (e.g. the stack pointer), may be useful to reference within C-code. How can I access them?


One way to do this,is to use assembly. For MicroBlaze, the instruction to access the stack pointer would be:

register int *stack_ptr asm("r1");

This will grab the dedicated register (r1 in MicroBlaze), and put it into a register-int data type. You can now reference the pointer to get the data at the stack address, print the stack address, or other functions.

To print this address, cast the stack_ptr type to a void, like follows:

printf("This is my stack pointer: %p", ( void * )stack_ptr);
AR# 46408
Date 12/15/2012
Status Active
Type General Article
  • EDK - 13.3
  • EDK - 13.4