Files
Diddy-Kong-Racing/src/get_stack_pointer.c
T
Ryan MyersandGitHub afb264bc16 Match stack_pointer with C code (#530)
* Remove useless comment

* Small amounts of documenting, official names, and use some new knowledge to match what was previously thought to be only possible with hasm.

* Define the proper type for the stack_pointer function, and come up with a solution for GCC builds that should hopefully work.

* Partial revert to support getting the actual stack pointer for GCC builds

* Come up with a better GCC build option for getting the stack pointer

* Update the score
2025-04-25 15:40:33 -04:00

22 lines
474 B
C

#include "memory.h"
#ifdef __sgi
/**
* Uses IDO specific -dollar compiler flag to get the current stack pointer.
* Official Name: diCpuTraceCurrentStack
*/
StackInfo *stack_pointer(void) {
return (StackInfo *) __$sp;
}
#else
/**
* Uses GCC specific code to get the current stack pointer.
* Official Name: diCpuTraceCurrentStack
*/
StackInfo *stack_pointer(void) {
register StackInfo *sp;
asm volatile ("move %0, $sp\n": "=r"(sp));
return sp;
}
#endif