.tocof pseudo-op
Purpose
Allows for the definition of a local symbol to be the table of contents of an external symbol so that the local symbol can be used in expressions.
Syntax
Description
The .tocof pseudo-op declares the Name2 parameter to be a global symbol and marks the Name1 symbol as the table of contents (TOCs) of another module that contains the symbol Name2. As a result, a local symbol can be defined as the TOC of an external symbol so that the local symbol can be used in expressions or to refer to the TOC of the called module, usually in a .tc statement. This pseudo-op generates a Relocation Dictionary entry (RLD) that causes this data to be initialized to the address of the TOC external symbols. The .tocof pseudo-op can be used for intermodule calls that require the caller to first load up the address of the called module's TOC before transferring control.
Parameters
Item | Description |
---|---|
Name1 | Specifies a local symbol that acts as the TOC of a module that contains the Name2 value. The Name1 symbol should appear in .tc statements. |
Name2 | Specifies a global symbol that exists within a module that contains a TOC. |
Examples
The following example illustrates the use of the .tocof pseudo-op:
tocbeg: .toc
apb: .tc [tc],pb,tpb
# This is an unnamed TOC entry
# that contains two addresses:
# the address of pb and
# the address of the TOC
# containing pb.
.tocof tpb,pb
.set always,0x14
.csect [PR]
.using tocbeg,rtoc
l 14,apb
# Load R14 with the address
# of pb.
l rtoc,apb+4
# Load the TOC register with the
# address pb's TOC.
mtspr lr,14
# Move to Link Register.
bcr always,0
# Branch Conditional Register branch
# address is contained in the Link
# register.