This is Hacker Public Radio episode 3,812 for Tuesday, the 14th of March 2023. Today's show is entitled, he pause computer does nothing. It is hosted by Brian in Ohio and is about 25 minutes long. It carries a clean flag. The summary is, a Z80 no-op test. Hello Hacker Public Radio, Brian in Ohio here. I'm out from under my rock doing part 2 of the Z80 computer build. As you can tell by the title, today's show is, peepos computer doesn't nothing. What that means, of course, if you don't know peepos, that's me, who my two-year-old grandson calls me peepo. He's the impetus, the reason that I'm doing this project and chronicling it here on HPR. So that maybe one day in the future, he or turns out his brothers in the oven, or maybe his cousin who's also in the oven. Maybe one of those three, or maybe all three, or who knows, will someday in the future, one or all of those kids will hang out with their old grandpa and learn how a computer works by building one themselves. So here I am, learning to do myself beforehand, getting ready. And so, in the last episode, I put together the one piece of test equipment that I needed, which was a logic probe, because I'm going to initially spool up this Z80 system using the facilities of an Arduino mega board to emulate, rom, and ram, and also to provide that some test equipment, like a logic probe, so I can program the system when I provide the required things to see if it's up and running. And so what's required initially is some power, clock signal, and some data. And the data I'm going to give it is, give the Z80 is provided by the Arduino mega board, which will be the machine code, which has the op code of zero. So the Z80 has about 180 instructions that it recognizes. They're all hexadecimal, coded, and it zero zero to the processor when it sees that. That's a no-op, it means do nothing and move on to the next instruction. And in this case, because the address lines aren't going to be hooked up to anything, they're not hooked up to any memory, it's just going to think that it's gone from one memory location to another, and it's just going to find another no-op. And so that's why this is called the no-op test. You're just getting the computer up and running, and having to do exactly nothing. So a couple things is to make sure just to clarify, I'm using an Arduino mega board, but it's not the Arduino environment. I'm running flash forth on it, and why would I use flash forth to do this instead of the Arduino environment, because flash forth is interactive. Without being a huge application in itself, there's other interactive languages that run on Arduino boards, things like circuit Python, but they're huge compared to the size of a fourth virtual machine. And also it's fourth is really geared towards manipulating things at the bare metal level, being able to dig into the registers and control whatever computer it's on at a very foundational level without any abstraction layers in between, except the ones you build yourselves by defining words. And why am I using them? They are doing a mega board instead of the Arduino unabored. It's because they're doing them, or yeah, instead of which has the mega 328 chip, and then has to do with the fact that the Arduino mega board has oooles and oooles of IO. It's got tons of ports, tons of available ports that I can manipulate to interact with the ZAD chip. It should be a snap to do it with this board. So the micro control board, like I said, is going to give the five volts the clock signal and the data to get the ZAD up and running. It's also going to provide the logic probe so we can test to see that it is running. So I wired up a probe shield that plugged into the board. First thing I did, and I've got pictures in the show notes to show all this stuff, is I hot glue to solder the spread board onto the Arduino mega probe shield, and then I plugged in the ZAD and the first wire that's shown by itself is a white wire that's the actual logic probe, that's from the last episode. I can plug that in onto the different pins of ZAD and see if things are happening or not. The next picture just shows power and brown being connected. I've split the power wire so I can have a rudimentary on-off switch. The next picture, there's a picture number 3 with the blue wire that's a clock signal. And then the next one picture number 4 has got the show's yellow lines that are the control lines. The interrupt, the non-masculine interrupt, the white signal, the bus request and the reset signals. Those are all signals that are input to the ZAD to help control what's going on. Then orange wires are all the data bus. They go up to port A on the Arduino mega board. And the address lines then are, I put a little silver dot on the chip to show where pin 1 is. And so from where the clock chip is, which is pin 6, up and around clock wise, those unconnected pins are on the ZAD chip or all address lines. And the one that we're most interested in is the one at A0, which is next to the ground line, next to that black wire. And that's the one we'll be probing once we start this because what's as the ZAD goes through memory space, it's going to put each individual starting at zero and working up all the way up to 65,000 binary 16-bit data addresses. And so that pin should be cycling between zero and one the most of all those pins. And so if I see activity on that pin, then I'm pretty confident that the chip is up and running. Now, so that's the hardware side of the test we're going to do today. On the software side, I fixed some of the fourth words in the last code that I presented in the last episode. It's kind of good HPR as a, it's always, it's good, it helps you to, when you post something and then even after the fact that I was looking at over and I saw that I made some mistakes and I refactored some of the words broken apart and I defined some new words, and that listing is in the show notes too. And so the fix I made was that the data processing word as defined was getting, when it, to sense that it was a static either higher or low signal, it was probing the wrong point. It was probing the output of pin H3 digital, six I think it is on the digital six on the, on the, on the, are doing a megabord. And what I really wanted to, you see, look at what was the input into pin E, the logic probe that, that white wire. So I changed that. I changed the, the output there too on the data processing word. I really don't care what frequency it is. So I just changed the word to, to just output if it's pulsing or just say it's pulsing, just put on the serial terminal pulse, the word pulse. Because I'm not interested in specific frequencies. I just put the clock in the logic and knit words, so that I can initialize the clock registers and on the, on the AVR chip. And I could, and the same for the logic probe, just, split in two words. I added some words to control the reset line. Those words are reset and run. Reset takes the, the pin, the reset pin from a high level state, which is in the run mode, and takes it to a low level state. So almost all control signals on the Z80 are active low. So when they're driven to ground, driven to zero voltage, they become active and do what they're supposed to do. So when you take the reset line and, and drive it to ground, then the, the chip is, is in a reset mode. And I added one more to, to be able to single step the clock. So I can, I can start and stop the clock with those words, start clock and stop clock. And I can change the frequency of the clock by, by, putting a number and, and then, calling the words set frequency. But I also wanted to be able to single step the, the, the, the, the Z80 chip. So that, we can probe around and look to see some other signals to see what's happening because the, the, like all computers, this Z80 has a very systematic way of functioning. And what it does is it, it, initially, it reads in from the data, looking, looks for, and it, it, and it interprets that first bit of data as, um, as some kind of instruction. And then if that instruction needs more data, it goes and fetches it, and then it processes it. And so the, you can, there's different signals that come alive in that process because each instruction for the Z80 takes between, I think it's like four in 20 clock cycles, depending on how long and how much data it needs. Um, so we, I've got the, uh, to, uh, I guess, uh, enough explanation I can do the test here. I've got the board plugged in. I've got, um, and I've got my serial term. I've got a, a little, uh, a serial term with serial terminal with a flash forth running at the flash forth prompt. And the first thing I'll do is I'll, uh, get the logic probe up and running by typing the word, um, logic probe, uh, in it. And why do that? It says, okay. Uh, and then I, uh, I'm going to, um, get the microtr, controller boards set up the ports on it. So that's, um, going to be, uh, let me look at my code. I can't remember exactly. Oh, Z80 ports in it. Basically what this does is it sets up those, those interconnections between the Z80 and the, and the, are doing a mega board up with all those wires. It, all those things that it's connected to, it's setting up them, them up correctly as either inputs or output ports. And so that is the word, Z80 ports in, uh, in it. And hit that, it's okay. And then, um, now add some power to the Z80 chip. And so I just, uh, plugged in five volts on the board. And now I should be able to, uh, the clock should be started. So I should be able to take my white logic probe and put it where the blue wire is. And I should be able to type the word sample in. And I'm expecting to see the word pulse output. And I do. And I can double check that that's actually working. I can go stop clock. Uh, this is the way I'm going to stop the clock. And now I'm going to do another sample of it of the pin. And, um, I'm in the wrong place. It's, uh, let's see here. Put this in to the right place. There you go. I should be able to get, um, let's see here. Seven. Okay, so I, uh, I had to, I never initialize the clock. I never typed in clock in it. So now I typed in clock in it, which, uh, initializes the clock. And now I can, uh, I can, um, I can, uh, start the clock. And I can sample. And, oops, different type quickly. Sample. It comes out pulse. And then I can stop the clock. And I can sample. And now it shows that it's a low. It's, it's not pulsing. It's a low signal. And I can start the clock again. And now, the next thing to probe is I'm going to take a, the logic probe wire that went wire out for more of the clock is the blue line. And I'm going to put it over in the A0 not line, which is that, that empty pin right next to the ground wire. And I'm going to, uh, sample there. And I need, and I get a high signal. So what I need to do is I need to properly reset the, the, the board, which I'll just type in the words reset and run. And then I should be able to sample. And I get a pulse. So the, so on the A0 pin, it's pulsing. And if I stop the clock. Oops, stop. If I type it correctly. Stop the clock. And now I sample. It's just a high because it's not, um, the clock stopped and you need a, a functioning clock for it to work. Um, so that to me is a good, uh, indication that the Z80 chip is, uh, behaving properly that it's, um, that the wiring and everything is connected correctly. And so now, uh, one other experiment, one other thing I can check is I can check the M1 line. M1 line is right next to the, um, well, I should make sure I've got, I've got a, uh, image of the, um, of the, uh, got the image of the Z80 chip, the pin out of the chip in the show notes. And yeah, M1 is actually, um, right next to reset. So, whatever. So the, the, um, the way is this, the, the order of things that happen when the Z80, uh, starts functioning when you first reset it. So what happens is we bring power up. You reset the, the, the Z80 puts it in no good state. It puts the program counter to zero. It puts address zero on the address bus. And then it, it, uh, it then draws M1 low. And M1 is just a signal. It, it draws the M1 signal low. And that's the indication, and it's starting the first part of what they call a machine cycle. Machine cycle is everything it takes to complete, uh, to get us in instruction, whatever data needs, and then finish it. And then, and then, uh, uh, it signals all this by first off, bringing them the M1 line low. And so the way to check that that's actually happening is to go back to that, uh, the terminal, and the clock is right now stopped. So I'm, I'm not going to start the clock. I'm going to single step the clock. And what I'm going to do is I'm going to, uh, go back to reset. I'm going to single step the, um, uh, just step, sorry step. I'm a single step, and then sample the pin. And I should see it high. And I'll do that a couple times, um, because it takes three clock cycles for the chip to be properly reset. So here we go. I'll do that one more time. And now I'm going to put the reset line into the run mode. And now I'm going to single step again and sample. And the M1 signal pin is still high, that clock signal. And now one more clock signal. And now when low, it's the beginning of a machine cycle. And if I click clock at a couple of times, it'll go back to high. And so I know that the, the M1 signal is working. And so with the A, uh, the address zero pulsing, um, that it, that it has busy, that it has activity on the address bus. And with the M1 signal cycling the way it is, I'm pretty confident that, uh, this is the 80 chip is, is good. And that, uh, it was a good, uh, a good, uh, no optest for that, uh, for that chip. And so I think that, uh, covers, I'm going to look my notes here. Uh, uh, uh, uh. Yeah, um, oh, there was one more thing we can do. And, and then that'll, that'll be the end. The last, uh, the last, uh, the last signal to probe. And this one is going to be, uh, the halt signal. When the, uh, when the, uh, uh, Z80 interrupts, uh, when the Z80 encounters a halt signal, it actually halts this, the processor, and does no opts internally until it receives an interrupt signal. And the halt signal, again, is active, um, believe it's active low. Also, and it's on pin number 18 of the chip. So I'm going to put it with the logic probe into, pin 18, and, um, do the same exact process. I'm going to reset the chip. So, uh, start with, uh, by putting it in, I put it in reset. And then I will, um, cycle the clock, uh, and sample a few times here. And now this time what it's going to be different is I'm going to put the, uh, hex address of 76, hex 76 on the data bus. Uh, and so, so when I start, uh, when I start to run the program, instead of finding on the data bus at address zero, a, a, a machine instruction zero, it's going to, the Z80's going to find on the data bus, the machine instruction 76, which is halt. And when it does that, I should, we should see when I sample that pin, the, the halt signal, it should go low. So let's do that. Let's put, uh, 76 into, um, um, the data port. And I do that by typing in 76 data, uh, dollar sign 76, which is the hex notation in fourth for hex numbers, dollar sign 76. And then the word data, which is the data port, and I'm going to do C store, which is C and an exclamation point. That'll store the number 76 onto the data port. And I got the wrong thing. What's it called? May I got the wrong word? The wrong thing. It's called, um, what's it called? Yeah. Oh, it's couples, uh, case sensitive, fourth is, this fourth is case sensitive. So 76, capital DATA, C store, uh, C store, the values, the hex values 76 into the data port. And I get OK. And now I'm going to, uh, sample, and, uh, step and sample, the clock. And because it's, it's nothing there. OK. Now I'm going to, put the, the Z80 into run mode. And now I'm going to step and sample. And do it a few times to, because it'll take about four or five or six to get there. And there are now, the, the pin, uh, 20, the signal on pin, uh, 18 went from high to low. And that to me, uh, because it found that 76 on the, uh, on the data bus, it executed the instruction halt. And now this, the, um, uh, the Z80 is in a halt mode. So if I, if I, if I start the clock now, I'm going to do a nice sample. It should stay low. It should stay low. It should stay low. The, now completely, and a little stay low until I reset it, uh, or give it an interrupt signal, which I'm not going to do. And so there we go. Uh, Looks like I've got a functioning, uh, good does the 80 chip. I, have learned a little bit. It's about how to, um, manipulate, and a couple of instructions, the no-op instruction, and the halt instruction, and put them on the data bus, and, and get the, uh, Z80 to respond accordingly. And I was able to, uh, um, see all those things by, using the logic probe that's, that it's built into the, software on the, our degree. So, consider, consider this, uh, a successful experiment. Um, I think, uh, I'm not sure where to go from here. I think the next thing to do would be to, maybe do a, a more, um, a more, a longer set of instructions, a small program, and, uh, maybe even, I might have to add some LEDs or something. We'll see, or at least put out some numbers on to the, serial ports, like we can see get some output that way. And, um, and that'll require emulating, emulating some RAM. I think I'm, excuse me, a ROM, emulating some read-only memory. So I'll be the next, uh, the next step in this project. So, um, thanks for listening. Um, if you have any questions or comments, go ahead and leave them in the show notes, or you can email me. And if you, um, or if you're interested in this project, and if you, um, or if you're interested in retro computers, or doing something like this yourself, uh, pick up a mic and start recording a show, and upload it to HackerPublicRadio. And, if you, um, and anyway, thanks for listening. I appreciate your attention. And I just like to remind everybody, that it's not how much an item costs. It's how much you save. Goodbye. You have been listening to HackerPublicRadio, at HackerPublicRadio.org. Today's show was contributed by a HPR listening like yourself, if you ever thought of recording podcast, and click on our contribute link to find out how easy it means. Hosting for HPR has been kindly provided by an onsthost.com, internet archive, and our Sync.net. On this otherwise stages, today's show is released on our Creative Commons, at Tribution, 4.0 International License.