I can't find PEI too useful it is almost an effective shorthand for LDA (dp),y PHA DEY LDA (dp),y PHA.
PEI effectively performs the following:
Code: Select all
rep #%00100000 ;16 bit accumulator
lda dirpag ;somewhere in direct page
pha ;push it
Despite the meaning of the
PEI mnemonic, the instruction does not use indirection as you suggest.
PEA and
PEI are two poorly-named mnemonics—a single mnemonic, such as
PHW (push word), should have been used, with
PHW # pushing its 16 bit operand (equivalent to
PEA) and
PHW <dp> pushing the 16 bit value at
<dp> and
<dp>+1 (equivalent to
PEI). It would have been nice if these instructions had a complement that pulls a word and discards it, such as
PLW, which would simplify stack housekeeping following a return from a subroutine whose invocation was preceded by the pushing of a stack frame, but they don't.
IMHO it would be better to store 2 adjacent zp-values to the stack like LDA zp,X PHA DEX LDA zp,X PHA.
Even simpler if you are going to go that route is:
which avoids the penalty of manipulating
.X, as well as the extra clock cycles consumed with indexed reads. However,
PEI is twice as fast as my above example, as it uses six clock cycles—assuming
DP is page-aligned, instead of the 12 clock cycles used to read and push both direct page locations, again assuming
DP is page-aligned. Furthermore,
PEI doesn't clobber the accumulator.
6309 is also a mighty beast...The only advantages of 65816 are 24-bit address, higher frequency of produced chips, better support.
...not to mention lower power consumption and substantially lower interrupt latency.
