Reading through the Z80 datasheet, I noticed something interesting. The Z80 separates its instruction execution into separate phases (which are called "machine cycles" in the official literature, but I don't like that terminology because it is too easy to confuse with clock cycles ... a machine cycle consists of multiple clock cycles, usually 3 or 4) that perform different kinds of operation. In the first such phase, which is called M1, the processor fetches the instruction to execute in the remaining phases, then once execution has finished it cycles back to M1 again and fetches the next instruction.
Interestingly, the processor has a pin that provides a signal identifying whether or not it is in the M1 phase. Apparently this is because the memory timing for instruction fetch is different to memory accesses that are performed by the executing instruction, so if your RAM has an access time > 1.5 clock cycles but < 2 cycles you need to assert the /WAIT signal during instruction fetches but not data fetches. But I see no reason this couldn't be used as a seventeenth address line, effectively allowing the Z80 to address an entire 64K of data memory without the inconvenience of needing to fit its program in the same space.
Are there any examples of machines that did this? Or any reason why it wouldn't work?
LD HL,#1234has singe M1 cycle and then two ordinary read cycles to read operand) or make further accesses commanded by the instruction just read. Unfortunately, the complexity of such a hardware is relatively high and it could be easily made only in FPGA or CPLD devices. – lvd Jul 31 '17 at 15:44BIT 7,(IX+1)command. First it fetches DD prefix, then CB prefix. Then it fetches 1, a displacement (not using M1 cycle, just ordinary memory read). And finally it fetches another opcode with M1 cycle! Only then the actual execution starts. – lvd Feb 20 '18 at 08:58ld ix,0 / add ix,desequence to transfer a value into ix can add a displacement "for free", meaning the short displacements add cost but little value). If, however, there had been a two-byte 8-cycleex de,ix/iyinstruction, the IX/IY displacements could have been much more valuable. MaybeDD EBandFD EBhad been planned? – supercat Jun 01 '18 at 16:18ex de, i[xy]would have been tricky to implement:ex de, hljust toggles a flipflop that inverts the select lines to the de and hl registers. Extending that to IX and IY would have required either a much more sophisticated decoder or actual data swapping, which with only a 4-bit wide data path into or out of temporary storage would have taken at least 16 cycles. – Jules Jun 01 '18 at 19:31exx,ex de,hlandex sp,hl. Were it not forex sp,hl, there would be eight possible permutations which could be accommodated easily using three flops called "prime", "hsel", and "altsel". Accesses to HL use register (prime:hsel), accesses to DE use (prime:!hl), exchanging de and hl would invert the value of hsel, and exx would flip the value of hl while swapping the values of hsel and altsel. – supercat Jun 01 '18 at 19:48exinstructions could then shuffle the values of the appropriate 3-bit registers, while exx would swap the contents of the first two 3-bit registers and the 6-bit one. – supercat Jun 01 '18 at 19:53ex sp,hlas a 4-cycle instruction? In the absence ofexx, there would be six permutations, which would be a bit awkward but not impossible. With 120 permutations, though, I can't see any approach that would be simpler than having a bunch of 3-bit registers to select which of five 16-bit registers is mapped to each of DE, HL, DE', HL', and SP. – supercat Jun 01 '18 at 20:19ex (sp), hltakes 19 cycles, and as far as I'm aware there isn't anex sp, hl, so I think you're getting confused somewhere...? – Jules Jun 01 '18 at 20:59ex sp,hl, and [now that you mention it] is missingex (sp),hl. In any case, ix/iy seem like they would take up far more circuitry than they end up being worth, so the only plausible reason I see for their existence would be that they were intended to be far more usable than they ended up being. Do you know of anything that would indicate how the Z80's design evolved from conception to completion? – supercat Jun 01 '18 at 21:41IX+naddressing mode orjrinstructions by arranging for the incrementer to be capable of adding or subtracting 256 rather than just one? It really seems a waste that instructions which add an 8-bit signed displacement burn so many T-states on an increment or decrement operation. – supercat Jun 02 '18 at 20:08