|
PDP-11/40 使用 KD11-A 处理器。这种处理器有许多寻址方式,其中有一种是对 PC(程序计数器)的相对寻址。这种寻址方式是:
- RELATIVE ADDRESSING - Relative addressing specifies the operand
- address relative to the instruction location. This is accomplished by
- using the PC as an index register. The PC is considered as a base
- address. The offset, the distance between the location of the operand
- and the PC, is held in the index word of the instruction. PAL-11
- assembles instructions of the form
- OPR A
- (where A has not been assigne as a name of a general register) as an
- instruction word with the address field
- +-----------------------+
- | 6 | 7 |
- +---+---+---+---+---+---+
- ADDRESS FIELD-RELATIVE MODE
- followed by an index word of the form
- +----------------------------+
- | A-ADDRESS OF THIS WORD * 2 |
- +----------------------------+
复制代码
在 UNIX 源代码中有这样的代码:
- 0851 gword:
- 0852 mov PS,-(sp)
- 0853 bis $340,PS
- 0854 mov nofault,-(sp)
- 0855 mov $err,nofault
- 0856 mfpi (r1)
- 0857 mov (sp)+,r0
- 0858 br 1f
复制代码
很明显,0852 行的目的是将 PS(处理器状态)压入堆栈。PS 的值在别处指明,是 177776。处理器状态似乎应该在这个地址中。然而基于上面对寻址方式的描述,程序会将相对于 pc 距离为 177776 的内存中的内容压入堆栈。请问这是怎么回事?
还有一点,在 UNIX 汇编中,像 nofault 这样的标识符出现在代码中是否代表该标识符所在位置的地址? |
|