2 ms·
Many early machines did this, often using a special form of store instruction that only modified the target address part of an instruction word. EDSAC, on whic
by kps 12y ago
Many early machines did this, often using a special form of store instruction that only modified the target address part of an instruction word.
EDSAC, on which David Wheeler invented the subroutine call, had no such instruction, and did it like this (using a modern pseudo-assembler syntax, not the original):
address instruction comment
------- ----------------- ---------
m - 1. clear accumulator
m. add from m # Load the 'add from m' instruction itself
# (which contains its own address) into
# the accumulator.
m + 1. jump to s # Jump to the subroutine.
m + 2. … # Control will return here.
⋮
s. add from 3 # Add a magic constant (kept in location 3)
# to the accumulator (which contains the
# 'add from m' instruction from m) resulting
# in a 'jump to m+2' instruction.
s+1. store to r # Store the 'jump to m+2' instruction at the
# end of the subroutine.
⋮ # Subroutine body.
r. (anything) # ‘Return’ jump stored here.