Archives
Tags
- General (18)
- Food (1)
- Cooking (1)
- Ruby (6)
- Rails (2)
- Svn (2)
- Linux (9)
- Git (1)
- Firefox (8)
- Porn (1)
- Freyja (1)
- Witchhammer (6)
- Music (1)
- Merb (3)
- Poetry (0)
- Bolverk (3)
- Sinatra (1)
- Discogs (1)
- Centos (1)
- Python (1)
- Whinging (2)
- Travel (2)
- Scheme (7)
- Lisp (8)
- Sicp (1)
- Rot13 (1)
- Czech (2)
- Metal (3)
- Passenger (1)
- Fun (5)
- Fractals (2)
- Plt (2)
- Clojure (1)
- Continuations (1)
- Javascript (1)
- Presentation (1)
Programming Bolverk; a simple example
Since Bolverk has gone live, I've had a few friends mention to me that "[It] sounds like a cool idea, but I have no idea where to start". Because of this, I've decided a small example of how one might go about programming her is in order.
I will demonstrate how to read in two binary numbers, determine their sum, and then print that value to the standard output.
0: Write the machine instructions
Below is an example of how you could write the solution (along with notes in parentheses).
2143 (LOAD register 1 with the decimal value 67) 220D (LOAD register 2 with the decimal value 13) 5123 (ADD register 1 and register 2 and store the result in register 3) 33A1 (STORE the contents of register 3 into the memory cell A1) D1A1 (PRINT the contents of memory cell A1 as a decimal number -- 80) C000 (HALT the program)
1. Load the instructions into main memory.
Click the "Write / Load Program" link and wait for the thickbox dialog to load up. Once ready, copy the following into the textarea:
2143 220D 5123 33A1 D1A1 C000
The "Starting cell" select can be left as is. Now click "Insert". You will notice that the program has been loaded into main memory. The populated cells will appear purple.
Note, you can manually change any single memory cell by double clicking it, changing the hexadecimal value, and then clicking out of the cell.
2. Initialise the program.
Click on the first cell of your program. You will notice the "Initialize Program" button will be enabled. Click it.
You will notice that the first two cells of your program code will be highlighted. This, as the legend shows, is the next instruction the machine will execute.
3. Run the program.
This is the easy part. You simply have to click the "Machine Cycle" button for each machine instruction in your program. At each instruction, you will see how the processor is being affected.
Try it! By the time the program ends, you should have the decimal number "80" printed to Standard Output.