Assumed that the LM80C is actually fully functioning, we can try to use it as a real computer. The NASCOM BASIC used as programming environment has a lot of interesting functionalities: one of these is the ability to drive an input/output port using specific instructions like OUT and IN, that act as the corresponding assembly instructions. They permit to send/receive data to/from any I/O port connected to the CPU. In this little test we’ll try to drive the Z80 PIO of the LM80C by using BASIC commands.
We’ll use the actual hardware of the LM80C: at the moment, it has a Z80 PIO with an ULN2803 connected to its port B; the ULN2803 drives 8 LEDs. Let’s power up the LM80C, choose a Cold start, set the top of the memory to the max value (press Enter), then enter the following program:
10 OUT 3,&B11001111:OUT 3,&B00000000
20 FOR A = 0 TO 255
30 OUT 1,A : FOR B = 0 TO 50 : NEXT B
40 NEXT A
50 OUT 1,0
Let’s examine the list (I’m so happy to use this term: it brings me back some decades to my childhood when I passed a lot of afternoons typing on my C16 the “lists” of BASIC program I found in specialized magazines). At line 10 we are using the OUT command to set up the PIO. The command format is:
OUT port, value
Port is the I/O port as set in hardware, value is any value in the range 0..255 (a byte). As you can see by the code, we are sending commands to I/O port 3: how did I find this address? We need to go back through our steps and recover a previous article where I connected the Z80 PIO to the Z80 CPU. I set the connections so that the PIO command lines are attached to pins A1 & A0 of the address bus: by doing so, we can set the mode and the channel we want to talk to by simply addressing these 2 lines. By looking at the assembly code you can see that the control line of port B can be selected by setting A0 & A1 to 11b (binary format), that is 3 in decimal format. The meaning of the bytes I sent to the PIO can be retrieved by the PIO data sheet: here I just summarize that the first byte sets the port B to work in mode 3, the so called “bit control” where every single line can be set individually; the second byte sets the lines as outputs.
From line 20 to 40 I created a little loop that increments a variable and sends it to the PIO. To send the value to the PIO we must set A1 & A0 address pins to 01b, that corresponds to 1 in decimal format: in fact, at line 30 you can see that we are sending the “A” variable to port 1. This is done by OUT 1 command. Then I introduced a little delay so we can see the changing of the LEDs while the PIO receives the different values of “A”. Finally, at line 50, we tun off the LEDs after the loop is terminated.
The following video shows the program in action:
Code is also available on my GitHub repository.