Simple 1-Bit Light Computer

                    

Source Code Binary Code   Memory   CPU
  
  
0000
  
P0
Q0
 
 


Instruction Set for Simple 1-Bit Light Computer

0 Turn the Light Off off
1 Turn the Light On on


-- Description --

This simple computer uses a single bit instruction. A single bit can only take on two possible values. It's either on or off. We normally write these values as 1 (for on) and 0 (for off). This computer uses these instructions to turn a light (a red "LED" in this case) either on or off. In other words, a "program" for this simple computer is just a series of 1's and 0's which tell it when to turn the light on or off.

This computer can be programmed in either binary (1's and 0's) or with words ("on" and "off"). The words are called "Source Code", and they are entered into the "Source Code" text block. Each instruction word of the source code must be separated from other instruction words with either a space or a new line. The use of the words "on" and "off" instead of "1" and "0" is actually more typing, but it introduces the concept of using human-friendly words in place of binary codes when writing programs. The human-friendly words are not much better in this case, but they will be much more helpful when programming more advanced computers.

The "Compile Program" button will convert all of the source code into binary instructions and show the binary program (along with addresses) in the "Binary Code" text block. Pushing the "Compile" button will write over any binary instructions in the "Binary Code" text block.

Once a program is compiled (or entered directly in binary) it can be loaded from the Binary Code block into the computer Memory using the Load Program button.

Once a program is loaded into memory, it can be run with the "Run/Stop" button. The CPU shows the program counter ("P") and the state of the output light ("Q"). This computer can hold up to 256 instructions. The controls are explained here:

The normal programming process goes as follows:

  1. Write or modify the program in the "Source Code" block
  2. Compile the "Source Code" to "Binary Code" with the "Compile Program" button
  3. Load the "Binary Code" program into "Memory" with the "Load Program" button
  4. Run the program with the "Run/Stop" button or step through it with the "Step" button.

The process is iterative as each program is written and tested.


-- Sample Programs --


Simple Blinking Light:

This very simple program turns the light on and off over and over again. This program works well at almost any speed (instructions per second).

on off


Strobe Light:

This program simulates a strobe light that turns on the light once every 10 instructions. This program works well at either 4, 8, or 16 instructions per second.

off off off off off on off off off off


Morse Code for SOS (... --- ...):

The Morse Code for "S" is "..." (dot dot dot).
The Morse code for "O" is "---" (dash dash dash).
So "SOS" is "...---..." (dot dot dot dash dash dash dot dot dot).
There's a pause between letters of 3 "dots" and a longer pause between each word ("SOS" in this case) of 5 or 7 dots.
Note that this program runs well at a speed of 8 instructions per second.

on off on off on
off off off
on on on off on on on off on on on
off off off
on off on off on
off off off off off off off

For reference, the International Morse Code from Wikipedia states:

1. A dash is equal to three dots.
2. The space between parts of the same letter is equal to one dot.
3. The space between two letters is equal to three dots.
4. The space between two words is equal to seven dots.

A is dot dash
B is dash dot dot dot
C is dash dot dash dot
D is dash dot dot
E is dot
F is dot dot dash dot
G is dash dash dot
H is dot dot dot dot
I is dot dot
J is dot dash dash dash
K is dash dot dash
L is dot dash dot dot
M is dash dash
P is dash dot
O is dash dash dash
P is dot dash dash dot
Q is dash dash dot dash
R is dot dash dot
S is dot dot dot
T is dash
U is dot dot dash
V is dot dot dot dash
W is dot dash dash
X is dash dot dot dash
Y is dash dot dash dash
Z is dash dash dot dot

1 is dot dash dash dash dash
2 is dot dot dash dash dash
3 is dot dot dot dash dash
4 is dot dot dot dot dash
5 is dot dot dot dot dot
6 is dash dot dot dot dot
7 is dash dash dot dot dot
8 is dash dash dash dot dot
9 is dash dash dash dash dot
0 is dash dash dash dash dash