Skip to content

Commit 4c7d19a

Browse files
authored
Update README.md with full list
1 parent beb51c6 commit 4c7d19a

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

README.md

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,37 @@ Ee.E.e!eeeeee!.Ee.E.e!
1313
```
1414
Disgustingly beautiful right?
1515

16+
## migraine interpreter internals
17+
- 2 Immediate integer registers
18+
- Where you'll be storing immediate values from functions
19+
- The current usable register can be swapped with ``E``
20+
- Function index
21+
- Accesses all functions
22+
- Can be traversed with ``e`` and, when the index is odd, ``! or .`` will execute a goto function
23+
- Resets to 0 if the index is larger than the function list
24+
- Program counter
25+
- Keeps track of how far it is within the program
26+
- Can be traversed through the branch function
27+
- """Unlimited""" integer stack
28+
- Lets you store values from registers. Basically makes this whole language functional
29+
- Can be accessed through sevaral stack functions
30+
1631
## How do I use this nightmare?
1732
migraine has only 4 operation characters, but it lets you do everything you need.
1833
| Character | Operation | Purpose |
1934
| --- | --- | --- |
2035
| ``e`` | Function index increment | Iterates through the function list |
21-
| ``.`` | Execute function | Executes the current function determined by the function index. Passes through the current register |
36+
| ``.`` | Execute function | Executes the current function determined by the function index. Passes the current register to the function as a parameter |
2237
| ``!`` | Execute function pass 0 | Very similar to ``.`` however this purposefuly passes 0 to the function instead of a register |
2338
| ``E`` | Swap register | Swap the current register |
2439

25-
migraine uses a function list that you iterate through using these operators in order to create logic. You might notice, you can only increment!
26-
27-
How do you decrement? This function list has a special function when the function index is odd, it has a goto function that allows you to traverse the function list however you fancy. ``e!`` is used quite a bit in programs as it sets the function index back to 0.
40+
The interpreter has *also* been setup to ignore all characters following a ``#`` character, this allows for comments in code files. Yipee! Documentation!
2841

2942
### The function list
43+
migraine uses a function list that you iterate through using the operators above in order to create logic. You might notice, you can only increment!
44+
45+
How do you decrement? This function list has a special function when the function index is an odd number, it has a goto function that allows you to traverse the function list however you fancy. ``e!`` is used quite a bit in programs as it sets the function index back to 0.
46+
3047
| Index | Function | Purpose |
3148
| --- | --- | --- |
3249
| 0 | number_0 | Sets the rightmost digit in the current register to 0 |
@@ -40,11 +57,43 @@ How do you decrement? This function list has a special function when the functio
4057
| 16 | number_8 | Sets the rightmost digit in the current register to 8 |
4158
| 18 | number_9 | Sets the rightmost digit in the current register to 9 |
4259

43-
Woah woah, okay before we continue. This number function is pretty versatile. You can chain them using ``.`` to assemble numbers.
60+
Okay before we continue. This number function is pretty versatile. You can chain them using ``.`` to assemble numbers.
4461

4562
``ee ee ee!`` would set the current register to 3. If we were to then do ``ee.`` immediately afterwards, the current register would now be 34.
4663

4764
Say we want to reset the current register back to 0, we can do ``e!`` to reset the function index to 0, and then ``!`` which would set the current register to 0
4865

66+
This works because the number function internally looks something like this:
67+
```
68+
int number(int intRegister, int digit)
69+
{
70+
return (intRegister * 10) + digit;
71+
}
72+
```
73+
It will always shift to the left to allow for a new digit, however when you pass 0 through (instead of a register) it resets.
74+
| Index | Function | Purpose |
75+
| --- | --- | --- |
76+
| 20 | add | Adds the non-current register to the current register |
77+
| 22 | subtract | Subtracts the current register from the non-current register |
78+
| 24 | multiply | Multiplies the non-current register to the current register |
79+
| 26 | divide | Divides the current register from the non-current register |
80+
| 28 | input | Gets input from stdin through the console, copies to the current register |
81+
| 30 | output_int | Output the current register as an integer to the console |
82+
| 32 | output_char | Output the current register as a character to the console |
83+
| 34 | compare_equals | Check if the current register is equal to the non-current register, the current register will be overriden with the result |
84+
| 36 | compare_greater | Check if the current register is greater than the non-current register, the current register will be overriden with the result |
85+
| 38 | branch | If the current register has a value greater than 0, it will set the program counter to the non-current register |
86+
| 40 | stack_push | Push the current register to the stack |
87+
| 42 | stack_pop | Pop from the top of the stack and override the current register with the popped value |
88+
| 44 | stack_read | Read the stack by accessing at an index provided by the current register, the current register will be overriden with the read value |
89+
| 46 | stack_write | Write to the stack by accessing at an index provided by the current register, overrites the stack entry with a new value from the non-current register |
90+
91+
Annnndd, that's all of them! That's the official function list however due to migraine being structured this way, it is completely possible to amend more functions to it. *The only issue is, the higher the index, the more ``e``'s are required to access them!!!*
4992

93+
All functions listed in the table (notice goto is left out, it's a special little guy) follow this pattern:
94+
```cpp
95+
currentRegister = function(EITHER currentRegister OR 0);
96+
```
97+
The result will always be given back to the current register.
5098

99+
I recommend checking out the ./Examples folder as I've included a few usable code demos with documentation!

0 commit comments

Comments
 (0)