-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlookup-tables.js
90 lines (85 loc) · 1.5 KB
/
lookup-tables.js
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const C_BINARY = Object.freeze({
'0': '101010',
'1': '111111',
'-1': '111010',
'D': '001100',
'A': '110000',
'!D': '001101',
'!A': '110001',
'-D': '001111',
'-A': '110011',
'D+1': '011111',
'A+1': '110111',
'D-1': '001110',
'A-1': '110010',
'D+A': '000010',
'D-A': '010011',
'A-D': '000111',
'D&A': '000000',
'D|A': '010101',
});
const C_A_BINARY = Object.freeze({
'M': '110000',
'!M': '110001',
'-M': '110011',
'M+1': '110111',
'M-1': '110010',
'D+M': '000010',
'D-M': '010011',
'M-D': '000111',
'D&M': '000000',
'D|M': '010101',
});
const JUMP_BINARY = Object.freeze({
'null': '000',
'JGT': '001',
'JEQ': '010',
'JGE': '011',
'JLT': '100',
'JNE': '101',
'JLE': '110',
'JMP': '111',
});
const DESTINATION_BINARY = Object.freeze({
'null': '000',
'M': '001',
'D': '010',
'MD': '011',
'A': '100',
'AM': '101',
'AD': '110',
'AMD': '111',
});
// { } Symbols: predefined, labels, variables
const SYMBOL_MEM_LOC = {
'SP': 0,
'LCL': 1,
'ARG': 2,
'THIS': 3,
'THAT': 4,
'R0': 0,
'R1': 1,
'R2': 2,
'R3': 3,
'R4': 4,
'R5': 5,
'R6': 6,
'R7': 7,
'R8': 8,
'R9': 9,
'R10': 10,
'R11': 11,
'R12': 12,
'R13': 13,
'R14': 14,
'R15': 15,
'SCREEN': 16384,
'KBD': 24576,
};
module.exports = {
C_A_BINARY,
C_BINARY,
JUMP_BINARY,
DESTINATION_BINARY,
SYMBOL_MEM_LOC,
};