Skip to content

Commit 6865794

Browse files
committed
Add operation instructions
1 parent f187968 commit 6865794

File tree

1 file changed

+139
-1
lines changed

1 file changed

+139
-1
lines changed

docs/Zune software/Iris/uix-assembly.md

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Mneumonic | Name
6060
`MUL` | [MathMultiply](#mathmultiply)
6161
`DIV` | [MathDivide](#mathdivide)
6262
`MOD` | [MathModulus](#mathmodulus)
63-
`NEG` | [MathModulus](#mathmodulus)
63+
`NEG` | [MathNegate](#mathnegate)
6464
`AND` | [LogicalAnd](#logicaland)
6565
`ORR` | [LogicalOr](#logicalor)
6666
`NOT` | [LogicalNot](#logicalnot)
@@ -277,6 +277,144 @@ Pushes the schema of the specified type to the stack.
277277
TYP <typeIndex>
278278
```
279279

280+
### Arithmetic and Logical Operations
281+
282+
#### Operation
283+
Performs the specified arithmetic or logical operation using the provided operation host type schema. Unary operations will pop a single value off the stack and execute the operation. Binary operations will first pop the right operand, followed by the left. The operation result is pushed to the stack.
284+
285+
The operation host, such as `Int32Schema`, must support the requested operation. Type schemas can declare support for operations using `SupportsOperationHandler` and `PerformOperationHandler`.
286+
287+
This is a real instruction. It is recommended to use the alternative virtual instructions described in [Arithmetic and Logical Operations](#arithmetic-and-logical-operations) for the sake of clarity.
288+
```asm
289+
OPR <operationHostTypeIndex>, <operationId>
290+
```
291+
292+
#### MathAdd
293+
Pops two values off the stack and pushes their sum. This is a virtual instruction for [Operation](#operation).
294+
```asm
295+
ADD <operationHostTypeIndex>
296+
OPR <operationHostTypeIndex>, 1
297+
```
298+
299+
#### MathSubtract
300+
Pops two values, $a$ then $b$, off the stack and pushes their difference, $b - a$. This is a virtual instruction for [Operation](#operation).
301+
```asm
302+
SUB <operationHostTypeIndex>
303+
OPR <operationHostTypeIndex>, 2
304+
```
305+
306+
#### MathMultiply
307+
Pops two values off the stack and pushes their product. This is a virtual instruction for [Operation](#operation).
308+
```asm
309+
MUL <operationHostTypeIndex>
310+
OPR <operationHostTypeIndex>, 3
311+
```
312+
313+
#### MathDivide
314+
Pops two values, $a$ then $b$, off the stack and pushes their quotient, $b / a$. This is a virtual instruction for [Operation](#operation).
315+
```asm
316+
DIV <operationHostTypeIndex>
317+
OPR <operationHostTypeIndex>, 4
318+
```
319+
320+
#### MathModulus
321+
Pops two values, $a$ then $b$, off the stack and pushes their remainder, $b \bmod a$. This is a virtual instruction for [Operation](#operation).
322+
```asm
323+
MOD <operationHostTypeIndex>
324+
OPR <operationHostTypeIndex>, 5
325+
```
326+
327+
#### MathNegate
328+
Pops a value $a$ off the stack and pushes its negation, $-a$. This is a virtual instruction for [Operation](#operation).
329+
```asm
330+
NEG <operationHostTypeIndex>
331+
OPR <operationHostTypeIndex>, 16
332+
```
333+
334+
#### LogicalAnd
335+
Pops two values, $a$ then $b$, off the stack and pushes their logical AND, $a \land b$. This is a virtual instruction for [Operation](#operation).
336+
```asm
337+
AND <operationHostTypeIndex>
338+
OPR <operationHostTypeIndex>, 6
339+
```
340+
341+
#### LogicalOr
342+
Pops two values, $a$ then $b$, off the stack and pushes their logical OR, $b \lor a$. This is a virtual instruction for [Operation](#operation).
343+
```asm
344+
ORR <operationHostTypeIndex>
345+
OPR <operationHostTypeIndex>, 7
346+
```
347+
348+
#### LogicalNot
349+
Pops a value $a$ off the stack and pushes its logical negation, $\lnot a$. This is a virtual instruction for [Operation](#operation).
350+
```asm
351+
NOT <operationHostTypeIndex>
352+
OPR <operationHostTypeIndex>, 15
353+
```
354+
355+
#### RelationalEquals
356+
Pops two values, $a$ then $b$, off the stack and pushes whether they are equal, $b = a$. This is a virtual instruction for [Operation](#operation).
357+
```asm
358+
REQ <operationHostTypeIndex>
359+
OPR <operationHostTypeIndex>, 8
360+
```
361+
362+
#### RelationalNotEquals
363+
Pops two values, $a$ then $b$, off the stack and pushes whether they are not equal, $b \neq a$. This is a virtual instruction for [Operation](#operation).
364+
```asm
365+
RNE <operationHostTypeIndex>
366+
OPR <operationHostTypeIndex>, 9
367+
```
368+
369+
#### RelationalLessThan
370+
Pops two values, $a$ then $b$, off the stack and pushes whether the result of $b \lt a$. This is a virtual instruction for [Operation](#operation).
371+
```asm
372+
RLT <operationHostTypeIndex>
373+
OPR <operationHostTypeIndex>, 10
374+
```
375+
376+
#### RelationalGreaterThan
377+
Pops two values, $a$ then $b$, off the stack and pushes whether they are not equal, $b \gt a$. This is a virtual instruction for [Operation](#operation).
378+
```asm
379+
RGT <operationHostTypeIndex>
380+
OPR <operationHostTypeIndex>, 11
381+
```
382+
383+
#### RelationalLessThanEquals
384+
Pops two values, $a$ then $b$, off the stack and pushes whether they are less than or equal, $b \le a$. This is a virtual instruction for [Operation](#operation).
385+
```asm
386+
RLE <operationHostTypeIndex>
387+
OPR <operationHostTypeIndex>, 12
388+
```
389+
390+
#### RelationalGreaterThanEquals
391+
Pops two values, $a$ then $b$, off the stack and pushes whether they are greater than or equal, $b \ge a$. This is a virtual instruction for [Operation](#operation).
392+
```asm
393+
RGE <operationHostTypeIndex>
394+
OPR <operationHostTypeIndex>, 13
395+
```
396+
397+
#### RelationalIs
398+
Pops two values, `a` then `b`, off the stack and pushes whether `b is a`. This is a virtual instruction for [Operation](#operation), though it does not appear to be used anywhere.
399+
```asm
400+
RIS <operationHostTypeIndex>
401+
OPR <operationHostTypeIndex>, 14
402+
```
403+
404+
#### PostIncrement
405+
Pops a value $a$ off the stack and pushes $a + 1$. This is a virtual instruction for [Operation](#operation).
406+
```asm
407+
INC <operationHostTypeIndex>
408+
OPR <operationHostTypeIndex>, 17
409+
```
410+
411+
#### PostDecrement
412+
Pops a value $a$ off the stack and pushes $a - 1$. This is a virtual instruction for [Operation](#operation).
413+
```asm
414+
RNE <operationHostTypeIndex>
415+
DEC <operationHostTypeIndex>, 18
416+
```
417+
280418
## TODO
281419

282420
### `IStringEncodable`

0 commit comments

Comments
 (0)