Skip to content

Commit a678a95

Browse files
committed
???
1 parent cc328ab commit a678a95

23 files changed

+2023
-0
lines changed

docs/ASCII-Table.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# ASCII Table
2+
3+
## Notes
4+
5+
* **ASCII control characters (character code 0–31)** The first 32 characters in the `ASCII-table` are unprintable
6+
control codes and are
7+
used to
8+
control peripherals such as printers
9+
* **ASCII printable characters (character code 32–127)** Codes 32–127 are common for all the different variations of the
10+
ASCII table, they are called printable characters, represent letters, digits, punctuation marks, and a few
11+
miscellaneous symbols. You will find almost every character on your keyboard. Character 127 represents the command
12+
DEL.
13+
14+
| Index of Character | Symbol Of Character | Description |
15+
|--------------------|---------------------|------------------------------------------|
16+
| 0 || Null character |
17+
| 1 |  | Start of heading |
18+
| 2 |  | Start of text |
19+
| 3 |  | end of text |
20+
| 4 |  | end of transmission |
21+
| 5 |  | enquiry |
22+
| 6 |  | acknowledge |
23+
| 7 |  | bell/alert |
24+
| 8 |  | backspace |
25+
| 9 | | Horizontal tab |
26+
| 10 | | new line |
27+
| 11 | | vertical tabulation |
28+
| 12 | | form feed |
29+
| 13 | | carriage return |
30+
| 14 |  | shift out |
31+
| 15 |  | shift in |
32+
| 16 |  | data link escape |
33+
| 17 |  | device control one (XON) |
34+
| 18 |  | device control two |
35+
| 19 |  | device control three (XOFF) |
36+
| 20 |  | device control four |
37+
| 21 |  | negative acknowledge |
38+
| 22 |  | synchronous idle |
39+
| 23 |  | end of transmission block |
40+
| 24 |  | cancel |
41+
| 25 |  | end of medium |
42+
| 26 |  | substitute |
43+
| 27 |  | escape |
44+
| 28 |  | file separator |
45+
| 29 |  | group separator |
46+
| 30 |  | record separator |
47+
| 31 |  | unit separator |
48+
| 32 | | space |
49+
| 33 | ! | exclamation mark |
50+
| 34 | " | double quotes |
51+
| 35 | # | pound sign |
52+
| 36 | $ | dollar sign |
53+
| 37 | % | percent sign |
54+
| 38 | & | ampersand |
55+
| 39 | ' | single quote |
56+
| 40 | ( | open bracket |
57+
| 41 | ) | close bracket |
58+
| 42 | * | star / asterisk |
59+
| 43 | + | plus |
60+
| 44 | , | comma |
61+
| 45 | - | hyphen / minus |
62+
| 46 | . | full stop / dot / period |
63+
| 47 | / | slash / divide |
64+
| 48 | 0 | zero |
65+
| 49 | 1 | one |
66+
| 50 | 2 | two |
67+
| 51 | 3 | three |
68+
| 52 | 4 | four |
69+
| 53 | 5 | five |
70+
| 54 | 6 | six |
71+
| 55 | 7 | seven |
72+
| 56 | 8 | eight |
73+
| 57 | 9 | nine |
74+
| 58 | : | colon |
75+
| 59 | ; | semi colon |
76+
| 60 | < | less than / open angle bracket |
77+
| 61 | = | equals |
78+
| 62 | \> | greater than / closed angle bracket |
79+
| 63 | ? | question mark |
80+
| 64 | @ | at sign |
81+
| 65 | A | uppercase A |
82+
| 66 | B | uppercase B |
83+
| 67 | C | uppercase C |
84+
| 68 | D | uppercase D |
85+
| 69 | E | uppercase E |
86+
| 70 | F | uppercase F |
87+
| 71 | G | uppercase G |
88+
| 72 | H | uppercase H |
89+
| 73 | I | uppercase I |
90+
| 74 | J | uppercase J |
91+
| 75 | K | uppercase K |
92+
| 76 | L | uppercase L |
93+
| 77 | M | uppercase M |
94+
| 78 | N | uppercase N |
95+
| 79 | O | uppercase O |
96+
| 80 | P | uppercase P |
97+
| 81 | Q | uppercase Q |
98+
| 82 | R | uppercase R |
99+
| 83 | S | uppercase S |
100+
| 84 | T | uppercase T |
101+
| 85 | U | uppercase U |
102+
| 86 | V | uppercase V |
103+
| 87 | W | uppercase W |
104+
| 88 | X | uppercase X |
105+
| 89 | Y | uppercase Y |
106+
| 90 | Z | uppercase Z |
107+
| 91 | \[ | opening square bracket |
108+
| 92 | \\ | backslash |
109+
| 93 | ] | closing square bracket |
110+
| 94 | ^ | caret |
111+
| 95 | _ | underscore |
112+
| 96 | ` | grave accent |
113+
| 97 | a | lowercase a |
114+
| 98 | b | lowercase b |
115+
| 99 | c | lowercase c |
116+
| 100 | d | lowercase d |
117+
| 101 | e | lowercase e |
118+
| 102 | f | lowercase f |
119+
| 103 | g | lowercase g |
120+
| 104 | h | lowercase h |
121+
| 105 | i | lowercase i |
122+
| 106 | j | lowercase j |
123+
| 107 | k | lowercase k |
124+
| 108 | l | lowercase l |
125+
| 109 | m | lowercase m |
126+
| 110 | n | lowercase n |
127+
| 111 | o | lowercase o |
128+
| 112 | p | lowercase p |
129+
| 113 | q | lowercase q |
130+
| 114 | r | lowercase r |
131+
| 115 | s | lowercase s |
132+
| 116 | t | lowercase t |
133+
| 117 | u | lowercase u |
134+
| 118 | v | lowercase v |
135+
| 119 | w | lowercase w |
136+
| 120 | x | lowercase x |
137+
| 121 | y | lowercase y |
138+
| 122 | z | lowercase z |
139+
| 123 | { | opening curly brace |
140+
| 124 | \| | pipe / vertical bar |
141+
| 125 | } | closing curly brace |
142+
| 126 | ~ | Equivalency sign / tilde |
143+
| 127 |  | delete |
144+
145+
146+
147+

docs/Architecture-Overview.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# MVM Kernel Overview
2+
3+
The MVM (Micro Virtual Machine) kernel is a time-sharing kernel designed for educational purposes.
4+
It manages multiple processes concurrently within the VM's emulated environment.
5+
The kernel is implemented in Kotlin and runs separately from the VM's user-space processes;
6+
user programs interact with the kernel via system calls.
7+
The kernel itself does not reside in the VM's emulated memory.
8+
9+
## Key Kernel Components
10+
11+
The MVM kernel comprises the following key components:
12+
13+
### Scheduler
14+
15+
The scheduler manages the execution of processes,
16+
allocating a single instruction cycle to each process before switching.
17+
The MVM kernel uses a round-robin scheduler.
18+
The scheduler maintains a ready queue of processes waiting for execution.
19+
The scheduler is invoked after each instruction completes execution.
20+
21+
### Process Manager
22+
23+
This component is responsible for creating, managing, and terminating processes. Key data structures include:
24+
25+
- **Process Control Block (PCB):** Represented by the `KProcess`(Kernel Active Process) class, this data structure
26+
stores information about each process (PID, registers, memory, state, etc.).
27+
- **System Calls:** The kernel provides system calls for process creation (`fork`, `spawn`), termination (`exit`), and
28+
other process-related operations.
29+
30+
### Snap Shot Manager
31+
32+
The snapshot manager keeps track of the state of each process at any given time during execution.
33+
When the kernel switches between processes, it snapshots the state the active process and saved it in memory.
34+
This includes
35+
36+
* Registers
37+
* Memory
38+
* Pc
39+
40+
### Virtual File System (VFS)
41+
42+
The VFS driver manages file system operations within the VM
43+
and is responsible for implementing a set of system calls for file operations.
44+
The VFS is persistent, saving and loading data from the `vfs.fs` file.
45+
46+
### Virtual Devices
47+
48+
The kernel includes drivers for virtual devices:
49+
50+
- **Console I/O:** Provides system calls for console input (`readIo`) and output (`writeIo`).
51+
- **Timer:** The timer is not emulated as a virtual device.
52+
Instead, the scheduler is driven by a counter that
53+
increments after each instruction cycle.
54+
This is private to the VM itself
55+
56+
### Inter-Process Communication (IPC)
57+
58+
The kernel manages IPC between processes using message passing mailboxes.
59+
60+
### System Call Handler
61+
62+
This component intercepts system calls from user-space programs, dispatching them to the appropriate kernel functions.
63+
64+
## Execution Model
65+
66+
The MVM uses a round-robin scheduling model.
67+
Each process receives a single instruction before the scheduler switches to another process.
68+
Processes do not block on system calls; they execute one instruction at a time.
69+
This design prioritises reliability and simplicity when handling many concurrent processes.
70+
71+
This document gives a high-level overview of the MVM kernel.
72+
For details on specific components and their functions, consult other sections of this wiki.

docs/Assembly-Intro.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Introduction to MVM Assembly Language
2+
3+
This page provides a gentle introduction to the MVM (Micro Virtual Machine) assembly language. MVM assembly is a
4+
low-level language designed for a simple, time-sharing virtual machine. It allows you to write programs by providing a
5+
set of instructions that manipulate data stored in registers and memory. The virtual machine manages multiple processes
6+
concurrently.
7+
8+
## Basic Concepts
9+
10+
* **Registers:** The MVM uses several types of registers:
11+
* **General Purpose Registers (G1-G10):** Used for general computations and data storage.
12+
* **System Registers (S1-S4):** Used for passing arguments to system calls. `S1` holds the system call ID.
13+
* **Return Registers (R1-R10):** Used to store the results of operations and system calls.
14+
* **Function Argument Registers (F1-F10):** Used for passing arguments to functions.
15+
* **Floating-Point Registers (X1-X10):** Used for floating-point arithmetic.
16+
* **Intel Registers (I1-I10):** Hold status flags and other information.
17+
* **Memory:** The MVM has a fixed amount of memory, accessed using addresses. Each address holds a 64-bit integer.
18+
* **Stack:** A last-in, first-out (LIFO) data structure for temporary storage. Used for function calls return values.
19+
* **Instructions:** Instructions specify operations. Each instruction has a mnemonic (e.g., `ADD`, `MOV`) and
20+
arguments (operands).
21+
* **System Calls:** Functions to interact with the operating system (OS plus Kernel), such as file I/O, process
22+
management, and more. These are invoked using the `SYSCALL` instruction, which takes the system call ID as an
23+
argument.
24+
25+
## Example Program
26+
27+
This simple program adds two numbers and prints the result:
28+
29+
```assembly
30+
LIT G1 10 // Load 10 into G1
31+
LIT G2 5 // Load 5 into G2
32+
ADD G1 G2 R1 // Add G1 and G2; result in R4
33+
PRINTR R1 // Print the value in R4 (15)
34+
```
35+
36+
## Key Instruction Categories
37+
38+
* **Data Transfer:** `LIT`, `XLIT`, `MOV`, `STORE`, `LOAD`, `PUSH`, `POP`, `PEEK`, `CPY`, `SETTYPE`, `DEALLOC`
39+
* **Arithmetic:** `ADD`, `SUB`, `MUL`, `DIV`, `MOD`, `POW`,
40+
* **Bitwise:** `AND`, `OR`, `XOR`, `NOT`, `SHL`, `SHR`
41+
* **XFloats:** `XADD`, `XSUB`, `XMUL`, `XDIV`, `XMOD`, `XPOW`, `ITOF`, `FTOI`
42+
* **Control Flow:** `JMP`, `JZ`, `JNZ`, `CALL`, `RET`
43+
* **String:** `STR`
44+
* **I/O:** `PRINTS`, `PRINTR`
45+
* **System Calls:** `SYSCALL`
46+
* **Miscellaneous:** `INR`, `HELP`, `SLEEP`
47+
48+
## Further Learning
49+
50+
For detailed information, refer to:
51+
52+
* [Instruction Set](Instruction-Set): Detailed explanation of each instruction.
53+
* [Registers](Registers): Information on the different register types.
54+
* [Memory Model](Memory-Model): How memory is organised and accessed.
55+
* [System Calls](System-Calls): How to interact with the OS kernel.
56+
* [Standard Library](Standard-Library): Overview of available functions.
57+
58+
This introduction provides a foundation for understanding the MVM assembly language. You can start writing programs
59+
after
60+
understanding the basic concepts and then explore more advanced features.
61+
62+

0 commit comments

Comments
 (0)