avatar
Jack Aidley @jackaidley.bsky.social

... this is actually a negative number. The command 'G n F' is a conditional jump that jumps if the accumulator is negative. Once it reaches the subroutine it adds a pre-calculated constant to 'A m F' to convert it into 'E m+2 F' and stores it into the address at the end so that it will now return.

aug 25, 2025, 10:24 am • 1 0

Replies

avatar
Ehud @duhe.bsky.social

So the return address is in location 3? The snippet doesn’t show this. But then why put the A in the accumulator to begin with? Now I’m confused…

aug 25, 2025, 10:30 am • 0 0 • view
avatar
Jack Aidley @jackaidley.bsky.social

No, location 3 is used to store the number that needs to be added to 'A m F' to turn it into 'E m+2 F'. The accumulator gets the entire command 'A m F' stored into it, this means when you add the number stored in 3 to the accumulator it can be stored as the return op without further manipulation.

aug 25, 2025, 10:46 am • 1 0 • view
avatar
Jack Aidley @jackaidley.bsky.social

Command codes in EDSAC 2 were stored as a 5 bit command code, a spare bit, a 10 bit address, and a final bit indicating whether the command was 'F' (short) or 'D' (long). So, if you're calling a subroutine at position 10, you'd store the return address with 'A 10 F' which is '11100 0 0000001010 0'

aug 25, 2025, 10:57 am • 1 0 • view
avatar
Jack Aidley @jackaidley.bsky.social

And you need to return from the subroutine function with 'E 12 F' (because you want to skip before the accumulator and the jump instruction you return to the stored value + 2), which is '00011 0 0000001100 0'. Location 3 is used to store the difference between these two values which is always...

aug 25, 2025, 10:57 am • 1 0 • view
avatar
Jack Aidley @jackaidley.bsky.social

... the same 'U 2 F' (00111 0 00000 00010 0). Add this to 'A 10 F' and you get 'E 12 F' -- which, looking at it now, I think only works because of arithmetic overflow.

aug 25, 2025, 10:57 am • 1 0 • view
avatar
Ehud @duhe.bsky.social

Ok, thanks. I think I got it: to get the return location we use the current line which was relocated so has the correct current program counter. The A instruction does this for us, and adds the contents of the current pc location which is the instruction A m. 1/ .

aug 25, 2025, 10:58 am • 1 0 • view
avatar
Ehud @duhe.bsky.social

This is how we capture m, the current pc. In the subroutine we add the difference between A and E instructions (and m to m+2 to go the instruction after the jump) to get a return jump and plug it at the end of the subroutine. This is a constant value. 2/

aug 25, 2025, 10:58 am • 2 0 • view
avatar
Ehud @duhe.bsky.social

Presumably E jumps on positive and G on negative unrelated to this, simply the way conditional branching was implemented way before subroutines were contemplated. 3/3

aug 25, 2025, 10:58 am • 2 0 • view
avatar
Jack Aidley @jackaidley.bsky.social

Correct. I'm not sure about the last point though. Wheeler mentions in the paper you referenced that they were thinking about subroutines as early as '48 and so I think it more likely that the E/G distinction was included for more general use and the issue here just tolerated.

aug 25, 2025, 11:08 am • 1 0 • view
avatar
Ehud @duhe.bsky.social

Excellent. That’s pré what I was wondering about.

aug 25, 2025, 11:13 am • 0 0 • view
avatar
Ehud @duhe.bsky.social

(Tolerated describes what I assumed. So they may have contemplated subroutines, but the E/G behavior wasn’t designed for that purposed). It’s path dependence.

aug 25, 2025, 11:16 am • 1 0 • view