With the Z80's CLK line now connected to a debounced slide switch, everything still seemed to behave as expected -- for example, the /M1 status line LED turned off (active/low) at M1-T1 high, while the /MREQ and /RD status line LEDs turned off (active/low) at M1-T1 low, exactly as shown in the Z80 timing diagrams. But I discovered that if I held the CLK line low for 'too long', the Z80 would sometimes lose its mind: it might, for example, start executing memory read cycles instead of M1 cycles, with the address line LEDs showing some random pattern). So I learned to 'quickly' toggle the clock's slide switch from high-to-low and back to high again, so that the CLK line wasn't being held low for too long. That seemed to solve the immediate problem.
--
You received this message because you are subscribed to the Google Groups "SEBHC" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sebhc+un...@googlegroups.com.
To post to this group, send email to se...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sebhc/842419cc-994d-411f-b9a8-925ba5f38a9c%40googlegroups.com.
Hi Mark,
Good to hear from you!
If there’s some specific questions you have re Z80 initial states, ask away and I’ll be happy to try to answer them.
The first question I wanted to answer was: What is the initial state of registers and flags following a power-on/reset?
Assuming the Z80 is held in reset for at least three clock cycles following power-on, all registers except PC, I and R are set to 0xFF or 0xFFFF. The PC, I and R registers are zeroed following any reset; no other registers are affected. (It’s been claimed that a reset sets SP to 0xFFFF; not so.)
The one exception I discovered is that the F register is initially 0x64 (01100100B), not 0xFF as I expected. Strange. I determined that value by executing a PUSH AF instruction immediately after power-on/reset and checking the state of the data lines during T2 of the second memory write cycle (A is written first to (SP-1); then F is written to (SP-2)). The data lines contains 0xFF during T2 of the first memory write cycle (pushing A onto the stack), but 0x64 during T2 of the second memory write cycle (pushing F onto the stack). I need to play around with this one some more and see if I can figure why F seems to be an exception to the ‘all-bits-set at power-on/reset’.
Paul
--
You received this message because you are subscribed to a topic in the Google Groups "SEBHC" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sebhc/xB5t-s6zX1o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sebhc+un...@googlegroups.com.
To post to this group, send email to se...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sebhc/CAAjkm78p9nXP6fWFr%3DNoF31J-0iC-XxHfgX-JurO0WT5Cs7bnQ%40mail.gmail.com.
Paul: Your statement about the value of the SP register on reset seems to contradict itself. You say that all registers except PC, I, and R are set to 0xFF or 0xFFFF, and those three are set to 0. Then you say that it has been claimed incorrectly that SP is set to 0xFFFF but this is "not true". So, what DOES happen to SP? It better have some determined value (pointing to RAM somewhere) if a PUSH instruction is going to be executed...
Sign me confused (John, W0JT)
To view this discussion on the web visit https://groups.google.com/d/msgid/sebhc/003d01d04bee%2435dc6400%24a1952c00%24%40comcast.net.
--
You received this message because you are subscribed to the Google Groups "SEBHC" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sebhc+un...@googlegroups.com.
To post to this group, send email to se...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sebhc/f4de17fd-2abe-4d36-8f98-7f522fd3d11c%40googlegroups.com.
Ok, sorry I failed to pick up on the distinction between first reset after power-on (set SP to 0xFFFF) and subsequent resets (leave SP alone). But I am curious about another aspect of the SP behavior. As you describe it, with the SP set to 0xFFFF, the pushed values go into memory locations 0xFFFE and 0xFFFD, not into 0xFFFF (where SP is pointing) and 0xFFFE. If this is true, SP doesn't point to TOS (where next byte goes) but rather to BOS (where the last byte went). Is this correct, i.e. in the scenario you describe, the very last byte of memory @0xFFFF is not written to?
--
Hi Mark,
First, Happy Birthday! (I got a notice from Outlook.com). Hope you’re not turning into an old guy like me. J
Second, I wanted to follow up on your message re Z80 initialization.
Because I wrote my Z80 emulator to run independently of my H89 emulator, I couldn’t simply force the Z80’s /RESET line to be active/low at the time the Z80’s clock was started. (I suppose I could have done that, but since the Z80 doesn’t have any sort of self-reset-at-power-on feature, I would have been cheating.) My H89 emulator holds the Z80’s /RESET line active/low for a fixed number of clock cycles when the clock is started at power on, since the H89’s CPU logic board provides a circuit to do just that.
I found some differences in behavior between my NMOS Z80 chip and CMOS Z80 chip. In general the CMOS chip is better behaved.
With both chips I found all registers to be in their ‘all bits set’ state with the exception of the F (flags) register. Oddly, I saw a couple of different F register values when I powered on the chip. (To determine the value of the F register, I executed a PUSH AF instruction following reset, which loads the F register onto the data lines during the first memory write cycle; the values on the data lines sometimes varied but were never 0xFF. Pushing any other register pair always produced 0xFF on the data lines during the memory write cycles.)
Also, I discovered that, if I started the clock without holding the /RESET line active/low, the CMOS Z80 chip ‘wasted’ a couple of cycles but then started executing an M1 cycle with PC=0x0000, just as would normally happen when the Z80 comes out of reset. The NMOS Z80 chip on the other hand went a bit crazy, activating various status lines in odd combinations. Sometimes it would eventually start a normal M1 cycle, in other cases it would just cycle through a sequence of odd states.
One interesting observation with the CMOS chip: With the /RESET line held low at power on, if I then start the clock, it takes one or two clock cycles before the address and data lines are floating and the status lines are all inactive/high. This is to be expected because the Zilog documentation says it takes three clock cycles before the reset is “accepted”. In fact , the Z80 only samples the /RESET line during low-to-high transitions, so depending on when the /RESET line is activated, it takes two samples to put the Z80 into reset (on the 3rd sample). What’s curious is what the Z80 is actually doing for those first two clock cycles. The behavior seems different if the /RESET line is active/low when the clock starts following power-on, versus the /RESET line becoming active after the Z80 has started normal processing. In the first case, those two clock cycles seems to do nothing; in the latter case those two cycles are normal processing cycles. For example, once the Z80 has started normal processing, if the /RESET line becomes active/low at the start of T2 of a normal M1 cycle, the Z80 will execute the T2 and T3 cycles as normal, then go into reset at the start of T4 (address and data lines floating; all status lines inactive/high). But when the clock is started with the /RESET line active/low following power on, the next two clock cycles appear to do nothing.
Of course, the only clues I have in all this is the Z80’s address, data and status lines, so I can’t know what’s going on internally. I know there are smart people out there that have reverse engineered the Z80’s gates and can better speak to its internal workings than me.
By the way, how did your ‘raw’ disk format project finally turn out? I thought that was a great design, and I’m planning to implement it in my H89 emulator (it will support the standard *.h8d disk images as well as your .raw disk images. With the option to save a disk image file, I can save a disk image in either format, which will allow me to convert any h8d formatted disk image into a raw disk image. The obvious advantage to your raw format, besides being a more accurate image of a floppy disk, is being able to save the disk’s volume ID, something you can’t do with the h8d images (since they contain no header fields).
Take care,
Paul
From: se...@googlegroups.com [mailto:se...@googlegroups.com] On Behalf Of Mark Garlanger
Sent: Wednesday, February 18, 2015 11:49 PM
To: se...@googlegroups.com
Subject: Re: [sebhc] Re: Driving a Z80 chip with a 'slow' clock
Cool, lots of good info for my emulator.
Mark
--
You received this message because you are subscribed to a topic in the Google Groups "SEBHC" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sebhc/xB5t-s6zX1o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sebhc+un...@googlegroups.com.
To post to this group, send email to se...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sebhc/CAAjkm7-pESXrhxDd6kLXCcCuMoOkmSGRdxw5pYt3%2Btj61_5ygA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sebhc/00c601d05db6%24db394920%2491abdb60%24%40comcast.net.
Hi Gregg,
Yes, thanks. While it’s true that HDOS stores the user-specified volume ID in the Label sector of a floppy at the time the disk is initialized, it also stores the volume ID in the Volume field in the header of each sector.
My H89 emulator, which includes a floppy disk controller emulator, needs to correctly read and write all of the bits stored on a floppy, including both user and header data. The standard .h8d disk images provide only user data (256 bytes per sector), not the header data. So my emulator creates each sector’s header data ‘on the fly’ when a new h8d disk image is loaded. That’s easily to do, except for the Volume field in the header. In the case of h8d images my emulator could get that value from the Label sector, but that would be cheating — the emulated floppy controller should know nothing about the format or content of the 256-byte user data in each sector, or how a particular OS might organize the data on the disk. Instead, my emulator currently zeros the Volume field in the header of each sector, even though that might not be the correct value.
Mark’s raw disk format is ideal for my (still-in-progress) floppy disk controller emulator because it provides an image of all the bits stored on a floppy disk, regardless of which OS (HDOS, CP/M, etc.) might have written those bits. Furthermore, the captured bits in a raw image file can start anywhere on the disk — the image file need not organize its data starting with track 0, sector 0 — since the raw disk image includes the necessary status bits (TRK0 and HOLE) to map each captured bit to a specific track, sector and offset with the sector. (The only requirement is that the number of bits captured in each track be the same.)
Paul
Thanks Mark, I’ll give this a good read and offer any comments, suggestions.
Paul
P.S. I have a few (too many) years on you. But I’ve decided to stop aging at this point, so I’ll let you know when you’ve caught up.
Thanks Dwight,
I’m not a hardware guy, so ‘metastable condition’ is a new term to me. I think I get the concept, and it helps me understand why the Z80 needs two full clock cycles before it ‘accepts’ the reset (Zilog says three, but my testing showed that two consecutive low-to-high clock transitions with the /RESET line active/low is enough to force the reset), and what might be going on during those two clock cycles).
In the case of my CMOS Z80 chip, I can’t say that the chip always starts life in a ‘happy state’, but it never seems to lose its mind the way the NMOS chip does if I start the clock with the /RESET line inactive/high. Sometimes when I power on the CMOS chip with the /RESET line active/low, the address and data lines are already floating, other times it takes one or two cycles before they float. In the case where I activate the /RESET line after the clock has started, it always takes both of those two ‘acceptance’ clock cycles before the address and data lines start floating (unless those two clock cycles would have normally had them floating).
Paul
Hi Gregg,
I appreciate all your comments, and have certainly found myself at times ‘mired’ in compromise when designing and building my Z80 and H89 emulators. (I can’t tell you how many times I went through major redesigns with my Z80 emulator, trading off hardware accuracy to achieve better performance.) I set out from the start to build emulators that mimicked the hardware as closely as possible without ending up with Spice. J And my ‘cheating’ reference was from the perspective of my own design requirements; I certainly understand that other emulators might have a different design center, so their definition of ‘cheating’ could vary significantly from mine.
My H17 floppy disk emulator needs to load and save single floppy disks in the form of disk images stored on the host OS (in my case, Windows). The h8d disk image format is one way to represent an H17 floppy disk’s data, limited to 256 user bytes per sector. In my case I wanted image files that contained all of the data found on an disk, not only the user data. Mark’s raw data design provides that. My emulator will work fine with either type of image file, although I will need to generate the missing header data, since my floppy drive controller emulator emulates the S2350 USRT chip and needs to handle all the bits passing under a drive’s read/write head.
My goal is to implement both disk image formats, so that I can load and save disk images in either format, and providing a ‘for free’ conversion from one format to the other. The intent isn’t to inject a competing format with the h8d images, only to end up with disk images that more closely align with my emulator’s design goals.
Paul
From: se...@googlegroups.com [mailto:se...@googlegroups.com] On Behalf Of Gregg Chandler
Sent: Saturday, March 14, 2015 5:10 PM
To: SEBHC
Subject: Re: [sebhc] Re: Driving a Z80 chip with a 'slow' clock
Paul:
--
You received this message because you are subscribed to a topic in the Google Groups "SEBHC" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sebhc/xB5t-s6zX1o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sebhc+un...@googlegroups.com.
To post to this group, send email to se...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sebhc/D12A1BFB.DF30C%25info%40esx.com.