Skip to content

Commit 4f7520a

Browse files
committed
refactor & update opcodes upto 15
1 parent 8d938a7 commit 4f7520a

File tree

1 file changed

+69
-17
lines changed

1 file changed

+69
-17
lines changed

smalig/grammar.yaml

+69-17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
# - vA: It is always a destination register on this document and a single <A> represents a 4-bit register, i.e, first 16 registers (0-15).
1616
# As such vAA represents an 8-bit register, i.e, first 256 registers (0-255), and vAAAA represents a 16-bit register, i.e, first 64k registers (0-65535).
1717
# - vB: It is always a source register on this document and denotion of <B> is same as <A>.
18+
# Arguments which indicate a literal value have the form "#+X".
19+
# Arguments which indicate a relative instruction address offset have the form "+X".
20+
# Arguments which indicate a literal constant pool index have the form "kind@X", where "kind" indicates which constant pool is being referred to.
21+
1822
- opcode: "00"
1923
name: "nop"
2024
format: "ØØ|op"
@@ -23,7 +27,7 @@
2327
args_info: ""
2428
short_desc: "No operation"
2529
long_desc: "Does nothing, Waste cycles."
26-
note: "Data-bearing pseudo-instructions are tagged with this opcode, in which case the high-order byte of the opcode unit indicates the nature of the data. See \"packed-switch-payload Format\", \"sparse-switch-payload Format\", and \"fill-array-data-payload Format\"."
30+
note: 'Data-bearing pseudo-instructions are tagged with this opcode, in which case the high-order byte of the opcode unit indicates the nature of the data. See "packed-switch-payload Format", "sparse-switch-payload Format", and "fill-array-data-payload Format".'
2731
example: "0000 - nop"
2832
example_desc: "Does nothing, Waste cycles"
2933

