-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguageSpecE.txt
68 lines (48 loc) · 1.25 KB
/
LanguageSpecE.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
==Registers==
Represented by x, y, z, w.
Valid values 0-7
reg7 is the program counter
==Literals==
Represented by <Literal>
An 8 bit number
==Booleans==
False: 0
True: != 0
==Operations==
l <Literal> x
* loads the literal value into x
add x y z
* x + y -> z
minus x y z
* x - y -> z
negate x y
* Negates x (multiplies by -1) -> y
pt x y
* copies the value in x into y
* Pass Through
and x y z
* x (boolean and) y -> z
or x y z
* x (boolean or) y -> z
invert x y
* if x == 0 then 1 -> y
* if x != 0 then 0 -> y
gt x y z
* if x > y then 1 -> z else 0 -> z
e x y z
* if x == y then 1 -> z else 0 -> z
lt x y z
* if x < y then 1 -> z else 0 -> z
==Jump Instructions==
If the function is true, ALU outputs the new value, else ALU outputs the current Program Counter value + 1
jgt w x y z
* if w > x then y -> z else program counter -> z
* jgt <arg1> <arg2> <new value> <destination register>
je w x y z
* if w == x then y -> z else program counter -> z
jlt w x y z
* if w < x then y -> z else program counter -> z
==Comments==
Since each command has a specific number of tokens that it looks at, comments can be placed at the end of each line, and will be ignored.
eg:
invert 1 2 <this is a comment>