4

For some context to this question see Raffzahn's excellent question and answer How were Zuse Z22 Instructions Encoded?.


The Z22 treats the first few locations of its address space in a particular way:

  • the instruction encoding gives preferential treatment to the encoding of addresses in this range, a little like a register file
  • it is not backed by the (slow) memory drum, but some of it is backed by fast core memory.
  • Some of the locations have special meanings, such as having a constant value when reading, or having the ability to test some of the bits for conditional execution, or I/O ports.

The Z22 instruction word has a bit you can set (it's called F), to copy the already-incremented program counter to Location 5. And any instruction can do this as a side effect, but I imagine it's most often combined with a E, which is the jump instruction, so that FE would be a subroutine call, having the return address in Location 5. So I guess to return from a subroutine you'd do EG 5 or something.

It's a bit like subroutine call/return on ARM, where you can call a subroutine with bl somewhere and return with bx lr, except that the return address is stored in a fixed location in memory instead of a register, and that any instruction can store the program counter to Location 5, not just branches.

Now we know that Location 5 is written to by the F operation. Another funky location in this portion of the address space in Location 16, which is a read-only shadow of Location 5. And this question asks what purpose that serves.

I suppose we can rule out the possibility of incomplete address decoding, since the binary values for 5 and 16 don't share any common 1s. Also none of the other locations have this kind of shadowing so far as I know. So it was deliberately put in, along with write-protection. So what is it for?

4
  • 1
    AFAIR it's simply about having access to complex addressing modes using the last return address without changing it. Especially C which used on SS5 would change the return address. Used on SS16 will produce no effect on storage. It's handy to havea parameter list right after the jump, so the address in SS5 is essentially a pointer to a parameter record, which can be addressed using SS16 with any addressing mode without side effect on is content. While the return would use R16 plus parameter length as return jump. Would need to spend some time reading the doc to check.
    – Raffzahn
    Commented Dec 22, 2023 at 14:05
  • @Raffzahn oh that makes sense, (except C is "Constante", isn't it?). But mind to make it an answer so I can vote and/or accept? Commented Dec 23, 2023 at 13:57
  • Yes, C is Constant - which in this case means immediate value instead of an address - for example adding an immediate value to SS16 before using the result - which due being read only will not be stored in SS16. UsingSS16+0 gives the first word after the subroutine jump, +1 the second and so on. Think of it as base + offset addressing. I'm right now down with Covid, not really in a mood to write a goodanswer.
    – Raffzahn
    Commented Dec 23, 2023 at 15:13
  • @Raffzahn I'm beginning to understand what you're on about. Gute Besserung! Commented Dec 23, 2023 at 17:11

1 Answer 1

1

In simple, early instruction sets, saving the program counter and doing arithmetic on it wasn't rare.

One might, for example, embed some data in the program just after a subroutine call, use the return address to find the data for use by the subroutine, and increment the return address to just past the data so that you could return to the right instruction. This seems like madness nowadays, but we are used to much more capable computers with well-defined calling conventions and memory organisations.

Location 16 might have several purposes, and the question isn't quite clear on its behaviour.

  • If location 16 is a read-only copy of the value that was stored into location 5 by the last subroutine call, then it is probably a method of ensuring that the original return address remains available.

  • If location 16 is always a copy of location 5, updated immediately by hardware when location 5 changes, then its purpose is less obvious. It might be provided for use by instructions that alter the location they read.

1
  • As I understand, Location 16 shadows Location 5; it is always a copy of Location 5. Also, so far as I can tell, the only instruction that alters memory is the store instruction, U. Maybe my question has no clear answer ... Commented Dec 22, 2023 at 10:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .