Hi
I need to implement a stack overflow handler which will disable all interrupts and then execute some instruction such as bkpt #0 in case of ARM Cortex and then enter infinite loop
void StackOverflow( ) { // disable all interrupts //todo: Indicate Overflow by write to GPIO port or an LED __asm volatile("bkpt #0"); // breakpoint here for(;;) { }}
Is there similar instruction in RH850 to do this similar to bkpt #0 in case of ARM Cortex?
Thanks,
The equivalent RH850 assembly instruction that you are looking for is the DBTRAP insn, but I'm not sure that is the appropriate action to take based on a stack overflow detection.
asm( "dbtrap" ); // GHS in-line assembly
As this insn is used to implement software breakpoints, using this to throw a run-time exception would seem ill-advised.
It might be better to use something like SYSCALL, TRAP, or FETRAP to handle this condition.
ok noted, thanks very much for point it out . I will try out the TRAP or SYSCALL or perhaps HALT and see how it works