I wonder if 6522 is Turing complete? I suspect yes because the interaction between I/O and counters allows a deterministic sequence of bus cycles to perform computation.
BigEd on Mon 13 Jun 2022 wrote:
(A schoolfriend of mine borrowed my Compukit while I was away, and wrote a monitor with a single-stepping capability which was in effect an emulation of 6502 on 6502. It was possible, he said, but terribly slow, to run the monitor within itself.)
I'll be very impressed if 6502 on 6502 simulation either requires less than 2KB of program or runs no worse than 30 times slower. Assuming that the smallest implementation was desirable, I assume that it was possibly 50 times slower.
I've dabbled with
6502 on 6502 simulation. It started as 65C02 on 65C02. After establishing that the native call stack can be used by the simulator and that RegP is best hidden on top of stack, simulation is focused on RegA, RegX and zero page. While RegY can be held in its native register, I chose otherwise because this eases extended uses, such as additional index registers or vector operations. When not held in native registers, RegA, RegX and RegY may be held in memory locations which are compatible with KIM-1 monitor firmware.
If RegX is set to zero in a few places, 65C02 simulation can be written in NMOS 6502. To be pedantic, it is possible to implement the ROR bug workaround. This allows 65C02 on 6501 - with a mere factor of 30 performance penalty. It that isn't slow enough, is possible to include decimal mode workarounds. In particular, this allows decimal operation on systems without decimal support. Going the other way and expanding outwards, I found that it is possible to implement a fictional aggregate of RegB from the draft 6501, RegQ from the failed 6516 and RegZ from 65CE02 while reserving 11x1x100 as prefixes for 16/32/64 bit extensions. With minor speed penalty in the simulation, it is possible to substitute absolute address mode with abs,Z. However, good luck implementing all of this in less than 6KB. Ordinarily, it not possible to nest simulations due to conflicting use of zero page. However, with further performance penalty, for each nested simulation, it is possible rotate memory around by one page or more.
One of the many advantages of writing a ridiculous extension of 6502 (with two accumulators, two flag registers, three or more index registers, additional addressing modes and vector extensions) is that it can be programmed using your favorite assembler, as part of your preferred workflow.