@@ -34,7 +38,7 @@
3438
syntax: "move vA, vB"
3539
args_info: "A: destination register (4 bits), B: source register (4 bits)"
3640
short_desc: "Move the contents of one non-object register to another."
37-
long_desc: "Moves the content of vB into vA. Both registers must be in the first 16 register range (0-15)."
41+
long_desc: "Moves the content of vB into vA. Both registers is in the first 16 register range (0-15)."
3842
note: ""
3943
example: "0110 - move v0, v1"
4044
example_desc: "Moves the content of v1 into v0."
@@ -46,7 +50,7 @@
4650
syntax: "move/from16 vAA, vBBBB"
4751
args_info: "A: destination register (8 bits), B: source register (16 bits)"
4852
short_desc: "Move the contents of one non-object register to another."
49-
long_desc: "Moves the content of vB into vA. vB must be in the 64k register range (0-65535) while vA is one of the first 256 registers (0-255)."
53+
long_desc: "Moves the content of vB into vA. vB is in the 64k register range (0-65535) while vA is one of the first 256 registers (0-255)."
5054
note: ""
5155
example: "0200 1900 - move/from16 v0, v25"
5256
example_desc: "Moves the content of v25 into v0."
@@ -58,7 +62,7 @@
5862
syntax: "move/16 vAAAA, vBBBB"
5963
args_info: "A: destination register (16 bits), B: source register (16 bits)"
6064
short_desc: "Move the contents of one non-object register to another."
61-
long_desc: "Moves the content of vB into vA. Both registers must be in the first 64k register range (0-65535) & 16 bits."
65+
long_desc: "Moves the content of vB into vA. Both registers is in the first 64k register range (0-65535) & 16 bits."
6266
note: ""
6367
example: "030000090181 - move/16 v2304, v33025"
6468
example_desc: "Moves the content of v33025 into v2304."
@@ -70,7 +74,7 @@
7074
syntax: "move-wide vA, vB"
7175
args_info: "A: destination register-pair (4 bits), B: source register-pair (4 bits)"
7276
short_desc: "Move the contents of one register-pair to another."
73-
long_desc: "Move the value of the (vB, vB+1) register-pair to the (vA, vA+1) register-pair. Both register-pairs must be in the first 16 register range (0-15)."
77+
long_desc: "Move the value of the (vB, vB+1) register-pair to the (vA, vA+1) register-pair. Both register-pairs is in the first 16 register range (0-15)."
7478
note: "It is legal to move from vN to either vN-1 or vN+1, so implementations must arrange for both halves of a register-pair to be read before anything is written."
7579
example: ""
7680
example_desc: ""
@@ -82,7 +86,7 @@
8286
syntax: "move-wide/from16 vAA, vBBBB"
8387
args_info: "A: destination register-pair (8 bits), B: source register-pair (16 bits)"
8488
short_desc: "Move the contents of one register-pair to another."
85-
long_desc: "Move the value (long/double) of the (vBBBB, vBBBB+1) register-pair to the (vAA, vAA+1) register-pair. vB must be in the 64k register range (0-65535) while vA is one of the first 256 registers (0-255)."
89+
long_desc: "Move the value (long/double) of the (vBBBB, vBBBB+1) register-pair to the (vAA, vAA+1) register-pair. vB is in the 64k register range (0-65535) while vA is one of the first 256 registers (0-255)."
8690
note: "It is legal to move from vN to either vN-1 or vN+1, so implementations must arrange for both halves of a register-pair to be read before anything is written."
8791
example: "0516 0000 - move-wide/from16 v22, v0"
8892
example_desc: "Moves the content of register-pair (v0, v0+1) into (v22, v22+1)."
@@ -94,7 +98,7 @@
9498
syntax: "move-wide/from16 vAAAA, vBBBB"
9599
args_info: "A: destination register-pair (16 bits), B: source register-pair (16 bits)"
96100
short_desc: "Move the contents of one register-pair to another."
97-
long_desc: "Move the value of the (vBBBB, vBBBB+1) register-pair to the (vAAAA, vAAAA+1) register-pair. Both register-pairs must be in the first 64k register range (0-65535) & 16 bits."
101+
long_desc: "Move the value of the (vBBBB, vBBBB+1) register-pair to the (vAAAA, vAAAA+1) register-pair. Both register-pairs is in the first 64k register range (0-65535) & 16 bits."
98102
note: "It is legal to move from vN to either vN-1 or vN+1, so implementations must arrange for both halves of a register-pair to be read before anything is written."
99103
example: ""
100104
example_desc: ""
@@ -106,7 +110,7 @@
106110
syntax: "move-object vA, vB"
107111
args_info: "A: destination register (4 bits), B: source register (4 bits)"
108112
short_desc: "Move the contents of one object-bearing register to another."
109-
long_desc: "Move the value of register vB to register vA. Both registers must be in the first 16 register range (0-15)."
113+
long_desc: "Move the value of register vB to register vA. Both registers is in the first 16 register range (0-15)."
110114
note: ""
111115
example: "0781 - move-object v1, v8"
112116
example_desc: "Moves the content of v8 to v1."
@@ -118,7 +122,7 @@
118122
syntax: "move-object/from16 vAA, vBBBB"
119123
args_info: "A: destination register (8 bits), B: source register (16 bits)"
120124
short_desc: "Move the contents of one object-bearing register to another."
121-
long_desc: "Move the value of register vBBBB to register vAA. vB must be in the 64k register range (0-65535) while vA is one of the first 256 registers (0-255)."
125+
long_desc: "Move the value of register vBBBB to register vAA. vB is in the 64k register range (0-65535) while vA is one of the first 256 registers (0-255)."
122126
note: ""
123127
example: "0801 1500 - move-object/from16 v1, v21"
124128
example_desc: "Move the content of v21 to v1."
@@ -130,7 +134,7 @@
130134
syntax: "move-object/16 vAAAA, vBBBB"
131135
args_info: "A: destination register (16 bits), B: source register (16 bits)"
132136
short_desc: "Move the contents of one object-bearing register to another."
133-
long_desc: "Move the value of register vBBBB to register vAAAA. Both registers must be in the first 64k register range (0-65535) & 16 bits."
137+
long_desc: "Move the value of register vBBBB to register vAAAA. Both registers is in the first 64k register range (0-65535) & 16 bits."
134138
note: ""
135139
example: ""
136140
example_desc: ""
@@ -142,7 +146,7 @@
142146
syntax: "move-result vAA"
143147
args_info: "A: destination register (8 bits)"
144148
short_desc: "Moves the single-word, non-object result of the preceding invoke-kind to the specified register. Must immediately follow the invoke-kind."
145-
long_desc: "Moves the single-word result of the immediately preceding method invocation into the destination register (vA). vA must be in the first 256-register range (0-255)."
149+
long_desc: "Moves the single-word result of the immediately preceding method invocation into the destination register (vA). vA is in the first 256-register range (0-255)."
146150
note: "Must immediately follow an invoke-kind with a valid single-word, non-object result. Anywhere else is invalid."
147151
example: "0A00 - move-result v0"
148152
example_desc: "Move the return value of a previous method invocation into v0."
@@ -154,7 +158,7 @@
154158
syntax: "move-result-wide vAA"
155159
args_info: "A: destination register (8 bits)"
156160
short_desc: "Moves the wide (double-word) non-object result of the preceding invoke-kind to the specified register-pair."
157-
long_desc: "Moves the wide (double-word) result of the previous method invocation into register-pair (vAA, vAA+1). vA must be in the first 256-register range (0-255)."
161+
long_desc: "Moves the wide (double-word) result of the previous method invocation into register-pair (vAA, vAA+1). vA is in the first 256-register range (0-255)."
158162
note: "Must immediately follow an invoke-kind with a valid double-word result. Anywhere else is invalid."
159163
example: "0B02 - move-result-wide v2"
160164
example_desc: "Move the long/double result value of the previous method invocation into v2,v3."
@@ -166,7 +170,7 @@
166170
syntax: "move-result-object vAA"
167171
args_info: "A: destination register (8 bits)"
168172
short_desc: "Moves the object result of the preceding invoke-kind to the specified register."
169-
long_desc: "Moves the object result of the previous method invocation into vAA. vA must be in the first 256-register range (0-255)."
173+
long_desc: "Moves the object result of the previous method invocation into vAA. vA is in the first 256-register range (0-255)."
170174
note: "Must immediately follow an invoke-kind or filled-new-array with a valid object result. Anywhere else is invalid."
171175
example: "0C00 - move-result-object v0"
172176
example_desc: "Move the object result of the previous method invocation into v0."
@@ -178,7 +182,7 @@
178182
syntax: "move-exception vAA"
179183
args_info: "A: destination register (8 bits)"
180184
short_desc: "Moves the exception object of the most recent exception to the specified register."
181-
long_desc: "Moves the caught exception into vAA. vA must be in the first 256-register range (0-255)."
185+
long_desc: "Moves the caught exception into vAA. vA is in the first 256-register range (0-255)."
182186
note: "This must be the first instruction of any exception handler whose caught exception is not to be ignored, and must only *ever* occur as the first instruction of an exception handler; anywhere else is invalid."
183187
example: "0D19 - move-exception v25"
184188
example_desc: "Moves the caught exception into register v25."
@@ -202,7 +206,7 @@
202206
syntax: "return vAA"
203207
args_info: "A: return value register (8 bits)"
204208
short_desc: "Return from a single-width (32-bit) non-object value-returning method."
205-
long_desc: "Returns the 32-bit value in vAA to the caller. vA must be in the first 256-register range (0-255)."
209+
long_desc: "Returns the 32-bit value in vAA to the caller. vA is in the first 256-register range (0-255)."
206210
note: ""
207211
example: "0F00 - return v0"
208212
example_desc: "Returns with return value in v0."
@@ -214,7 +218,7 @@
214218
syntax: "return-wide vAA"
215219
args_info: "A: return value register (8 bits)"
216220
short_desc: "Return from a double-width (64-bit) value-returning method."
217-
long_desc: "Returns a double/long result from register-pair (vAA, vAA+1) to the caller. vA must be in the first 256-register range (0-255)."
221+
long_desc: "Returns a double/long result from register-pair (vAA, vAA+1) to the caller. vA is in the first 256-register range (0-255)."
218222
note: ""
219223
example: "1000 - return-wide v0"
220224
example_desc: "Returns with a double/long value in v0,v1."
@@ -226,11 +230,59 @@
226230
syntax: "return-object vAA"
227231
args_info: "A: return value register (8 bits)"
228232
short_desc: "Return from an object-returning method."
229-
long_desc: "Returns the object reference value from vAA to the caller. vA must be in the first 256-register range (0-255)."
233+
long_desc: "Returns the object reference value from vAA to the caller. vA is in the first 256-register range (0-255)."
230234
note: ""
231235
example: "1100 - return-object v0"
232236
example_desc: "Returns with object reference value in v0."
233237

