User`s guide
Recommended and Required Source Changes
3.3 Flow Control Mechanisms
For example, consider the following coroutine linkage:
Rout1: .JSB_ENTRY
.
JSB Rout2 ; Rout2 will call back as a coroutine
.
JSB @(SP)+ ; Coroutine back to Rout2
.
RSB
Rout2: .JSB_ENTRY
.
JSB @(SP)+ ; coroutine back to Rout1
.
RSB
You could change the routines participating in such a coroutine linkage to
exchange explicit callback routine addresses (here, in R6 and R7) as follows:
Rout1: .JSB_ENTRY
.
.
MOVAB Rout1_callback, R6
JSB Rout2
RSB
Rout1_callback: .JSB_ENTRY
.
.
JSB (R7) ; Callback to Rout2
.
RSB
Rout2: .JSB_ENTRY
.
.
MOVAB Rout2_callback, R7
JSB (R6) ; Callback to Rout1
RSB
Rout2_callback: .JSB_ENTRY
.
RSB
To avoid consuming registers, the callback routine addresses could be pushed
onto the stack at routine entry. Then, JSB @(SP)+ instructions could still be used
to perform ‘‘direct’’ JSBs to the callback routines. In the following example, the
callback routine addresses are passed in R0, but pushed immediately at routine
entry:
3–12 Recommended and Required Source Changes