Dosius, some more SoftCard information for you: I did a little poking around on my IIgs after booting CP/M (having a gs made this really easy, since you can still get into the control panel from CP/M :) I visited the monitor from CP/M and looked at the Z80/6502 switching code, and here's what I've derived: 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. As each processor toggles the SoftCard, the other picks up where it had last been, unless something Special happens, like a RESET. I wrote a little code to test this out. I started up the GS with no disk in the drive, hit RESET, CALL -151, and entered the following code: 6502 Code: 0300: A9 20 LDA #$20 ; prove we got here 0302: 8D 20 03 STA $0320 ; by storing value 0305: 8D 00 C4 STA $C400 ; activate softcard 0308: A9 50 LDA #$50 ; prove we got back 030A: 8D 21 03 STA $0321 ; by storing value 030D: 60 RTS ; back to caller Z80/8080 Code: (8080 mnemonics) 1000: 38 80 MVI A,80H ; prove Z80 code ran 1002: 32 22 F3 STA F322H ; by storing value 1005: 32 00 E4 STA E400H ; deactivate softcard *320: 00 00 00 *300G *320.322 320: 20 50 80 * Worked. Mike Dosius wrote: > Mike Guidero wrote in message > news:... >> Address translation table: >> Z80 address 6502 address >> $0000-$AFFF $1000-$BFFF >> $B000-$DFFF $D000-$FFFF >> $E000-$EFFF $C000-$CFFF >> $F000-$FFFF $0000-$0FFF > Well, that gives me my RdZ80() and WrZ80() functions... :) I can > start work on ds80io.c from there... It's something to start with. > Thx :) In article , Mike Guidero 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/