When programming a DEC PDP 8 in the mid seventies indirection was used by the programmers to indicate where the program was to jump to (I think). I found it very useful and want to know what techniques are used on the 8086 to produce thee same result, or an indication of what has replaced it
-
Can you provide a link to something that describes what "indirection" means? – trojanfoe May 17 '15 at 08:37
-
@trojanfoe I guess he means indirect jumps `jmp [an adress]` – the accountant May 17 '15 at 08:42
-
I.e. "jump to an address *contained* in memory or a register"? – trojanfoe May 17 '15 at 08:43
-
1@trojanfoe . Exactly! like `jmp [eax]` – the accountant May 17 '15 at 08:53
-
Here's a reference on the PDP8: http://en.wikipedia.org/wiki/PDP-8 – Ira Baxter May 17 '15 at 13:53
2 Answers
PDP8 instructions have 2 addressing mode bits, I and Z, and a 7 bit offset. JMP instructions have these.
The offset specifies a memory location in the same 128 word page as the PC, or in "page 0", depending on the Z bit. The I bit means "read the addressed memory location, use it as an address of the operand". The Z bit means "use page zero" instead of the current page.
To jump to a location in the same 128 word page, you specify the I and Z bits as off. This corresponds to most closely on the x86 to a "short relative jmp", having an 8 bit (short) relative offset.
To transfer control to a fixed target location on another page, you must have a word in the current page (or page zero) that contains the target address. You then specify a jmp with the I bit set, with the offset referring to the location of the target address. In practical usage, this corresponds most closely on x86 to a "long relative jmp", which has a 32 bit relative offset. For subroutine calls, this corresponds to "long relative call" which has the same 32 bit relative offset.
Sometimes you would want to pass control to an address computed dynamically. One the PDP8, you'd simply do a JMP indirect with offset referring to the location containing the computed address. This action corresponds most closely with x86 JMP [reg] instructions.
On the PDP8, you use the above technique to return from a subroutine. (The JMS subroutine call instruction stores the return address at the first word of the subroutine; no stack). On the x86, one mostly uses CALL and RET to effect subroutine call and return.

- 93,541
- 22
- 172
- 341
-
This is a personal thanks to Ira Baxter who is definitely on the same page as me and I can't seem to thank more than one person for an answer. – Android May 18 '15 at 08:53
If you are referencing the "indirection" explained at http://www.cs.swan.ac.uk/~csneal/SystemSpec/MoreExamples.html, the answer is quite simple: you don't.
The x86 instruction set is CISC, hence not limited to fixed instruction widths - the processor will figure out itself how long the instruction is and you don't need a hack to address locations longer than a (fixed) instruction size.
For example, jmp 100008283h
would translate to E9 AD 5E 00 00
in a binary I just opened, while xor eax, eax
translated to 31 C0
.
The closest thing resembling indirection in this sense is a short jump - absolute jumps take quite a lot of memory (see the example above), so if a destination is within reach of a short jump you'd essentially jump to an offset relatively to your current position and specify the 'distance' on the short jump.

- 2,158
- 8
- 29
- 52
-
1Thank you friedkiwi for pointing me in the right direction and Ira Baxter who posts sensible comments. I don't really want to read a discussion by people who were probably not even born when I started programming about their lack of understanding of the question. I've only posted 2 questionins in the last 2 years because I try to work it out myself first, which is one of the rules of this site I believe. – Android May 17 '15 at 17:39