Skip to content
This repository was archived by the owner on May 25, 2020. It is now read-only.

Commit 518d7bd

Browse files
committed
UPdate
1 parent 834c8a7 commit 518d7bd

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,101 @@ For now, only Windows users can enjoy this tool, and this is not going to change
1212
https://thecool1james.github.io/Command-Interpreter/
1313

1414
I'm kinda addicted to the emojis now. :stuck_out_tongue_closed_eyes:
15+
16+
| MNEMONIC | Bytecode | Stack In | Stack Out | Description |
17+
|----------|-----------|----------------------------------------|----------------|---------------------------------------------|
18+
| n/a | 0x00 | | | Null string terminator |
19+
| push | 0x01 | object id | object id | Pushes an object into stack |
20+
| ipush | 0x02 | variable id | variable value | Push an integer into stack |
21+
| swap | 0x03 | a, b | b, a | Swaps the top 2 values on the stack |
22+
| call | 0x04 | arg n, arg n-1 ... arg 0, method ID | return value | Call library function |
23+
| db | 0x05 | | | RESERVED, see 0x2A |
24+
| ret | 0x06 | | | Return void to caller |
25+
| iret | 0x07 | return value | return value | Return value after call, return to caller |
26+
| magic | 0x08 | | | BREAKPOINT |
27+
| error | 0x09 | error code | all cleared | Activates command block to print exception. |
28+
| n/a | 0x0A-0x19 | | | RESERVED FOR LIBRARY AND REFERENCES |
29+
| _raw | 0x2A | arg n, arg n-1 ... arg 0 | | Insert raw Minecraft comamnd* |
30+
| irv | 0x2B | variable type id, variable name hashed | | Register a new empty variable |
31+
| ro | 0x2C | target object id, source object id | | Registers a new object |
32+
| ipop | 0x2D | variable id | | Pops integer from stack into variable |
33+
| pop | 0x2E | target object id, source object id | | Pops object from stack into another object |
34+
| spush | 0x2F | variable id | variable value | Push a string into string register |
35+
| lpush | 0x30 | variable id | variable value | Push a long into stack |
36+
| bpush | 0x31 | variable id | variable value | Push a boolean into stack |
37+
| spop | 0x32 | variable id | | Pops string from register** into variable |
38+
| lpop | 0x33 | variable id | | Pops long from stack into variable |
39+
| bpop | 0x34 | variable id | | Pops boolean from stack into variable |
40+
| lods | 0x35 | | | Loads string into register |
41+
| lodl | 0x36 | | | Loads long into register |
42+
| lodb | 0x37 | | | Loads boolean into register |
43+
| lodi | 0x38 | | | Loads integer into register |
44+
| pops | 0x39 | | value | Loads register into stack |
45+
| popl | 0x3A | | value | Loads register into stack |
46+
| popb | 0x3B | | value | Loads register into stack |
47+
| popi | 0x3C | | value | Loads register into stack |
48+
49+
* - Note that the string stored in the stack must be null terminated with 0x0000 (yes, that's 4 bytes)
50+
- Note if there is 0x05 following the the null termination, then it signals a reference to an argument. The 0x05 is then followed by the argument id
51+
- The argument is structured like an object
52+
53+
** String register differs from regular registers
54+
55+
Stack and registers are abstract. Stack and registers can only hold up to 64 bits of data.
56+
57+
How it all operates:
58+
Roslyn Parser ->[References]-> OPCODES ->[Library]-> Command Blocks
59+
60+
A [Reference] contains all the variable structures. It contains all the system-required method names hashed, ther corresponding IDs
61+
and their structures. This will be written in CBIL, and compiled to the same bytecode above.
62+
A [Library] contains all the code linked to the system-required methods. The names of each method should match that of the [Reference]. This will be
63+
written in CBIL, and compiled to the bytecode above.
64+
A [structure] is something to define the structure a variable/object that will be stored in the stack. Think of classes.
65+
66+
A variable will be stored in a variable dictionary with the id and it's corresponding type and hashed name.
67+
An object will be stored in an object dictionary with the id and it's corresponding type and hashed name.
68+
69+
0x0A: A 2-byte variable structure ID follows. This will be the ID that will identify the variable type. (MNEMONIC: var)
70+
0x0B: A SHA1 object structure ID follows. This will be the ID that will identify the object type. (MNEMONIC: obj)
71+
0x0C: A 0x0000 goes in front of it to define the end of the structure (MNEMONIC: n/a)
72+
0x0D: Defines the start of a method, it then is followed by a hashed string, the object id, and the flags (stack: array of N variable structures as it's arguments) (MNEMONIC: [name] [id] [flags]:)
73+
0x0E: Defines the start of a class, it is then followed by a hashed string (the id of the object). (MNEMONIC: class [name]:)
74+
0x0F: Namespace name (MNEMONIC: namespace [name]:
75+
76+
All methods + variables in a class would be names [namespace].[class].[name] to give each class an unique id name
77+
78+
Example CBIL script:
79+
``` java
80+
using CBIL;
81+
namespace ExampleScript
82+
{
83+
class Example
84+
{
85+
string exampleString = "Hello World";
86+
void main()
87+
{
88+
printLn(exampleString);
89+
}
90+
}
91+
}
92+
```
93+
94+
Bytecode Mnemonics:
95+
```
96+
namespace ExampleScript:
97+
class ExampleScript.Example:
98+
irv 0x5 ExampleScript.Example.exampleString
99+
lods "Hello World"
100+
spop ExampleScript.Example.exampleString
101+
ExampleScript.Example.Main void private:
102+
spush ExampleScript.Example.exampleString
103+
call CBIL.Print.printLN
104+
105+
namespace CBIL:
106+
class CBIL.Print:
107+
CBIL.Print.printLN void public static:
108+
irv 0x5 CBIL.Print.printLN.s
109+
spop CBIL.Print.printLN.s
110+
_raw "say @a" db CBIL.Print.printLN.s
111+
ret
112+
```

0 commit comments

Comments
 (0)