If you want to link modules dynamically at run-time, you have two choices:
- You can code your calling module to check whether the called module is already available. This way you retain the option to link modules statically sometimes. Each calling module that calls another module first tests the external reference address, and then if it is zero, issues a LOAD for the module, saving the address in the external reference field, then a BALR to go to the called module. With this method you must also specify the Linker directive NCAL when you build the executable program; to do this, uncheck
Resolve external calls at link time on the
Assembler tab on your project properties
Assembler page. With NCAL set, the linker issues warnings that external references were not resolved and stores zero in each field holding the address of an external reference.
- You can code your calling module to link dynamically always. You simply issue a LOAD for the module you want to link to, then a BALR to branch to it. With this method it makes no difference whether you specify the NCAL Linker directive or not.
We recommend that you also mark each module in this environment as reentrant and serially reusable, so that modules are not deleted and reloaded for each call. To mark a module as reentrant, check
Mark module as reentrant on the
Assembler tab on your project properties
Assembler page. To mark a module as serially reusable, check
Mark load module as serially reusable on the
Assembler tab on your project properties
Assembler page.
If you want to use static linking on a module that is normally dynamically linked, and its
END statement names a default entry point for the module, you may need to provide an
ENTRY command in the linker input file,
.LIN, to override the default entry point. This is because the Linker, emulating the mainframe binder tool, sets the entry point for the entire executable program to the entry point named on the
END statement of the final included module.