HOME

TheInfoList



OR:

The Wheeler Jump is a type of
subroutine call In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed. Functions may ...
methodology that was used on some early computers that lacked hardware support for saving the return address. The concept was developed by David Wheeler while working on the pioneering
EDSAC The Electronic Delay Storage Automatic Calculator (EDSAC) was an early British computer. Inspired by John von Neumann's seminal ''First Draft of a Report on the EDVAC'', the machine was constructed by Maurice Wilkes and his team at the Universi ...
machine in the 1950s. EDSAC had not been built with subroutines in mind, and lacked a suitable
processor register A processor register is a quickly accessible location available to a computer's processor. Registers usually consist of a small amount of fast storage, although some registers have specific hardware functions, and may be read-only or write-only. ...
or a
hardware stack In computer science, a stack is an abstract data type that serves as a collection (abstract data type), collection of elements, with two main operations: * Push, which adds an element to the collection, and * Pop, which removes the most rece ...
that might allow the return address to be easily stored. Wheeler's solution was a particular way to write the subroutine code. To implement it, the last line of the subroutine was a "jump to this address" instruction, which would normally be followed by a memory location. In a Wheeler subroutine, this address was normally set to a dummy number, say 0. To call the routine, the address of the caller would be placed in the accumulator and then the code would jump to the starting point of the routine. The first instructions in the routine would calculate the return address based on the value in the accumulator, typically the next memory location so an increment will suffice, and then write the result to the dummy address previously set aside. When the routine runs its course it naturally reaches the end of the routine which now says "jump to the return address". As writing to memory is a slow process compared to register access, this methodology is not particularly fast. The addition of new registers for this sort of duty was a key design goal of
EDSAC 2 EDSAC 2 was an early computer (operational in 1958), the successor to the Electronic Delay Storage Automatic Calculator (EDSAC). It was the first computer to have a microprogrammed control unit and a bit-slice hardware architecture. First cal ...
.


Example

This example demonstrates the technique using a pseudo-
assembler language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence be ...
for a simple byte-oriented accumulator-based machine with a single register, A: 'prepare to call the subroutine 10 COPY PC TO A ' copy the program counter (10) into the accumulator 11 JUMP ' jump to... 12 70 ' ... location 70 ... many more lines... 70 ADD CONST ' add the following value to the accumulator... 71 3 ' ... three locations past the original PC value 72 STORE ' store the value in the accumulator to... 73 91 ' ... the set-aside memory location ... lines that perform the actual subroutine... 90 JUMP ' return to... 91 0 ' ... which will be replaced by 13 When this code completes, the JUMP instruction in address 90 will naturally return to location 13, the next instruction after the subroutine.


References

* * {{compu-stub Subroutines