Minimal Computer



During the lecture computer architecture in the summer semester 2000 at the Free University Berlin, faculty of computer science, every participant had to implement a simulation of a part of the computer.

Go to simulation

On this site you see a simulation of a minimal computer. This minimal computer mainly consists of a ALU, accumulator (treated as a single register) and an addressed memory.

It accepts following five essential and two tool instructions:
  • inc
  • clear
  • brz <address>
  • load <address>
  • store <address>
Increments the value of the accumulator by one.
Sets the value of the accumulator to zero.
branch if zero Takes a branch to the specified address, if the value of the accumulator is zero.
Loads the value at the specified address in the accumulator.
Stores the value of the accumulator at the specified address in memory.
  • incx <number>
  • # <text>
Shortcut for <number> times inc (inc, ..., inc)
No instruction: comment. <text> should not contain '#'.

We implemented two applets:
Instruction of use:
  1. Enter any combination of macro and assembler code in the left editor pane.
  2. Enter any memory content in the memory table.
  3. Enter an accumulator value.
  4. Enter a program counter value.
  5. Start and control the simulation with the slider.
    The simulation will process all instruction until their end will be reached.
  6. To start a new simulation you will have to press the button to reset the minimal computer.

Hints:
Macros:
The left editor pane accepts besides direct minimal computer instructions predefined macro code.
The standard predefined macros:
  • dec
  • addi <targetaddress> <number>
  • copy <sourceaddress> <targetaddress>
  • add <targetaddress> <address0> <address1>
  • sub <targetaddress> <address0> <address1>
Decrements accumulator by one.
Adds <number> to the value located at the specifed address.
Copies the value of the source address to the target address.
Adds the values of address one and two and stores the result in the target address.

Substracts the value of address one from the value of address zero and stores the result in the target address.

To define custom macros you will have to set applet parameters like follows:


<param name="macro0" value="<macroname>'|'<macrodefinition>">
<param name="macro1" value="<macroname>'|'<macrodefinition>">
...
<param name="macron" value="<macroname>'|'<macrodefinition>">

'|' stands for the | character. You must not mix up it with the or in the BNF!

  • <macroname>
  • <macrodefinition>
Stands for any macroname that differs from the basic instructions and other entered macro names.
= <basicinstruction>{'|'<basicinstruction>}
Instead of specifying addresses you set the key $n for the n-th given parameter or $r<number> for an address +/-<number> relative to the last macro instruction, which will be replaced by the given parameter or address when compiling.

Examples:
<param name="macro0" value="addi|# addi|load $0|incx $1|store $0|clear|# end addi">

Defines a macro named addi with the syntax addi <address> <number> and the semantik:
load <address>
inc, inc, ...
(<number> times)
store <address>
clear

<param name="macro0" value="endless_loop|# an endless loop|clear|brz $r-1|# endless">

Defines a macro named endless_loop with the syntax endless_loop and the semantik:
clear
brz <previousAddress>

<previousAddress> stands for the address of the instruction brz <previousAddress> minus one, means the preceeding clear instruction.

Go to simulation


Suggestions, questions or comments? Please mail us!

Daniel Szer | Paul Hackenberger