-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjelvm_instruction_set.txt
140 lines (113 loc) · 2.85 KB
/
jelvm_instruction_set.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
The jelvm instruction set
---------------------------
The instruction set of the virtual machine follows.
rN -- register N.
W -- wordsize. One of 'b', 's', 'w', 'l'.
b = 8 bits. s = 16 bits. w = 32 bits. l = 64 bits.
DATA -- Value in digits. Prefix 0x is supported.
OFFSET -- Value in digits. Prefix 0x is supported.
The first line is the byte offsets of the compiled instruction.
The second line is the opcode (in hex) followed by the other parts of the instruction with sized
that can be inferred from the first line of offsets.
The third line is a synopsis of the assembler instruction that the as-jelvm assembler accepts.
Instructions
---------------------------------
0 1 2 4 6
10 WW REGA REGB
move.W rA,rB
Copy contents of rA to rB.
0 1 2 4 6
11 WW REGA REGB
add.W rA,rB
Add contents of rA to rB.
rB = rB + rA
0 1 2 4 6
12 WW REGA REGB
sub.W rA,rB
Subtract contents of rA from rB.
rB = rB - rA.
0 1 2 4 6
13 WW REGA DATA
lsl.W rA,DATA
Logical shift left rA, DATA nr of bits.
rA << DATA.
0 1 2 4 6
14 WW REGA DATA
lsr.W rA,DATA
Logical shift right rA, DATA nr of bits.
rA >> DATA.
0 1 2 4
15 WW REGA
not.W rA
0 1 2 4 6
16 WW REGA REGB
eor.W rA,rB
0 1 2 4 6
17 WW REGA REGB
and.W rA,rB
0 1 2 4 6
18 WW REGA REGB
or.W rA,rB
0 1 2 4 6 10
30 WW REGA REGB OFFSET
store.W rA,OFFSET(rB)
0 1 2 4 6 10
31 WW REGA REGB OFFSET
load.W OFFSET(rA),rB
Transfer contents at address rA+OFFSET to register rB.
0 1 2 4
32 WW REGA
jmp.W rA
Jump to address contained in rA.
0 1 2 4 6
33 WW REGA REGB
jeq.W rA,rB
Jump to rB if rA.W is zero.
0 1 2 4 6
34 WW REGA REGB
jne.W rA,rB
Jump to rB if rA.W is non-zero.
0 1 2 4 12
50 WW REGA DATA
addrof.l rN,DATA
addrof.l rN,&LABEL
0 1 2 4 12
51 WW REGA DATA
set.W rA DATA
Set rA to DATA.
0 1 2 4 12
52 WW REGA DATA
inc.W rA,DATA
0 1 2 4 12
53 WW REGA DATA
dec.W rA,DATA
0 1 2 10
54 WW OFFSET
bra.W OFFSET
Jump to PC+OFFSET.
0 1 2 4 12
55 WW REGA OFFSET
beq.W rA,OFFSET
Jump to PC+OFFSET if rA is zero.
0 1 2 4 12
56 WW REGA OFFSET
bne.W rA,OFFSET
Jump to PC+OFFSET if rA is non-zero.
0 1 2 4
70 WW SYSCALL
syscall.l &SYSCALL
Perform systemcall.
Args to systemcall are contents of registers 2 and up.
Result is saved in register 0.
Errno is saved in register 1.
0 1 2 4
71 WW REGA
call.l rA
Make a C function call: reg[0] = (rA)(®s)
The C function takes a single argument:
(uint64_t *regs) a pointer to the register array.
Result is saved in register 0.
0 1 2 10
72 WW DATA
errno.W DATA
Set errno to value DATA.