.tocof pseudo-op

用途

允许将本地符号定义为外部符号的目录,以便可以在表达式中使用该本地符号。

语法

描述
.tocof Name1, Name2

描述

.tocof 伪操作将 Name2 参数声明为全局符号,并将 Name1 符号标记为包含该符号 Name2的另一模块的目录 (TOC)。 因此,可以将本地符号定义为外部符号的 TOC ,以便可以在表达式中使用本地符号或引用被调用模块的 TOC (通常在 .tc 语句中使用)。 此伪操作生成 "重定位字典" 条目 (RLD) ,该条目会将此数据初始化为 TOC 外部符号的地址。 .tocof 伪操作可用于模块间调用,这些调用要求调用者在传输控制之前首先装入被调用模块的 TOC 的地址。

参数

描述
Name1 指定一个本地符号,该符号充当包含 Name2 值的模块的 TOC。 Name1 符号应该出现在 .tc 语句中。
Name2 指定一个存在于包含 TOC 的模块中的全局符号。

示例

以下示例演示了 .tocof 伪操作的用法:


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.