XCTL Macro



This macro, whose name means Exchange Control, is somewhat similar to LINK but with one significant difference, control is passed to the nominated routine on the premise that there will be NO RETURN to the caller. As return is not anticipated GPRs 2 through 12 should be restored to the original contents as they were on entry to the caller.

Parameters are passed to the next routine in a conventional manner, i.e. via GPR 1, but because the memory of the calling module will be lost, any parameters passed must reside in their own memory, obtained by the calling program using either STORAGE macro, or the older GETMAIN macro.

XCTL will be required if the program to be invoked needs to be the top routine in the Program Request Block (PRB) chain.

Dynamic Linkage without return using the XCTL Macro.



XCTL syntax



(r1,r2)

This indicates the range of registers to be restored prior to the requested module receiving control.

This is necessary as control is not returned to the caller when the requested routine ends.

EP=

This provides the member name of the sub-routine by which it is stored in the Load Library.

EPLOC=

This is an alternative format where entaddr is the address of the sub-routine either as a A-type constant or a General Purpose Register (GPR) in the range 2 to 12. This address could be obtained by executing the LOAD macro before issuing the XCTL.)


The IBM manual includes descriptions of the LIST (MF=L) and EXECUTE (MF=E) formats which are useful for constructing re-entrant code. There is also a XCTLX macro for 64-bit addressing mode.

Copyright © Legac-e Education 2004-