[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Writing emulator...
In article <unl4ru9594j132@corp.supernews.com>,
Mike Guidero <mike@bogus.net> wrote:
> Upon RESET, the 6502 and the Z80 are reset. The Z80 is suspended at this
> time, and the 6502 is allowed to run.
>
> A write to the $Cn00 space of the SoftCard will activate the Z80. As soon
> as the Z80 has valid addressing data, the SoftCard asserts the DMA line on
> the bus, suspending the 6502 processor.
>
> At this point the Z80 is executing instructions and the 6502 is suspended.
>
> If the Z80 writes to the En00H ($Cn00 from the 6502's point of view) space
> of the SoftCard, the Z80 goes to sleep, and 6502 execution resumes at the
> point where it stopped.
All this is of course described in the Softcard manual..... :-)
One difference between the Z80 and the 6502 is that the Z80 is a static
processor, i.e. it can be put to sleep indefinitely: as long as it remains
powered, it will "remember" its processor state when it went to sleep.
The 6502 though is a dynamic processor: if it's put to sleep, it will
"forget" the contents of its internal registers after approximately 50
microseconds. Therefore the 6502 must continuously be "refreshed" when
it's put to sleep (just like a dynamic RAM chip mush be refreshed).
This is accomplished by letting the Softward Z80 CPU, which runs at
4 MHz, run for 1/2 microsecond (i.e. two clock cycles) and the be
suspended for another 1/2 microsecond, during which the 6502 is made
to fetch an instruction (but not execute it). This is enough to
refresh the 6502 registers.
And that's why the Softcard Z80 runs at an effective speed of 2 MHz
even though the processor itself actually runs at 4 MHz.
--------------------------------------------------------------------------
Some other CP/M cards, such as the Appli-Card, let the Z80 have its
own address space with its own RAM chips -- then the Z80 and the 6502
could run concurrently and the 6502 never needs to be put to sleep.
This makes the 6502 address space inaccessible to the Z80 though and
the Z80 must use the 6502 for all accesses to the 6502 address space,
i.e. for all kinds of I/O (keyboard, video screen, disk, serial port
- everything). The requires some kind of protocol between the Z80
and the 6502 so they can communicate. On the Appli-Card, whenever
the 6502 isn't busy doing some I/O requested by the Z80, it polls the
"ports" between the Z80 and the 6502 (which are memory mapped I/O
addresses in the $Cn00 address space as seen by the 6502, and port
addresses as seen by the Z80). Of this 6502-Z80 protocol somehow
gets out of sync, the computer hangs and must be rebooted.
One way to hang this 6502-Z80 protocol on the Appli-Card is to run a
CP/M utility which reads all Z80 ports and dumps their contents on
the screen: on the SoftCard this utility runs fine (although there's
nothing interesting to read from the Z80 ports there, since they are
unused on the SoftCard, which also lets the Z80 do memory mapped
I/O), but on the AppliCard this utility immediately hangs the system
so severely that a power off+on is required to recover.
--
----------------------------------------------------------------
Paul Schlyter, Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40, S-114 38 Stockholm, SWEDEN
e-mail: pausch at saaf dot se
WWW: http://hem.passagen.se/pausch/index.html
http://home.tiscali.se/~pausch/