-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
73 lines (66 loc) · 1.61 KB
/
README
File metadata and controls
73 lines (66 loc) · 1.61 KB
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
Instruction Set:
enum {
0 = NOP,
1 = PUSH,
2 = POP,
3 = MOV,
4 = ADD,
5 = SUB,
6 = MUL,
7 = CMP,
8 = JMP,
9 = JEQ,
10 = JNE,
11 = JLT,
12 = JGT,
13 = JLE,
14 = JGE,
15 = CALL,
16 = RET,
17 = SYSINT,
18 = AND,
19 = OR,
20 = XOR,
21 = NAND,
22 = NOR
};
Each instruction occupies the 5 higher order bits of a byte
The lower three bits are used for specifying special forms of the instruction
as follows:
NOP: no special form
PUSH: if 0, then push an immediate value
otherwise, push the corresponding register
POP: bottom 3 bits specify the register (cannot be 000)
MOV: consumes 2 bytes MINIMUM for the instruction
First 3 bits (destination):
000 -> memory location
001-111 -> register
Next 4 bits (source):
1XXX -> immediate value
0000 -> memory location
0001-0111 -> register
Next bit:
Dereference source?
Next bit:
Dereference destination?
Next 2 bits:
00 -> 32-bit move
01 -> 16-bit move
10 -> 8-bit move
11 -> 4-bit move
1. Moving into register, or memory location? (3 bits)
2. Moving from register, or memory location, or immediate value? (4 bits)
3. Dereference the source? (1 bit)
4. Dereference the destination? (1 bit)
5. Size of move? [D, W, B, L, H] (3 bits)
ADD/SUB/MUL/AND/OR/NOT/XOR/NAND/NOR:
First 3 bits (destination) [same as MOV]
Next 4 bits (source) [same as MOV]
Next 2 bits are ignored
Final 2 bits are size
SYSCALLS:
0 -> EXIT (return in rgb)
1 -> PUTCHAR
2 -> PRINT
3 -> GETCHAR
4 -> READ