#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 a subroutine or return from an interrupt). This may be useful if you care about the return instruction itself or if the code has to fall through to the first instruction of the next function.

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

Note: If this feature is used to fall through to the next function, smart linking has to be switched off in the Linker, because the next function may be not referenced from somewhere else. In addition, be careful 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 example in the following listing places some functions into a special named segment. All functions in this special code segment have to be called from an operating system every 2 seconds after each other. With the pragma some functions do not return. They fall directly to the next function to be called, 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