User`s guide
Recommended and Required Source Changes
3.3 Flow Control Mechanisms
3.3.5 Modifying the Return Address
The compiler detects any attempt to modify the return address on the stack and
flags it as an error.
Recommended Change
Rewrite the code that modifies the return address on the stack to return a status
value to its caller instead. The status value causes the caller to either branch to a
given location or contains the address of a special .JSB_ENTRY routine the caller
should invoke. In the latter case, the caller should RSB immediately after issuing
the JSB to a special .JSB_ENTRY routine.
For example, the compiler would flag the following code as requiring a source
change.
Rout1: .JSB_ENTRY
.
.
JSB Rout2 ; Might not return
.
RSB
Rout2: .JSB_ENTRY
.
.
MOVAB continue_label, (SP) ; Change return address
.
RSB
You could rewrite the code to incorporate a return value as follows:
Rout1: .JSB_ENTRY
.
.
JSB Rout2
TSTL R0 ; Check for alternate return
BEQL No_ret ; Continue normally if 0
JSB (R0) ; Call specified routine
RSB ; and return
No_ret: .
.
RSB
Rout2: .JSB_ENTRY
CLRL R0
.
.
MOVAB continue_label, R0 ; Specify alternate return
RSB
3.3.6 Coroutine Calls
Coroutine calls between two routines are generally implemented as a set of JSB
instructions within each routine. Each JSB transfers control to a return address
on the stack, removing the return address in the process (for instance, (JSB
@(SP)+). The compiler detects coroutine calls and flags them as errors.
Recommended Change
You must rewrite the routine that initiates the coroutine linkage to pass an
explicit callback routine address to the other routine. The coroutine initiator
should then invoke the other routine with a JSB instruction.
Recommended and Required Source Changes 3–11