238+
- opcode: "12"
239+
name: "const/4"
240+
format: "B|A|op"
241+
format_id: "11n"
242+
syntax: "const/4 vA, #+B"
243+
args_info: "A: destination register (4 bits), B: signed int (4 bits)"
244+
short_disc: "Move the given literal value (sign-extended to 32 bits) into the specified register."
245+
long_desc: "Moves the literal value B into vA. B is sign-extended to 32 bits. The value of B is in the range -8 to 7 (-0x8 to 0x7)."
246+
note: ""
247+
example: "1200 0001 - const/4 v0, 0x1"
248+
example_desc: "Moves the literal value 0x1(1) into v0."
249+
250+
- opcode: "13"
251+
name: "const/16"
252+
format: "AA|op BBBB"
253+
format_id: "21s"
254+
syntax: "const/16 vAA, #+BBBB"
255+
args_info: "A: destination register (8 bits), B: signed int (16 bits)"
256+
short_desc: "Move the given literal value (sign-extended to 32 bits) into the specified register."
257+
long_desc: "Moves the literal value BBBB into vAA. BBBB is sign-extended to 32 bits. The value of BBBB is in the range -32768 to 32767 (-0x8000 to 0x7FFF)."
258+
note: ""
259+
example: "1300 0A00 - const/16 v0, 0xa"
260+
example_desc: "Moves the literal value 0xa(10) into v0."
261+
262+
- opcode: "14"
263+
name: "const"
264+
format: "AA|op BBBBlo"
265+
format_id: "31i"
266+
syntax: "const vAA, #+BBBBBBBB"
267+
args_info: "A: destination register (8 bits), B: arbitrary constant (32 bits)"
268+
short_desc: "Move the given literal value into the specified register."
269+
long_desc: "Moves the literal value BBBB into vAA. BBBB is a 32-bit constant. The value of BBBB is in the range -2147483648 to 2147483647 (-0x80000000 to 0x7FFFFFFF)."
270+
note: ""
271+
example: "1400 4E61BC00 - const v0, 0xBC614E"
272+
example_desc: "Moves the literal value 0xBC614E(12345678) into v0."
273+
274+
- opcode: "15"
275+
name: "const/high16"
276+
format: "AA|op BBBB"
277+
format_id: "21h"
278+
syntax: "const/high16 vAA, #+BBBB0000"
279+
args_info: "A: destination register (8 bits), B: signed int (16 bits)"
280+
short_desc: "Move the given literal value (right-zero-extended to 32 bits) into the specified register."
281+
long_desc: "Moves the literal value BBBB0000 into vAA. BBBB is right-zero-extended to 32 bits. The value of BBBB is in the range -32768 to 32767 (-0x80000000 to 0x7FFF0000)."
282+
note: "Generaly used to initialise float values."
283+
example: "1500 2041 - const/high16 v0, 0x41200000 (#float 10.0)"
284+
example_disc: "Moves the floating literal value 0x41200000(10.0) into v0. The 16 bit literal in the instruction carries the top 16 bits of the floating point number."
285+
234286
- opcode: "28"
235287
name: "goto"
236288
format: "AA|op"

0 commit comments

Comments
 (0)