Skip to content

Commit ea8d19b

Browse files
authored
Update README.md
1 parent 563c32a commit ea8d19b

File tree

1 file changed

+17
-78
lines changed

1 file changed

+17
-78
lines changed

README.md

+17-78
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,35 @@
11
# TurnaCore
2-
TurnaCore is an imaginary 8-bit CPU with a custom architecture, created mainly for creating low-level programming challenges. [Read more about the architecture here](https://github.com/arda-guler/TurnaCore/blob/master/docs/CPU_architecture.txt) or below.
32

4-
The AO language is a custom assembly language to write programs for TurnaCore machines. [Read more about it here](https://github.com/arda-guler/TurnaCore/blob/master/docs/AO_language.txt) or below.
5-
6-
## TurnaCore CPU Architecture
7-
8-
![CPU](https://github.com/arda-guler/TurnaCore/assets/80536083/8d1ba771-0a63-435f-9b72-fa8eb8f3ddaa)
9-
10-
TurnaCore is under development. The following information is valid for the current version.
11-
12-
The TurnaCore CPU has 5 registers, numbered 1, 2, 3, 4 and 5. Each register can hold a number between 00000000 and 11111111. (These values correspond to 0 and 255 in decimal.)
13-
14-
The TurnaCore CPU can execute programs on the memory, but it can not write to the memory.
3+
![Multiplication](https://github.com/arda-guler/TurnaCore/assets/80536083/bfe4d51a-ab84-478c-afe1-7f4115404b06)
154

16-
Register 1 and 2 are general registers that can be directly written on. Addition and subtraction operations act on Register 1.
5+
*A TurnaCore machine multiplying 13 and 27.*
176

18-
Register 3 is the operation mode register. It tells the CPU what to do with the upcoming numerical value to be read.
7+
TurnaCore is an imaginary 16-bit CPU with a custom architecture, created mainly for creating low-level programming challenges. [Read more about the architecture here](https://github.com/arda-guler/TurnaCore/blob/master/docs/CPU_architecture.txt) or below.
198

20-
Register 4 is the address register. It keeps track of the address from which the instructions/data are being read. It increments automatically and keeps reading the loaded program from first instruction to the last, unless a jump command is executed. A jump command allows the value of Register 4 to be controlled directly, which makes loops, if-else conditionals and goto instructions possible.
21-
22-
Register 5 acts as a short term memory register. The value of Register 1 can be copied into Register 5, so that the value stored in Register 5 can be copied into Register 1.
23-
24-
## AO Programming Language
25-
26-
The AO (ASM Operands) language is a very low-level assembly language designed for TurnaCore machines.
27-
It matches 1-to-1 to the equivalent compiled binary machine code. Actually, the only thing it makes is to
28-
convert the "human-readable" TurnaCore instructions into corresponding binary values, which are "CPU-readable".
9+
The AO language is a custom assembly language to write programs for TurnaCore machines. [Read more about it here](https://github.com/arda-guler/TurnaCore/blob/master/docs/AO_language.txt) or below.
2910

30-
A program written in AO programming language is a combination of "instructions" and "data". All "instructions"
31-
and "data" are mere numbers, but the TurnaCore CPU architecture acknowledges certain numbers as built-in
32-
instructions to execute.
11+
## Use
3312

34-
In AO programming language, each "expression" (either an instruction or data) is separated by spaces and
35-
newline characters.
13+
**Run src/main.py** to start the TurnaCore machine. A TurnaCore machine can load one program into memory at a time (unless you write two programs back to back on the same source code file).
3614

37-
The following is an example AO program:
15+
Running simply as:
3816
```
39-
MR1
40-
1
41-
MR2
42-
5
17+
main.py
4318
```
19+
powers up a TurnaCore machine. The emulator will then scan the /programs folder and ask you to pick a program to run. Then, it will as you whether you want to run the program in *slow mode* (explained below) or not.
4420

45-
In this program, MR1 and MR2 are instructions whereas 1 and 5 are data. MR1 tells the CPU to switch to Modify
46-
Register 1 mode, and the following data 1 is then used to modify the value of Register 1. Then, the CPU is
47-
switched to Modify Register 2 mode using the MR2 instruction. The last line is the data which is used to
48-
modify the value of Register 2. When this program is executed, Register 1 should hold the value 1 and Register 2
49-
should hold the value 5.
50-
51-
The same program can be written as follows for better readability:
21+
Running via:
5222
```
53-
MR1 1
54-
MR2 5
23+
main.py <filename>
5524
```
25+
powers up a TurnaCore machine and loads up a program into memory. The emulator starts in *slow mode* (explained below) by default.
5626

57-
Do not forget that this is not a function - argument arrangement. 1 is not an argument for the MR1 insturction.
58-
They are merely two expressions that come after each other.
59-
60-
You can use the semicolon (;) as the first character in a line to denote a comment line.
61-
62-
Adding comments to the example program above can be done as follows:
27+
Running via:
6328
```
64-
; This program sets the value of Register 1 to 1 and Register 2 to 5.
65-
; Let's set Register 1 first.
66-
MR1 1
67-
; Let's set Register 2 next.
68-
MR2 5
69-
; Voila!
29+
main.py <filename> <slow_mode(Y/n)>
7030
```
31+
allows you to pick whether you want to start in *slow mode* (explained below) or not.
7132

72-
AO files are compiled into CIS (compiled instruction sequence) files. These are the files which the CPU reads.
73-
74-
See TurnaCore Instruction Set for a list of all instructions.
75-
76-
## TurnaCore Instruction Set
77-
78-
**ADD**: Adds value in Register 2 onto Register 1
79-
80-
**SUB**: Subtracts value in Register 2 from Register 1
81-
82-
**MR1**: Switches CPU mode to "Modify Register 1"
83-
84-
**MR2**: Switches CPU mode to "Modify Register 2"
85-
86-
**JMP**: Switches CPU mode to "Jump"
87-
88-
**JG**: Switches CPU mode to "Jump" if Register 1 is greater than Register 2; else, switches to a dummy CPU mode
89-
90-
**JL**: Switches CPU mode to "Jump" if Register 1 is less than Register 2; else, switches to a dummy CPU mode
91-
92-
**JE**: Switches CPU mode to "Jump" if Register 1 is equal to Register 2; else, switches to a dummy CPU mode
93-
94-
**WRITE**: Copies Register 1 value to Register 5
33+
## What is this 'Slow Mode' anyway?
9534

96-
**RECALL**: Copies Register 5 value to Register 1
35+
Slow mode has a Tkinter GUI for easily keeping track of what the machine is doing. The machine takes quite a lot longer to execute each instruction so that your eyes can keep up with the numbers. Good for debugging and education, not good for running extremely large programs just for the result. If slow mode is not enabled, instructions are carried out as fast as possible, with no GUI output (just the command line printouts at the end of the program).

0 commit comments

Comments
 (0)