I wrote:
> I 16-bit inc/dec 3 [except PC, and SP during stack operations]
^
This should probably be 2.
>stack pointer has to be decremented before the first memory access; this
>takes 1 cycle (referred to as D below. This also applies to the DEC BC
>cycle of an LDIR instruction).
Not that it makes much difference but I've decided that the DEC BC of an
LDIR instruction is of the I kind mentioned above. That also means I don't
have to add an extra cycle to make it add up. However I do have to add an
extra 3 cycles to a CPIR instruction to make it add up. Possibly this is
a fake memory cycle which corresponds to the 'store in (DE)' phase of the
LDIR.
> OTIR F+F+A+O+L = 16 F+F+A+w5+O+L+w3 = 24 [if c>247 & b=0]
> OTIR F+F+A+O+L = 16 F+F+A+O+L = 16 [if c<248 b=0]
This is incorrect since the DEC B seems to come before the output. In other
words, if you do
LD BC,&10F8
OTIR
then ports 0FF8, 0EF8, ..., 00F8 will be accessed. Strangely enough, if you
do
LD BC,&10FE
INIR
then ports 10FE, 0FFE, ...,01FE will be accessed - in other words the
DEC B comes after the input.
Unfortunately, I cannot come up with a theory which agrees exactly
with experiment. Here is a complete table of the times taken by block
instructions.
+-----+----+----+----+----+
| src| N | N | C | C | N = not contended
| dest| N | C | N | C | C = contended
+=====+====+====+====+====+
|LDI | 16 | 20 | 16 | 20 |
|LDIR | 24 | 24 | 24 | 24 | Note that for fooR the time given is for
|CPI | 16 | | 16 | | when the counter is non-zero. When the
|CPIR | 24 | | 24 | | counter is zero the time is as for foo.
|INI | 16 | 20 | 24 | 24 |
|INIR | 24 | 24 | 24 | 24 | When foo = fooR = 24 then foo might
|OUTI | 16 | 24 | 20 | 24 | take 20 or 24 depending on when it is
|OTIR | 24 | 24 | 24 | 24 | initiated.
+-----+----+----+----+----+
imc