#pragma NO_RETURN: No Return Instruction

Scope

Function

Syntax
  #pragma NO_RETURN 
  
Synonym

None

Arguments

None

Default

None

Description

This pragma suppresses the generation of the return instruction (return from subroutine or return from interrupt). Use this pragma when you care about the return instruction itself or when you want the code to fall through to the first instruction of the next function.

This pragma does not suppress the generation of the exit code (e.g., deallocation of local variables or compiler-generated local variables). The pragma suppresses the generation of the return instruction.

Note: To use this feature to fall through to the next function, you must switch off smart linking in the Linker, because the next function may be not referenced from somewhere else. In addition, ensure that both functions are in a linear segment. To be on the safe side, allocate both functions into a segment that only has a linear memory area.
Example

The following listing places some functions into a special named segment. An operating system calls each function two seconds after calling the previous function. Using this pragma, functions do not return, but fall directly through to the next function, saving code size and execution time.

Listing: Blocking Compiler-Generated Function Return Instructions
#pragma CODE_SEG CallEvery2Secs
#pragma NO_RETURN

void Func0(void) {

  /* first function, called from OS */

  ...

} /* fall through!!!! */

#pragma NO_RETURN

void Func1(void) {

  ...

} /* fall through */

...

/* last function has to return, no pragma is used! */

void FuncLast(void) {

  ...

}
See also

#pragma NO_ENTRY: No Entry Code

#pragma NO_EXIT: No Exit Code

#pragma NO_FRAME: No Frame Code