Register Binary         Octal Hex Dec 
PC        
IR        
MAR        
Value at PC (octal):  
PC disassembly:  
IR disassembly:  
Register Binary         Octal Hex Dec  Signed Dec
A          
B          
OUT          
Value at MAR (octal):  
Machine cycles elapsed:  
Instruction cycles elapsed:  
Memory page select:
Load to / export from:

Balaurul Unu

12-bit educational microcomputer, by Chris Musei-Sequeira

Balaurul Unu harkens back to the blinkenlightsy minicomputers and microcomputers of the 1970s, like the Altair 8800 and PDP-11. It features a simple instruction set inspired by the Intel 8080 and the Simple-As-Possible CPUs. Its 12-bit word length embraces octal numbers, providing 4 octal digits for all values.

SEE BALAURUL UNU ON GITHUB

BALAURUL UNU INSTRUCTION SET

Specifications

Quick start

  1. Click the CIRCUIT SPY switch to "ON". A register monitor will appear below Balaurul's front panel, while a memory monitor and import/export utility will appear to the right. Both monitors will be blank.
  2. Click the SPEED switch to "SLOW".
  3. Click the ON/OFF switch to "ON" (or press "q") to turn on Balaurul. Balaurul will turn on with random values in its registers and memory, shown in the monitors. If keyboard shortcuts are not working, click the mouse pointer on the blue faceplate of Balaurul and try again.
  4. Click the RUN/STOP switch to "RUN" (or press "w") to run Balaurul. Balaurul will perform actions based on the contents of its memory. If Balaurul halts, you can direct Balaurul to continue by moving the RUN/STOP switch to "STOP" and then back to "RUN".
  5. While leaving the RUN/STOP switch in the "RUN" position, toggle the ON/OFF switch to "OFF" and then to "ON" again. Balaurul will turn on with new random values in its registers and memory and immediately begin performing actions.
  6. To quickly show the PC or MAR in the memory monitor, click the "PC" or "MAR" labels, respectively, at the bottom left of the circuit spy.
  7. Perform Step 5 several more times while observing Balaurul's behavior on the front panel and the two circuit spy monitors.

Exploring the control and input switches

  1. Turn on Balaurul and set the RUN/STOP switch to the "STOP" position.
  2. Notice that the 2-line display in the lower "OUT" section is colored red. This indicates keyboard shortcut mode, where pressing the keyboard character shown on the front panel for a control will activate that control.
  3. Click the mouse on the 2-line display in the lower "OUT" section. Notice that the color changes from red to light blue. This indicates keyboard input mode, where keyboard presses will allow keyboard characters to be read using Balaurul's "KEY" instruction.
  4. To switch between keyboard shortcut mode and keyboard input mode, click the display.
  5. On the front panel, click "STEP M" (or press "r") to step Balaurul by individual machine cycles, or click "STEP I" (or press "t") to step Balaurul by individual instructions. Observe Balaurul's behavior on the front panel and the monitors.
  6. Click "RESET" (or press "e") to set Balaurul's program counter (PC) to zero, clear the CARRY and ZERO flags, clear the two-line display, and set the next machine cycle to "FETCH". Note that all other values remain unchanged.
  7. Make sure that all yellow input switches are in the "down" position, representing the octal number 0000. To instantly bring ALL yellow input switches to the "down" position, press "`" (backtick) on your keyboard.
  8. Click "EXAMINE" (or press "y"). The contents of memory address 0000 will be displayed on the OUT register of Balaurul's front panel, in octal.
  9. Click "EXAMINE NEXT" (or press "u"). Balaurul's PC will increment by one word (to address 0001) and display the contents of that memory location on the OUT register.
  10. Set the yellow input switches to show octal 0040 (binary 000 000 100 000, where only switch number 7 is in the "up" position).
  11. Perform "EXAMINE". Balaurul's PC will move to address 0040 and display the contents.
  12. Set the yellow input switches to show octal 7000 (binary 111 000 000 000). Click "DEPOSIT" (or press "i"). Balaurul will deposit the value 7000 at address 0040 and display the value on the OUT register.
  13. Click "DEPOSIT NEXT" (or press "o"). Balaurul will increment the PC by one word (to 0041), deposit the value 7000 at that memory location, and display the value on the OUT register.
  14. Open the circuit spy, enter the number 0 in the "Load to / export from" box, and click "EXPORT FROM RAM". All words of memory will be displayed as octal values in the text box, where they can be copied, modified, and re-imported to memory.

Entering your first program

Your first program will add the numbers 3 and 4 together and display the result on the OUT register. The assembly language source code is as follows, per the Balaurul Unu instruction set:

ORIGIN 0000     ; Code assumes that first word is at 0000
    
LDI 0003        ; Load the value 3 into the accumulator
ADI 0004        ; Add immediate value 4 to accumulator
OUT             ; Display accumulator on OUT register
HLT             ; Halt

The source code assembled into octal machine code is as follows:

0020 0003       ; At 0000: Load the value 3 into the accumulator
0021 0004       ; At 0002: Add immediate value 4 to accumulator
0002            ; At 0004: Display accumulator on OUT register
0001            ; At 0005: Halt

Or as a single block:

0020 0003 0021 0004 0002 0001

To enter the program using the circuit spy, do the following:

  1. Make sure Balaurul is on and in the "STOP" setting.
  2. Open the circuit spy.
  3. Copy the single block of machine code (above) and paste it into the text box within the memory monitor panel.
  4. Type the number 0 into the "Load to / export from" box.
  5. Click the "IMPORT TO RAM" button. Balaurul will import the text box contents into memory, starting at memory location 0000. The memory monitor will then show the imported values.

Now reset Balaurul, then run Balaurul. Balaurul should display 0007 (in binary) on the OUT register and halt. If this does not happen, verify the contents of the text box within the memory monitor and re-import. Be sure to reset Balaurul before running.

Now try entering the program using only the front panel switches. Turn Balaurul off, then on again to set its registers and memory to random values. Then follow the guidance in "Exploring the control and input switches" to enter the machine code. Then reset and run Balaurul.

A simple keyboard monitor

The following program will echo pressed keyboard characters to the output display when Balaurul is in keyboard input mode (see "Exploring the control and input switches"). See the "KEY" instruction in the Balaurul instruction set for supported keys.

ORIGIN 0000     ; Code assumes first word at 0000
    
KEY             ; Scan for pressed key; read into accumulator
OUT             ; Display accumulator on OUT register
JMP 0000        ; Jump to beginning

The source code assembled into octal machine code is as follows:

0004            ; At 0000: Scan for pressed key; read into accumulator
0002            ; At 0001: Display accumulator on OUT register
0060 0000       ; At 0002: Jump to 0000

Or as a single block:

0004 0002 0060 0000

Sample programs