Popular Electronics
AUGUST 1976
[33] [34] [35] [36] [37] [38]
[Part 1] [Part 2] [Part 3] [Part 4]

ONE BYTE INSTRUCTIONS TWO BYTE INSTRUCTIONS
1NRN+130MMGO TO MM
2NRN-131MMGO TO MM IF Q=1
8NRN,0–>D39MMGO TO MM IF Q=0
9NRN,1–>D32MMGO TO MM IF D=00
AND–>RN.03AMMGO TO MM IF D != 00
BND–>RN.133MMGO TO MM IF DF=1
4NMN–>D,RN+138MMGO TO MM IF DF=0
5ND–>MN34MMGO TO MM IF EF1=1
DNN–>P3CMMGO TO MM IF EF1=0
ENN–>X35MMGO TO MM IF EF2=1
7A0–>Q (LIGHT OFF)3DMMGO TO MM IF EF2=0
7B1–>Q (LIGHT ON)36MMGO TO MM IF EF3=1
F0MX–>D3EMMGO TO MM IF EF3=0
F1MX or D–>D37MMGO TO MM IF EF4=1 {IN SWITCH
F2MX and D–>D3FMMGO TO MM IF EF4=0 {IN SWITCH
F3MX xor D–>DF8KKKK–>D
F6SHIFT D RIGHT, BIT 0–>DFF9KKKK or D–>D
76ROTATE D RIGHT, DF–>B7,B0–>DFFAKKKK and D–>D
FESHIFT D LEFT, BIT 7–>DFFBKKKK xor D–>D
7EROTATE D LEFT, DF–>B0,B7–>DFFDKKKK-D–>D,CARRY–>DF
F5MX-D–>D,CARRY–>DFFFKKD-KK–>D,CARRY–>DF
F7D-MX–>D,CARRY–>DFFCKKKK+D–>D,CARRY–>DF
F4MX+D–>D,CARRY–>DF7CKKKK+D+DF–>D,CARRY–>DF
ONE BYTE INPUT INSTRUCTIONSN2N1N0 1-BYTE OUTPUT INSTRUCTIONSN2N1N0
69BUS–>MX,D001 61MX–>BUS,RX+1001
6ABUS–>MX,D010 62MX–>BUS,RX+1010
6BBUS–>MX,D011 63MX–>BUS,RX+1011
6CINPUT SWITCH BYTE–>MX,D100 64MX–>HEX DISPLAY,RX+1100
Table 1. Instruction Subset Table shows required sequence of steps.

the bus so that it can be stored at the memory location addressed by RX. This input byte will also be placed in the 1802's D register.

When a 64 instruction is executed, N2 is high and ~MREAD is low, making the output of IC10C high and preventing the input switch byte from getting onto the bus. Instead, gate IC10B generates an output clock pulse with TPB that clocks the RAM output byte into the hex display.

The four external flag input lines– EF1, EF2, EF3, and EF4–can be pulled low by external switches. These four lines can be tested by instructions 34, 3C, 35, 3D, 36, 3E, 37 and 3F. Note in Fig. 5 that the INPUT pushbutton switch, debounced by portions of IC11, is connected to the ~EF4 line. This means that ~EF4 = 1 when S12 is depressed and ~EF4 = 0 when S12 is in its normal position.

Latched output line Q can be set high by a 7B instruction or reset to low by a 7A instruction. The Q LED comes on when Q is high. The ~DMA~IN, ~DMA~OUT, and ~INTERRUPT lines can be pulled low to cause these operations to occur.

The ~LOAD and RUN lines control the operation of the microprocessor according to the following conditions:
~LOADRUNMode
gndgndload
+5Vgndreset
gnd+5V
+5V+5Vrun

RUN and LOAD switches S1 and S2 in Fig. 5 control the operation of the computer. With both switches set to OFF, ~LOAD is +5V and RUN is at ground potential. This resets the 1802. Neither TPA nor TPB are generated in the reset state and R0 = 0000, P = 0, X = 0 and Q = 0 after the 1802 is reset. When the LOAD switch is set to ON, ~LOAD goes low and RUN stays low, forcing the system into the load mode. Now you can load a sequence of bytes into the RAM, starting at address 0000, by setting the bytes into the input toggle switches, one at a time, and operating the INPUT switch.

In the load mode, the 1802 does not execute instructions but waits for a low to appear on the ~DMA~IN line. When this happens, the 1802 performs one memory write cycle during which the switch input byte is stored in memory. R0 is used to address memory. during the DMA IN cycle. After the input byte is stored at the address specified by R0, this register is in- [38]

[Article Sidebar]
INTRODUCTION
TO PROGRAMMING

Once you have built your Elf, you must learn how to load a sequence of bytes into memory and then go back and display the sequence. Let us write a simple program that can be loaded into the memory and run.

Suppose you want to program the computer to turn on the Q LED whenever the INPUT switch is set to ON. First, you must draw a flow chart that shows the required sequence of steps (Fig. 7). Locate the correct instructions in the Instruction Subset Table. A 7A instruction will perform Step 1. Load this instruction into M(0000). Note that when the INPUT switch is not depressed, EF4 = 0. A two-byte 3F 00 instruction will jump (branch) back to the 7A instruction at M(0000) as long as the INPUT switch is not operated (EF4 = 0). This condition is known as a "loop," and the program will stay in this loop while it is waiting for the INPUT switch to be depressed. Load 3F 00 into memory locations M(0001) and M(0002) to perform the second step in the flow chart. All GO TO MM instructions shown in the Table put MM into the low-order byte of the program counter if a GO TO condition exists. Otherwise, the next instruction in sequence is fetched by the 1802.

Loading a one-byte 7B instruction into M(0003) takes care of Step 3, while a 30 01 instruction will jump back to the 3F 00 instruction at M(0001). Load the 30 01 instruction at M(0004) and M(0005) to complete the program.

You load this 6-byte program by placing the LOAD switch on the ON position, with

RUN and MP set to OFF, setting up the toggle switches for the hex number 7A, and depressing the INPUT switch. Release the INPUT switch, insert 3F and operate the INPUT switch again. Then load 00 and so on until the last byte, 01, has been stored at M(0005). If you "blow" the program, set MP to ON and LOAD to OFF. Then set LOAD to ON and operate the INPUT switch until you get to the byte immediately preceding the wrong entry. Set MP to OFF, set up the correct byte, and operate INPUT. Flip MP back to ON to protect what you have stored in memory.

To start the program running, set LOAD to the down position to reset the 1802 and set the RUN switch to ON. Nothing should happen until you depress the INPUT switch, at which time the Q LED should come on. Releasing the INPUT switch should cause the LED to extinguish. If you like, you can now observe the timing signals of the 1802 on an oscilloscope while the program is running.

Another simple program involves counting the number of times the INPUT switch is operated and then turning on the Q LED at the end of the count. The flow chart for this program is shown in Fig. 8. When you load and run this program, nothing will happen until you operate the INPUT switch five times, at which point the LED will come on and remain on. Note in Step 1 that you can change the number of times the INPUT switch is operated. Step 6 just loops on itself to terminate the program after the INPUT switch has been operated the specified number of times.

[33] [34] [35] [36] [37] [38]
[Part 1] [Part 2] [Part 3] [Part 4]
37 AUGUST 1976