Last updated June 9 2012. Edited by Herb Johnson, (c) Herb Johnson, except for content written by Lee Hart and others.
The group of four switches on the left are, from left to right:
S11 IN (a pushbutton) S10 LOAD (a toggle switch) S9 CLEAR (a toggle switch) S8 READ/WRITE (a toggle switch)
S10 LOAD and S9 CLR are the mode switches. They select 1 of 4 modes:
RUN - both up WAIT - right up, left down (CLR up, LOAD down) CLEAR - right down, left up (CLR down, LOAD up) LOAD - both downPower-up state
IN LOAD CLR R/W S11 S10 S9 S8 down down down 0. Select LOAD mode (R/W down to avoid write) apply power
To examine memory
IN LOAD CLR R/W S11 S10 S9 S8 down down down 0. Select LOAD mode (R/W down to avoid write) up down down 1. Select CLEAR mode (resets program counter to 0) down down down 2. Select LOAD mode (R/W down to select read) push 3. Reads memory location 0, displays contents on the LEDs, then increments program counter to 1 push 4. Reads memory location 1, push 5. Reads memory location 2, etc.
To load memory
IN LOAD CLR R/W S11 S10 S9 S8 down down down 0. Select LOAD mode (R/W down to avoid write) up down down 1. Select CLEAR mode (resets program counter to 0) down down down Select LOAD mode (R/W down to avoid write) down down up 2. Select LOAD mode (R/W up to select write) push 3. Set switches S0-S7 to byte to write to memory, then push IN. LEDs will change to show the data written, and program counter increments push 4. Set switches to next byte, press IN, push 5. Set switches to next byte, press IN, etc.
To modify memory location N
IN LOAD CLR R/W S11 S10 S9 S8 down down down 0. Select LOAD mode (R/W down to avoid write) up down down 1. Select CLEAR mode (resets program counter to 0) down down down 2. Select LOAD mode (R/W down to avoid write) push 3. Reads memory location 0, displays contents on the LEDs, then increments program counter to 1 push 4. Reads memory location 1, push 5. Reads memory location 2, etc. ... push 6. Reads memory location N-1, increments program counter to N down down up 7. Select LOAD mode (R/W up to select write) push 8. Set switches S0-S7, push to byte to write to memory. (then "examine memory" to verify results)
To run a program in memory
IN LOAD CLR R/W S11 S10 S9 S8 down down down 0. Select LOAD mode (R/W down to avoid write) up down down 1. Select CLEAR mode (resets program counter to 0) up down up 2. (optional if program writes to memory) up up -- 2. Select RUN mode. Program begins executing at 0.
Written by Lee Hart Mar 25 2010.
Herb: What do you recommend for a test configuration with NO ROM? Jumper settings and some switch toggling? Should I make a ROM header with specific data pins tied to ground to force an instruction?
With no ROM or RAM, the CPU will execute "air", and march aimlessly through the addresses. Look at the address and data buses with a 'scope or logic probe and you should see them all toggling. Note that the IDL instruction (all 0's) will *halt* the CPU, so add one pullup resistor from supply [+5 volts] to any data bus line to prevent it.
With a RAM, the front panel switches will work as follows:
[To write:] Select CLEAR, then LOAD mode. With WRITE enabled, set the data switches, and push the IN button. The LEDs should display the byte just loaded into memory address 0000.
Continue setting the data switches and pressing IN to load more bytes into consecutive locations.
To read: select CLEAR, select WRITE PROTECT, then select the LOAD mode. This time, it ignores the data switches. Each press of the IN button displays the contents of consecutive locations in memory starting at 0000. With a ROM, read mode is the only mode that works.
Your first programs: turn Q LED on and off
address data 0000 7B set Q (turn on the Q LED) 0001 00 idle (halt until clear, DMA, or interrupt)
Next try a loop:
address data 0000 7B set Q (turn the Q LED on) 0001 38 NBR (no branch, just continue) 0002 7A reset Q (turn the Q LED off) 0003 30 BR 0000 (branch back to 0) 0004 00
Q should produce a square wave, blinking on/off. The square wave frequency is the 1802's clock frequency divided by 64, so the blinks will be too fast to see, but you can verify it with a 'scope.
This program blinks Q far slower, so you can see it.
0000 7A reset Q 0001 F8 load... 0002 10 ... 10 hex (change this byte to blink faster or slower) 0003 B1 ... into register 1's high byte 0004 21 decrement register 1 0005 91 get high byte of register 1 0006 3A branch if not zero... 0007 04 ... to 0004 0008 31 branch if Q=1... 0009 00 ... to 0000 and reset Q 000A 7B set Q 000B 30 branch... 000C 01 ... to 0001 to skip reset
In assembler, this looks like:
0001 R1 EQU 1 0000 start ORG 0H 0000 7a REQ ;reset Q 0001 f8 10 L0: LDI 10H ;counter 0003 b1 PHI R1 ;into high R1 0004 21 L1: DEC R1 ;decrement 0005 91 GHI R1 ; 0006 3a 04 BNZ L1 ;branch until R1 is zero 0008 31 00 BQ start ;if Q set, go back 000a 7b SEQ ;otherwise set Q 000b 30 01 BR L0 ;and branch to counter 000d END
A shorter version is this:
addr data instruction Blinks Q slowly (every ---- ---- ----------- ~2 seconds at minimum 00 7B SEQ ; set Q clock frequency, ~12 Hz 01 FC 01 ADI 1 ; D=D+1 at max clock frequency) 03 3A 00 BNZ 0 ; branch to 0 if D not 0 05 7A REQ ; reset Q 06 FC 01 ADI 1 ; D=D+1 08 3A 05 BNZ 5 ; branch to 0 if D not 0 0A 30 00 BR 0 ; branch to 0
Here's programs to read the data switches, and display them on the LEDs.
addr data instruction ---- ---- ----------- 00 E1 SEX 1 ; set X=1 01 90 GHI R0 ; D=R0 high byte (i.e. 0) 02 B1 PHI R1 ; set R1=00xx 03 F8 0A LDI 10 ; set D=10 (hex 0A) 05 A1 PLO R1 ; set R1=000A 06 6D INP 5 ; read switches 07 65 OUT 5 ; write to LEDs, but increments R(X) 08 30 00 BR 0 ; branch to 0 to reset R1 to 10 0A xx ; RAM storage for INP/OUT instructions
Note that RESET sets P=0, X=0 and R0=0000. So R0 is the program counter (P) and R0 is the index register (X) until it's changed with the SEX instruction.
- Lee Hart Feb 21st 2010, shorter version & read data switches Sept 5 2010
To display the COMPLIMENT of the switches, a little more dramatic display program is below. I use R3, not R1. Note how INP, OUT and arithmetic/logic operations like XRI work in different ways. - Herb Johnson, June 2012.
0000 80 glo R0 ; zero value in R0 at reset 0001 B3 phi R3 ; high byte = 00 0002 F8 10 ldi 10H ; low byte = 10 0004 A3 plo R3 ; R3=0010 now 0005 E3 sex R3 ; X-->R3 0006 6C loop: inp 4 ; read switches into D and M(R3) 0007 FB FF xri 0FFH ; invert the bits in D 0009 53 str R3 ; save result in M(R3) 000A 64 out 4 ; and write M(R3) to LED's (incr R3) 000B 64 dec R3 ; cancel incr with decr 000C 30 06 br loop ; to read and write again 000E END
This page and edited content is copyright Herb Johnson (c) 2010. Contents written by Lee Hart, are copyright Lee Hart (c) 2010. Copyright of other contents beyond brief quotes, is held by those authors. Contact Herb at www.retrotechnology.com, an email address is available on that page..