Hallo, schön dass du dir diese Seite anschaust.
Damit du besser verstehst, wie diese Anwendung funktioniert, hier einmal die Basics:
Ganz oben findest du eine Reihe mit Kontrollknöpfen. Jeder Knopf hat seine eigene Funktion.
Der Computer ist in mehrere Bausteine aufgeteilt. Jeder Baustein hat eine eigene spezielle Funktion. Ein echter Computer ist natürlich deutlich komplizierter, aber so ist der PC deutlich verständlicher.
Im Arbeitsspeicher wird das Programm gespeichert. Jeder Eintrag ist dabei in ein Low-Byte und ein High-Byte unterteilt. Dadurch kann man in einem Eintrag die Instruktion und Adresse einfacher unterscheiden.
Siehe Befehle
Wie der Name es schon sagt, steuert und verwaltet die Control Unit alle Vorgänge im Computer. Das passiert dadurch, dass eine Instruktion in viele kleine µCodes aufgeteilt wird.
Diese µCodes sind in der Tabelle aufgeführt. Jede Instruktion besteht hier aus bis zu 10 µCodes.
Bei einem Befehl z.B. 001 00000
ist die Instruktion in den ersten drei Stellen zu finden. Dieser Wert wird dann mit 10 multipliziert und in den µCode Counter geladen.
In diesem Fall stände dann 0010
im Counter.
In der Tabelle sind dann alle Befehle für die Instruktion 001
zu finden.
Die Arithmetik Logic Unit ist hier sehr einfach aufgebaut.
Sie kann den Akkumulator nur erhöhen oder erniedrigen. Dafür können Werte aber direkt vom Datenbus geladen werden.
Über den Datenbus können Daten und Befehle zwischen RAM, Control Unit und ALU übertragen werden.
Über diesen Bus kann die Control Unit steuern, welcher Wert im RAM ausgewählt wird.
Bei normalen Rechnern sind hier natürlich noch deutlich mehr Werte angeschlossen.
Ein Befehl besteht aus einer Instruktion und einem Argument. Deshalb sind im RAM und im Instruction Register alle Werte separiert.
0 0 2 0 0 5 0 4
Instr Argument
In den ersten 3 Stellen wird hier der OpCode der Instruction codiert. Wenn dieser Teil in der Control Unit in den µCode Counter geladen wird, dann wird der OpCode mit 10 multipliziert.
In den letzten 5 Stellen wird ein beliebiger Zahlenwert gespeichert. Dieser kann als Argument für einen Befehl genutzt werden.
In diesem Beispiel hier würden die µCodes ab Adresse 20 im µCode Speicher ausgeführt werden.
Eine Instruktion kann nicht direkt ausgeführt werden. Deshalb wird sie durch mehrere kleine Befehle, sog. µCodes zusammengesetzt.
µCode | Beschreibung |
---|---|
ProgCounter -> AddrBus |
Lade den Wert des Programm Counters in den Adressbus |
InstrReg -> ProgCounter |
Lade das Argument des Instruktionsregisters in den Programm Counter |
ProgCounter ++ |
Erhöhe den Wert des Programm Counter um 1 |
Acc == 0 => InstReg -> ProgCounter |
Wenn der Wert des Akkumulators 0 ist, dann lade das Argument des Instruktionsregisters in den Programm Counter |
Ram -> DataBus |
Schreibe den aktuellen Wert aus den RAM auf den Datenbus |
DataBus -> Ram |
Schreibe den Wert des Datenbus in die momentane Stelle des RAM |
DataBus -> InstReg |
Lade den Befehl vom Datenbus in das Instruktionsregister |
DataBus -> Acc |
Lade den Wert vom Datenbus in den Akkumulator der ALU |
Acc -> DataBus |
Schreibe den Wert vom Akkumulator auf den Datenbus |
Acc ++ |
Erhöhe den Wert des Akkumulators um 1 |
Acc -- |
Verringere den Wert des Akkumulators um 1 |
Acc << DataBus |
Verschiebt den Wert im Akkumulator nach links um den Wert im DatenBus. |
Acc >> DataBus |
Verschiebt den Wert im Akkumulator nach rechts um den Wert im DatenBus. |
Acc + DataBus |
Addiere den Wert im Datenbus auf den Akkumulator |
Acc - DataBus |
Subtrahiere den Wert im Datenbus auf den Akkumulator |
Acc * DataBus |
Multipliziere den Wert im Datenbus mit dem Akkumulator |
Acc / DataBus |
Dividiere den Akkumulator durch den Datenbus |
Acc AND DataBus |
Führe bitweise UND auf Akkumulator mit Datenbus aus |
Acc OR DataBus |
Führe bitweise ODER auf Akkumulator mit Datenbus aus |
Acc XOR DataBus |
Führe bitweise XOR auf Akkumulator mit Datenbus aus |
Acc NOT DataBus |
Führe bitweise NOT auf Akkumulator mit Datenbus aus |
InstReg -> µCounter |
Nehme das Argument des Befehls im Instruktionsregister, füge am Ende eine 0 an und Lade ihn in den µCounter |
InstReg -> AddrBus |
Lade das Argument im Instruktionsregister in den Adressbus |
InstReg -> DataBus |
Lade das Argument im Instruktionsregister in den Adressbus |
µCounter = 0 |
Setzte den µCounter zurück |
Signal End of Program |
Zeigt ein Popup, dass das Ende des Programms signalisiert. |
Das hier ist ein kleines Hobbyprojekt. Meine Implementation ist also nur mit Vorsicht als "best-practice" Vorlage zu verwenden.
Zum Source CodeDieses Projekt ist angelehnt an den Johnny-Simulator.
Hello. In order for you to understand what this App does, I want to show you some basics of this app.
At the top of the application you can see a row of control buttons:
This computer is made up by multiple blocks like any other neumann-maschiene. Every block has it's own unique set of functions. A normal computer is much more complex than this, but the principle is the same.
The current program is stored in the RAM. Every entry is separated as mentioned in entry.
As the name suggests, the control unit manages everything that is done. To know what needs to be done it has a list of µCodes that gets executed when a instruction is requested.
These µCodes can be found in the table. Every instruction consists of up to 10 µCodes.
When a entry is executed, the first three digits (the instruction) gets multiplied by 10. This now is written into the µCounter and the µCodes for it get's executed.
Example:
When the entry 001 00000
gets executed, the µCounter would be set to 0010
. Now every µCode starting at location 0010
in the µCodes gets executed.
The Arithmetic Logic Unit is pretty simple in this case.
The ALU can only increment or decrement the accumulator. But it can read numbers from databus.
Via the databus values and entries can be transported between RAM, Control Unit and ALU.
With the addressbus the Control Unit can control which value is selected in RAM. On a normal computer there are a lot more things attached to this bus.
Each entry consists of a instruction and an argument. That's why the entrys in RAM and in µCodes are displayed separately.
0 0 2 0 0 5 0 4
Instr Argument
Here, the first 3 digits are the opCode of the instruction. When you try to load this part into the µCode Counter of the Control Unit, it will be automatically multiplied by 10.
In this example µCodes starting at the Address 20 will be executed.
The last 5 digits are a numerical value that can be used as an argument for the command.
Every instruction consists of a list of µCodes. Here is an explanation for all of them:
µCode | Description |
---|---|
ProgCounter -> AddrBus |
Load the value from program counter to addressbus |
InstrReg -> ProgCounter |
Load the argument from instruction register to program counter |
ProgCounter ++ |
Increment program counter by 1 |
Acc == 0 => InstReg -> ProgCounter |
If the accumulator is 0 then write the argument from instruction register to program counter |
Ram -> DataBus |
Load selected value from RAM to databus |
DataBus -> Ram |
Write value from databus to selected value in RAM |
DataBus -> InstReg |
Write entry from databus to instruction register |
DataBus -> Acc |
Write value from databus to accumulator |
Acc -> DataBus |
Load value from accumulator to databus |
Acc ++ |
Increment accumulator by 1 |
Acc -- |
Decrement accumulator by 1 |
Acc << DataBus |
Shift the Accumulator left by the value in databus |
Acc >> DataBus |
Shift the Accumulator right by the value in databus |
Acc + DataBus |
Add the value of the databus to the accumulator |
Acc - DataBus |
Subtract the value of the databus from the accumulator |
Acc * DataBus |
Multiply the value of the databus with the accumulator |
Acc / DataBus |
Divide the accumulator by the value of the databus |
Acc AND DataBus |
Do a bitwise AND to accumulator with the value of the databus |
Acc OR DataBus |
Do a bitwise OR to accumulator with the value of the databus |
Acc XOR DataBus |
Do a bitwise XOR to accumulator with the value of the databus |
Acc NOT DataBus |
Do a bitwise NOT to accumulator with the value of the databus |
InstReg -> µCounter |
Take the instruction from instruction register, add a 0 at the tail and write it to µCounter |
InstReg -> AddrBus |
Write the argument from instruction register to addressbus |
InstReg -> DataBus |
Write the argument from instruction register to databus |
µCounter = 0 |
Set µCounter to 0 |
Signal End of Program |
Show an alert that the end of program is reached. |
This is a hobby project so please don't take my code as a "best-practice" implementation.
This project is my take on Johnny-Simulator.