Beware: This is a work in progress as of 2016-03-29 . Expect things not to operate correctly, or maybe not to operate at all. If you have suggestions, I'd like to hear about them. Please post comments on the discussion page.

Welcome to TLC!

TLC is the "Tiny Little Computer." It was inspired by the Little Man Computer, devised by Dr. Stuart E. Madnick of MIT. TLC uses the same instructions as the Little Man Computer, so programs written for LMC can be assembled and run on TLC with only very minor changes. Image of the TLC datapath for decoration only.

However, the Tiny Little Computer is different from the Little Man Computer in a number of important ways. Perhaps the most important is that TLC, like all modern computers, is a binary computer, not a decimal computer. The memory in TLC is organized into 12 bit words, with numbers stored as two's complement integers. That means TLC can store values from -2048 to +2047.

Another very visible difference is that there's no "little man." The instruction decoder (I-Decoder) and control unit perform the functions of the little man. The little man could remember memory addresses and their contents, and whether the calculator held a zero or positive number. In TLC, the memory address register (MAR), memory data register (MDR), and P/Z latch perform these functions. Instead of having the little man remember the current instruction, TLC stores it in the instruction register (IR).

Ready to Go?

TLC can save programs in your browser's local storage. If you're ready to try things out, here's a sample program. It's the "positive difference" program used in many LMC examples. Like a real computer, TLC cannot process human-readable programs directly. They have to be translated by the assembler program into binary. To try out the sample program:

  1. Click the "Save" button just below the program; the sample program will be saved in your browser's local storage as "posdiff."
  2. Switch to the "Assembler" tab, use the drop-down menu to select the "posdiff" program and assemble it by clicking the "assemble" button.
  3. If all is well, the binary translation of the program will be saved, also as "posdiff" but tagged as a binary object program.
  4. Switch to the "Virtual Machine" tab, select "posdiff" and click "Load." The program is loaded into memory and the program counter is set to zero. Although the program is binary, it is shown as hexadecimal in the virtual machine for compactness.
  5. Click "Run" and the program executes. As with many real computers, each instruction takes more than one clock cycle. Provide an integer value at each of the two "Input?" prompts.
// Positive Difference Program
// Reads two numbers and subtracts them.  If the
// difference is positive, it is printed.  Otherwise,
// the numbers are swapped and subtracted again, then printed.
// You can think of the Accumulator as the display of a
// very small calculator.
//
       in            read first number into Accumulator
       sto first     store it in memory with name "first"
       in            read second number
       sto second    store it as "second"
// The second number is stored, but also remains in Accumulator
       sub first     subtract "first" from Accumulator
       brp print     positive? print it (brp=branch on positive)
       lda first     otherwise, load Accumulator with "first"
       sub second    ... and subtract "second"
print  out           send to output
       hlt           and stop (hlt=halt)
first  dat 0x00      initializes "first" to zero...
second dat           // initialization isn't really necessary
                     // because we will store a value here.
  

Register and memory contents: While a program is running on the virtual machine, you can place the mouse cursor over a register or memory cell to see the values in binary or decimal and, how the cell would be interpreted as an instruction. It takes about a second for the tool-tip to appear.

Breakpoints: Clicking in a memory cell will set a breakpoint at that location. When it is about to be loaded, the clock will stop so that you can inspect the contents of memory and registers. Click "Run" or "Step" to continue. Step executes one instruction and stops again.

Saving the output: Click the "select all" icon on the lower right of the output screen, or click in the output screen and press control-A. Press control-C to copy the selected text to the clipboard.

Writing Your Own Programs

You can edit programs directly in the source window of the assembler panel, but you might find it easier to create programs in an editor application like Notepad++ and paste the source in the assembler window. You do need to save the source using the "Save as" because that's how the assembler knows what to name the translated binary program, also called the object program.

Because a browser's local storage is isolated from the rest of a computer's file system for security, the only way to get a source program back out of TLC is to copy it from the source window of the assembler and paste it into an editor program.

The operation codes (op codes) for TLC and their semantics are the same as those for the Little Man Computer, so any program written for LMC will work on TLC, too. The only difference is that, for TLC, there must be at least one space or tab before the operation code. Labels must begin at the left, with no preceding spaces or tabs. The details are in the documentation. The TLC assembler will try to reformat programs with the op codes at the left margin, but some manual corrections may still be necessary.

Browser Support

TLC makes extensive use of the features of HTML5 and CSS3. It won't work in older browsers, and will probably fail badly and in unexpected ways. TLC has been tested pretty thoroughly in Firefox 30 and somewhat less thoroughly in Chrome 35 and Internet Explorer 11. It ought to work in other modern browsers; if you have trouble, try Firefox or Chrome.

You can run TLC on a tablet computer, but both the assembler and the virtual machine need lots of horizontal space. Using a desktop computer will probably be better.