jds wrote:
For a coprocessor to be useful it would need to have it's own registers, and there would need to be a way of loading the registers. I've had a look at the 8087 and it uses a stack, which seems like a good idea for a floating point processor. So to push onto the stack, I think that would be quite easy with an immediate value, we just use the NOP mechanism above to make the 65816 load the next few bytes and use those as an immediate value.
Thanks, Garth. BTW in case anyone's wondering, in this thread the term NOP doesn't necessarily imply $EA, the official NOP. $EA isn't ideal for the job of manipulating the '816 to read (but ignore) a series of bytes at PC because it only accesses one byte every 2 cycles. A better choice is to feed the '816 WDM ($42) -- a
two-byte NOP that executes in 2 cycles.
jds, you mentioned 8087, which is an interesting point of comparison. That chip has no need to comprehend addresses and address modes because those are managed by the host processor (8086 or 8088; '286 and even '386
also support 8087, IIRC). The host has special instructions that generate addresses and use them to access memory -- but the host does nothing with the access. It's perhaps reasonable to call these instructions NOP's, since no flags or registers are altered. But they're not to be confused with ordinary NOP's, whose only memory access is their own instruction fetch.
Intriguingly, the 65c02 has, as a fluke, instructions with very much the same sort of behavior. These play a key role regarding the
co-processor for 65c02 incorporated in my
KK Computer, built in the late 1980's. 65c02 memory-accessing
NOP's use the following address modes: Immediate, Absolute, Zero-page and Zero-page,X.
jds wrote:
the coprocessor to duplicate the address calculations of the 65816, I don't see a way that we could use the 65816 for this. We'd also need to take control of the bus to perform memory reads, and this is where it gets more complex.
Taking control of the bus is, in itself, not difficult. But generating addresses, especially for a variety of address modes, will take some doing. And, as you say, the '816 won't help us. It doesn't have the accidental (and undocumented) co-processor support tacitly featured by the 'c02.
As an alternative trick for generating addresses, you might consider feeding the '816 CMP or BIT instructions. But CMP and BIT alter the flags, and that limits the circumstances under which they can substitute for the 'c02 address-generating NOP's.
jds wrote:
This doesn't seem too complex to implement with a FPGA
Yes, an FPGA could do it. Of course, depending on what sort of challenge interests you, perhaps you'd prefer to omit the traditional '816 and do it and your co-processor
both in FPGA. FYI, on his
CPU Cores page forum member Rob Finch has two '816 cores you may wish to study. (Working but not rigorously tested, probably because at present we have no '816 test suite.)
cheers
Jeff