The Importance of Terminology's Quality

John W Kennedy jwkenne at attglobal.net
Thu Aug 14 18:33:30 EDT 2008


Robert Maas, http://tinyurl.com/uh3t wrote:
> John W Kennedy <jwke... at attglobal.net> wrote:
> JWK> Into the 60s, indeed, there were still machines being made
> JWK> that had no instruction comparable to the mainframe BASx/BALx
> JWK> family, or to Intel's CALL. You had to do a subprogram call by
> JWK> first overwriting the last instruction of what you were
> JWK> calling with a branch instruction that would return back to
> JWK> you.
> 
> That's not true, that you needed to do that, that there was no
> other way available. The subroutine linkage I invented for S.P.S.
> (Symbolic Programming System, i.e. IBM 1620 assembly language) was
> to reserve a 5-digit space immediately before the subroutine entry
> point for storing the return address. So the caller needed to know
> only one address, the entry point, and do both store-return-address
> and jump relative to that address, rather than needing to know both
> the entry point and the last-instruction-JUMP-needs-patch address
> as independent items of information. So calling a subroutine was
> two instructions (pseudo-code here):
>    literal[nextAdrOfSelf} -> memory[SubrEntryPoint-1]
>    jump to SubrEntryPoint
> and returning from a subroutine was two instructios:
>    copy memory[SubrEntryPoint-1] -> memory[here + 11]
>    jump to 00000 ;These zeroes replaced by return address just above
> Of course if you needed to pass parameters and/or return value,
> that was handled separately, perhaps by reserving additional
> storage just before the return address. Of course this methodology
> didn't support recursion.
> 
> So my method required one extra instruction per return point, but
> allowed multiple return points from a single subroutine, and
> allowed "encapsulation" of the relation between entry point and
> return point.
> 
> Note: On IBM 1620, instructions and forward-sweeping data records
> were addressed by their *first* digit, whereas arithmetic fields
> were addressed by their *last* digit, the low-order position, to
> support natural add-and-carry operations. Storage was decimal
> digits, with two extra bits, flag to indicate negative value (if in
> low-order position) or high-order-end (if in any other position),
> and parity. Values larger than nine were reserved for special
> purposes, such as RECORD MARK used to terminate right-sweep data
> records. Because of that, the low-order position of the return
> address and the first digit of the machine instruction at the
> subroutine entry point differed by only machine address, hence the
> SubrEntryPoint-1 instead of SubrEntryPoint-5 you would otherwise
> expect.
> 
> Hmm, I suppose if I had thought it out more at the time, I might have
> done it slightly differently:
> 
> Entry point like this:
>          jump 00000 ;Patched by caller to contain return address
>   Entry: ...(regular code)...
>           ...
> 
> Each return point like this:
>          jump Entry-12
> 
> 
> I wonder if anybody ever implemented a stack on the IBM 1620?
> Probably not, because it would take a lot more machine instructions
> to push and pop, and if you weren't writing anything recursive then
> extra work for no extra benefit except saving a few digits of
> memory if your maximum stack depth is less than the total number of
> subroutines you have loaded, except the extra instructions more
> than kill off the storage savings.
> 
> Hmm, I suppose you could have a auxilary function that serves as
> trampoline for stack-based call and return. To call, you move your
> own return address and address of subroutine to fixed locations in
> low memory then jump to the call trampoline, which pushes the
> return address onto the stack and jumps at entry address. To
> return, you just jump to the return trampoline, which pops the
> return address off the stack and jumps at it. The trampoline,
> occuping memory only *once*, could afford to have code to safely
> check for stack over/under flow.

Actually, I was thinking of the 1401. But both the 1620 and the 1401 
(without the optional Advanced Programming Feature) share the basic 
omission of any instruction that could do call-and-return without 
hard-coding an adcon with the address of the point to be returned to. 
(The Advanced Programming Feature added a 1401 instruction, Store 
B-address Register, that, executed as the first instruction of a 
subroutine, could store the return-to address.)

The 1620, oddly enough, /did/ have call instructions (Branch and 
Transfer, and Branch and Transfer Immediate) and a return instruction 
(Branch Back), but with a hard-wired stack depth of 1.

-- 
John W. Kennedy
  "When a man contemplates forcing his own convictions down another 
man's throat, he is contemplating both an unchristian act and an act of 
treason to the United States."
   -- Joy Davidman, "Smoke on the Mountain"



More information about the Python-list mailing list