HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Branching to an external address

HLASM Language Reference
SC26-4940-06

Use the V-type address constant to identify the external symbol that represents the address in an external source module that you want to branch to.

For example, you can load into a register the V-type address constant that identifies the external symbol. Using this register, you can then branch to the external address represented by the symbol.

If the symbol is the name entry of a START, CSECT, or RSECT instruction in the other source module, and thus names an executable control section, it is automatically identified as an entry symbol. If the symbol represents an address in the middle of a control section, you must identify it as an entry symbol for the external source module.

You can also use a combination of an EXTRN instruction to identify, and an A-type address constant to contain, the external branch address. However, the V-type address constant is more convenient because:
  • You do not have to use an EXTRN instruction.
  • The external symbol you specify, can be used in the name entry of any other statement in the same source program.
  • It works correctly even if the program is linked as an overlay module, so long as the reference is not to a symbol in an exclusive segment. See z/OS MVS Program Management: User's Guide and Reference, SA22-7643 for further information.
The following example shows how you use an A-type address constant to contain the address of an external symbol that you identify in an EXTRN instruction. You cannot use the external symbol name EXMOD1 in the name entry of any other statement in the source program.
         .
         .
         L     15,EX_SYM        Load address of external symbol
         BASR  14,15            Branch to it
         .
         .
EX_SYM   DC    A(EXMOD1)        Address of external symbol
         EXTRN EXMOD1           Identify EXMOD1 as external symbol
         .
         .
The following example shows how you use the symbol EXMOD1 as both the name of an external symbol and a name entry on another statement.
         .
         .
         L     15,EX_SYM        Load address of external symbol
         BASR  14,15            Branch to it
         .
         .
EXMOD1   DS    0H               Using EXMOD1 as a name entry
         .
         .
EX_SYM   DC    V(EXMOD1)        Address of external symbol
         .
         .

If the external symbol that represents the address to which you want to branch is part of an overlay-structured module, identify it with a V-type address constant. Do not use an EXTRN instruction and an A-type address constant. You can use the supervisor CALL macro instruction to branch to the address represented by the external symbol. The CALL macro instruction generates the necessary V-type address constant.

z/VM and z/OS
You can branch to external symbols in the same class using relative branch instructions.
MYPROG   CSECT ,             Define section MYPROG
CLASS_A  CATTR RMODE(31)     Define class CLASS_A
         - - -
         BRAS  14,ENTRYB     Branch to external symbol
         - - -
HISPROG  CSECT ,             Define section HISPROG
CLASS_A  CATTR RMODE(31)     Define class CLASS_A
         - - -
ENTRYB   STM   14,12,12(13)  Entry point referenced externally
         - - -
         END
You can also use a relative branch instruction to branch to an externally defined symbol:
MYPROG   CSECT ,             Define section MYPROG
MYCLASS  CATTR RMODE(31)     Define class MYCLASS
         EXTRN TARGET        Declare external symbol TARGET
         - - -
         BRAS  14,TARGET     Branch to external symbol
         - - -
         END

A separate source module must define the entry point TARGET in class MYCLASS.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014