ocmbytecode
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
ocmbytecode [2023/04/13 15:13] – [Opcode 0xA0..0xAF] nopsled | ocmbytecode [2023/04/23 14:52] – [Opcodes 30..3F] nopsled | ||
---|---|---|---|
Line 69: | Line 69: | ||
===== Opcodes 00..0F ===== | ===== Opcodes 00..0F ===== | ||
- | === Opcode | + | === Opcode |
does nothing | does nothing | ||
=== Opcode 0x01: Immediate byte (value) === | === Opcode 0x01: Immediate byte (value) === | ||
Line 173: | Line 173: | ||
stack output: smallint containing lowest 16 bits of a*b | stack output: smallint containing lowest 16 bits of a*b | ||
- | === Opcode 0x14: Divide Small Ints (div) === | + | === Opcode 0x14 (20): Divide Small Ints (div) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing a/b | stack output: smallint containing a/b | ||
- | === Opcode 0x15: Divide and Modulus of Small Ints (moddiv) === | + | === Opcode 0x15 (21): Divide and Modulus of Small Ints (moddiv) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing a/b (next to top); smallint containing a%b (top of stack) | stack output: smallint containing a/b (next to top); smallint containing a%b (top of stack) | ||
- | === Opcode 0x16: Modulus of Small Ints (divmod) === | + | === Opcode 0x16 (22): Modulus of Small Ints (divmod) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing a%b | stack output: smallint containing a%b | ||
- | === Opcode 0x17: Xor Small Ints (xor) === | + | === Opcode 0x17 (23): Xor Small Ints (xor) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing a ^ b | stack output: smallint containing a ^ b | ||
- | === Opcode 0x18: And Small Ints (and) === | + | === Opcode 0x18 (24): And Small Ints (and) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing a & b | stack output: smallint containing a & b | ||
- | === Opcode 0x19: Or Small Ints === (or) === | + | === Opcode 0x19 (25): Or Small Ints === (or) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing a | b | stack output: smallint containing a | b | ||
- | === Opcode 0x1A: Bitwise Negate Small Int (neg) === | + | === Opcode 0x1A (26): Bitwise Negate Small Int (neg) === |
stack input: smallint a | stack input: smallint a | ||
stack output: smallint containing ~a | stack output: smallint containing ~a | ||
- | === Opcode 0x1B: Shift Left Small Int (shl) === | + | === Opcode 0x1B (27): Shift Left Small Int (shl) === |
stack input: smallint a (next to top); smallint count (top of stack) | stack input: smallint a (next to top); smallint count (top of stack) | ||
stack output: smallint containing a << count | stack output: smallint containing a << count | ||
- | === Opcode 0x1C: Shift Right Small Int (shr) === | + | === Opcode 0x1C (28): Shift Right Small Int (shr) === |
stack input: smallint a (next to top); smallint count (top of stack) | stack input: smallint a (next to top); smallint count (top of stack) | ||
stack output: smallint containing ( (unsigned)a) >> count | stack output: smallint containing ( (unsigned)a) >> count | ||
- | === Opcode 0x1D: Shift Right Arithmetic Small Int (sar) === | + | === Opcode 0x1D (29): Shift Right Arithmetic Small Int (sar) === |
stack input: smallint a (next to top); smallint count (top of stack) | stack input: smallint a (next to top); smallint count (top of stack) | ||
stack output: smallint containing a >> count | stack output: smallint containing a >> count | ||
- | === Opcode 0x1E: Compare Small Ints for Greater (cmp) === | + | === Opcode 0x1E (30): Compare Small Ints for Greater (cmp) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing 1 if a > b, 0 otherwise | stack output: smallint containing 1 if a > b, 0 otherwise | ||
- | === Opcode 0x1F: Compare Small Ints for Less (cmp) === | + | === Opcode 0x1F (31): Compare Small Ints for Less (cmp) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
Line 236: | Line 236: | ||
===== Opcodes 20..2F ===== | ===== Opcodes 20..2F ===== | ||
- | === Opcode 0x20 (32): Compare Small Ints for equal === | + | === Opcode 0x20 (32): Compare Small Ints for equal (cmp) === |
stack input: smallint a (next to top); smallint b (top of stack) | stack input: smallint a (next to top); smallint b (top of stack) | ||
stack output: smallint containing 1 if a == b, 0 otherwise | stack output: smallint containing 1 if a == b, 0 otherwise | ||
- | === Opcode 0x21 (33): Test for Small Int Zero === | + | === Opcode 0x21 (33): Test for Small Int Zero (iszerow) |
stack input: object of any type (maybe only smallint intended) | stack input: object of any type (maybe only smallint intended) | ||
stack output: 1 if object has type smallint and is zero | stack output: 1 if object has type smallint and is zero | ||
- | === Opcode 0x22 (34): Add DWORDs === | + | === Opcode 0x22 (34): Add DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 253: | Line 253: | ||
note: DWORD instructions only use the 32 least significant bits in bigint input operands, and samllint operands are treated as unsigned for unknown reasons. All arithmetic is unsigned. As bigints are in sign/ | note: DWORD instructions only use the 32 least significant bits in bigint input operands, and samllint operands are treated as unsigned for unknown reasons. All arithmetic is unsigned. As bigints are in sign/ | ||
- | === Opcode 0x23 (35): Subtract DWORDs === | + | === Opcode 0x23 (35): Subtract DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 260: | Line 260: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x24 (36): Multiply DWORDs === | + | === Opcode 0x24 (36): Multiply DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 267: | Line 267: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x25 (37): Divide DWORDs === | + | === Opcode 0x25 (37): Divide DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 274: | Line 274: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x26 (38): Division and Modulus of DWORDs === | + | === Opcode 0x26 (38): Division and Modulus of DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 281: | Line 281: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x27 (39): Modulus of DWORDs === | + | === Opcode 0x27 (39): Modulus of DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 288: | Line 288: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x28 (40): Xor DWORDs === | + | === Opcode 0x28 (40): Xor DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 295: | Line 295: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x29 (41): And DWORDs === | + | === Opcode 0x29 (41): And DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 302: | Line 302: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x2A (42): Or DWORDs === | + | === Opcode 0x2A (42): Or DWORDs |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 309: | Line 309: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x2B (43): Bitwise Not DWORD === | + | === Opcode 0x2B (43): Bitwise Not DWORD (not) === |
stack input: small/big int a (top of stack) | stack input: small/big int a (top of stack) | ||
Line 316: | Line 316: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x2C (44): Shift Left DWORD === | + | === Opcode 0x2C (44): Shift Left DWORD (shl) === |
stack input: small/big int a (next to top); small/big int count (top of stack) | stack input: small/big int a (next to top); small/big int count (top of stack) | ||
Line 323: | Line 323: | ||
note: See Opcode 0x22 for important notes on DWORD instructions. | note: See Opcode 0x22 for important notes on DWORD instructions. | ||
- | === Opcode 0x2D (45): Shift Right DWORD === | + | === Opcode 0x2D (45): Shift Right DWORD (shr) === |
stack input: small/big int a (next to top); small/big int count (top of stack) | stack input: small/big int a (next to top); small/big int count (top of stack) | ||
Line 330: | Line 330: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x2E (46): Compare DWORDs for Less === | + | === Opcode 0x2E (46): Compare DWORDs for Less (cmp) === |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 337: | Line 337: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x2F (47): Compare DWORDs for Greater === | + | === Opcode 0x2F (47): Compare DWORDs for Greater |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 346: | Line 346: | ||
===== Opcodes 30..3F ===== | ===== Opcodes 30..3F ===== | ||
- | === Opcode 0x30 (48): Compare DWORDs for Equality === | + | === Opcode 0x30 (48): Compare DWORDs for Equality |
stack input: small/big int a (next to top); small/big int b (top of stack) | stack input: small/big int a (next to top); small/big int b (top of stack) | ||
Line 353: | Line 353: | ||
note: See Opcode 22 for important notes on DWORD instructions. | note: See Opcode 22 for important notes on DWORD instructions. | ||
- | === Opcode 0x31 (49): Execute === | + | === Opcode 0x31 (49): Execute |
stack input: binary blob containing bytecode | stack input: binary blob containing bytecode | ||
Line 362: | Line 362: | ||
PostScript equivalent: " | PostScript equivalent: " | ||
- | === Opcode 0x32 (50): If/Else === | + | === Opcode 0x32 (50): If/ |
stack input: selector (smallint at second to top of stack), blob for the true case (next to top), blob for the false case (top of stack) | stack input: selector (smallint at second to top of stack), blob for the true case (next to top), blob for the false case (top of stack) | ||
effect: if the selector is not zero, the true blob is executed (as in Opcode 31), otherwise the false blob is executed. | effect: if the selector is not zero, the true blob is executed (as in Opcode 31), otherwise the false blob is executed. | ||
- | === Opcode 0x33 (51): While === | + | === Opcode 0x33 (51): While (while) |
stack input: condition flag (smallint) | stack input: condition flag (smallint) | ||
Line 376: | Line 376: | ||
note: The blob reference on the alternate stack is **not** removed by this instruction, | note: The blob reference on the alternate stack is **not** removed by this instruction, | ||
- | === Opcode 0x34 (52): Push to alternate stack === | + | === Opcode 0x34 (52): Push to alternate stack (toalt) |
stack input: value of any type | stack input: value of any type | ||
Line 383: | Line 383: | ||
effect: The value is moved from the standard stack to the alternate stack | effect: The value is moved from the standard stack to the alternate stack | ||
- | === Opcode 0x35 (53): Pop from alternate stack === | + | === Opcode 0x35 (53): Pop from alternate stack (fromalt) |
**alternate** stack input: value of any type | **alternate** stack input: value of any type | ||
Line 390: | Line 390: | ||
effect: The value is moved from the alternate stack to the standard stack | effect: The value is moved from the alternate stack to the standard stack | ||
- | === Opcode 0x36 (54): Peek alternate stack === | + | === Opcode 0x36 (54): Peek alternate stack (peekalt) |
**alternate** stack input: value of any type (not removed by this instruction) | **alternate** stack input: value of any type (not removed by this instruction) | ||
Line 397: | Line 397: | ||
effect: The value is **copied** from the alternate stack to the standard stack | effect: The value is **copied** from the alternate stack to the standard stack | ||
- | === Opcode 0x37 (55): Push 0 === | + | === Opcode 0x37 (55): Push 0 (0) === |
stack output: smallint containing 0 | stack output: smallint containing 0 | ||
- | === Opcode 0x38 (56): Push 1 === | + | === Opcode 0x38 (56): Push 1 (1) === |
stack output: smallint containing 1 | stack output: smallint containing 1 | ||
- | === Opcode 0x39 (57): Push 2 === | + | === Opcode 0x39 (57): Push 2 (2) === |
stack output: smallint containing 2 | stack output: smallint containing 2 | ||
- | === Opcode 0x3A (58): Push 3 === | + | === Opcode 0x3A (58): Push 3 (3) === |
stack output: smallint containing 3 | stack output: smallint containing 3 | ||
- | === Opcode 0x3B (59): Push 4 === | + | === Opcode 0x3B (59): Push 4 (4) === |
stack output: smallint containing 4 | stack output: smallint containing 4 | ||
- | === Opcode 0x3C (60): Push 5 === | + | === Opcode 0x3C (60): Push 5 (5) === |
stack output: smallint containing 5 | stack output: smallint containing 5 | ||
- | === Opcode 0x3D (61): Push 6 === | + | === Opcode 0x3D (61): Push 6 (6) === |
stack output: smallint containing 6 | stack output: smallint containing 6 | ||
- | === Opcode 0x3E (62): Push 7 === | + | === Opcode 0x3E (62): Push 7 (7) === |
stack output: smallint containing 7 | stack output: smallint containing 7 | ||
- | === Opcode 0x3F (63): Push 8 === | + | === Opcode 0x3F (63): Push 8 (8) === |
stack output: smallint containing 8 | stack output: smallint containing 8 | ||
===== Opcodes 40..4F ===== | ===== Opcodes 40..4F ===== | ||
- | === Opcode 0x40: Push 9 === | + | === Opcode 0x40 (64): Push 9 === |
stack output: smallint containing 9 | stack output: smallint containing 9 | ||
- | === Opcode 0x41: Push -1 === | + | === Opcode 0x41 (65): Push -1 === |
stack output: smallint containing -1 | stack output: smallint containing -1 | ||
- | === Opcode 0x42: Push -2 === | + | === Opcode 0x42 (66): Push -2 === |
stack output: smallint containing -2 | stack output: smallint containing -2 | ||
- | === Opcode 0x43: Push -3 === | + | === Opcode 0x43 (67): Push -3 === |
stack output: smallint containing -3 | stack output: smallint containing -3 | ||
- | === Opcode 0x44: Test Small Int Positive === | + | === Opcode 0x44 (68): Test Small Int Positive === |
stack input: smallint a | stack input: smallint a | ||
stack ouput: smallint 1 if a > 0, smallint 0 else | stack ouput: smallint 1 if a > 0, smallint 0 else | ||
- | === Opcode 0x45: Test Small Int Negative === | + | === Opcode 0x45 (69): Test Small Int Negative === |
stack input: smallint a | stack input: smallint a | ||
stack ouput: smallint 1 if a < 0, smallint 0 else | stack ouput: smallint 1 if a < 0, smallint 0 else | ||
- | === Opcode 0x46: Test Small Int for Zero === | + | === Opcode 0x46 (70): Test Small Int for Zero === |
stack input: smallint a | stack input: smallint a | ||
Line 455: | Line 455: | ||
note: in contrast to Opcode 21 "Test for Small Int Zero", this opcode has undefined behaviour of the operand is not a small integer. | note: in contrast to Opcode 21 "Test for Small Int Zero", this opcode has undefined behaviour of the operand is not a small integer. | ||
- | === Opcode 0x47: Duplicate second-to-top === | + | === Opcode 0x47 (71): Duplicate second-to-top === |
effect: pushes a copy of the second-to-top (the third value if you call top-of-stack the first one) to the standard stack. | effect: pushes a copy of the second-to-top (the third value if you call top-of-stack the first one) to the standard stack. | ||
PostScript equivalent: "2 index" | PostScript equivalent: "2 index" | ||
- | === Opcode 0x48: Duplicate third-to-top === | + | === Opcode 0x48 (72): Duplicate third-to-top === |
effect: pushes a copy of the third-to-top (the fourth value if you call top-of-stack the first one) to the standard stack. | effect: pushes a copy of the third-to-top (the fourth value if you call top-of-stack the first one) to the standard stack. | ||
PostScript equivalent: "3 index" | PostScript equivalent: "3 index" | ||
- | === Opcode 0x49: Duplicate fourth-to-top === | + | === Opcode 0x49 (73): Duplicate fourth-to-top === |
effect: pushes a copy of the fourth-to-top (the 5th value if you call top-of-stack the first one) to the standard stack. | effect: pushes a copy of the fourth-to-top (the 5th value if you call top-of-stack the first one) to the standard stack. | ||
PostScript equivalent: "4 index" | PostScript equivalent: "4 index" | ||
- | === Opcode 0x4A: Duplicate 5th-to-top === | + | === Opcode 0x4A (74): Duplicate 5th-to-top === |
effect: pushes a copy of the 5th-to-top (the 6th value if you call top-of-stack the first one) to the standard stack. | effect: pushes a copy of the 5th-to-top (the 6th value if you call top-of-stack the first one) to the standard stack. | ||
PostScript equivalent: "5 index" | PostScript equivalent: "5 index" | ||
- | === Opcode 0x4B: Move Top-3 to top === | + | === Opcode 0x4B (75): Move Top-3 to top === |
effect: The value at Top-3 gets moved to top of stack, top of stack becomes top-1 and so on. | effect: The value at Top-3 gets moved to top of stack, top of stack becomes top-1 and so on. | ||
PostScript equivalent: "4 -1 roll" | PostScript equivalent: "4 -1 roll" | ||
- | === Opcode 0x4C: Move Top-4 to top === | + | === Opcode 0x4C (76): Move Top-4 to top === |
effect: The value at Top-4 gets moved to top of stack, top of stack becomes top-1 and so on. | effect: The value at Top-4 gets moved to top of stack, top of stack becomes top-1 and so on. | ||
PostScript equivalent: "5 -1 roll" | PostScript equivalent: "5 -1 roll" | ||
- | === Opcode 0x4D: Move Top-5 to top === | + | === Opcode 0x4D (77): Move Top-5 to top === |
effect: The value at Top-5 gets moved to top of stack, top of stack becomes top-1 and so on. | effect: The value at Top-5 gets moved to top of stack, top of stack becomes top-1 and so on. | ||
PostScript equivalent: "6 -1 roll" | PostScript equivalent: "6 -1 roll" | ||
- | === Opcode 0x4E: Increment Small Int === | + | === Opcode 0x4E (78): Increment Small Int === |
stack input: smallint a | stack input: smallint a | ||
stack ouput: smallint (a+1) | stack ouput: smallint (a+1) | ||
- | === Opcode 0x4F: Decrement Small Int === | + | === Opcode 0x4F (79): Decrement Small Int === |
stack input: smallint a | stack input: smallint a | ||
Line 501: | Line 501: | ||
===== Opcodes 50..5F ===== | ===== Opcodes 50..5F ===== | ||
- | === Opcode | + | === Opcode |
stack input: value //a// that is not an array | stack input: value //a// that is not an array | ||
stack output: //a// if a is numeric (smallint or bigint). If //a// is a blob, is is read as a two's complement signed big-endian number and returned in a bigint. | stack output: //a// if a is numeric (smallint or bigint). If //a// is a blob, is is read as a two's complement signed big-endian number and returned in a bigint. | ||
- | === Opcode | + | === Opcode |
stack input: value //a// that is not an array | stack input: value //a// that is not an array | ||
Line 513: | Line 513: | ||
note: Negative smallints or bigints are unchanged by this operation. Compare opcode 53 "Make operand unsigned" | note: Negative smallints or bigints are unchanged by this operation. Compare opcode 53 "Make operand unsigned" | ||
- | === Opcode | + | === Opcode |
stack input: value //a// that is not an array | stack input: value //a// that is not an array | ||
stack output: If the input is a blob, it remains unchanged. Otherwise, it is returned as two's complement big-endian number in a blob. | stack output: If the input is a blob, it remains unchanged. Otherwise, it is returned as two's complement big-endian number in a blob. | ||
- | === Opcode | + | === Opcode |
stack input: numeric value //a// | stack input: numeric value //a// | ||
stack output: A numeric value that results from interpreting the bits in //a// as unsigned number. I.e. smallints 0..32767 are returned unchanged. smallints -1..-32768 are converted to bigints 65536..32768 respsctively. Negative big-ints are sign-extended to whole bytes and the resulting value is treated as unsigned value | stack output: A numeric value that results from interpreting the bits in //a// as unsigned number. I.e. smallints 0..32767 are returned unchanged. smallints -1..-32768 are converted to bigints 65536..32768 respsctively. Negative big-ints are sign-extended to whole bytes and the resulting value is treated as unsigned value | ||
- | === Opcode | + | === Opcode |
stack input: numeric value //a// | stack input: numeric value //a// | ||
stack output: smallints stay unchanged. The low 16 bits of the absolute value are returned for bigints, so unless you know what you are doing, only use this instruction for the range 0..32767 | stack output: smallints stay unchanged. The low 16 bits of the absolute value are returned for bigints, so unless you know what you are doing, only use this instruction for the range 0..32767 | ||
- | === Opcode | + | === Opcode |
stack input: //n// value of any type; smallint //n// (at top of stack) | stack input: //n// value of any type; smallint //n// (at top of stack) | ||
stack output: (reference to) a newly created array containing the //n// elements from the stack below the count itself | stack output: (reference to) a newly created array containing the //n// elements from the stack below the count itself | ||
- | === Opcode | + | === Opcode |
stack input: an array of //n// elements | stack input: an array of //n// elements | ||
stack output: //n// values of any type (the array element); smallint //n// (count of elements; at top of stack) | stack output: //n// values of any type (the array element); smallint //n// (count of elements; at top of stack) | ||
- | === Opcode | + | === Opcode |
stack input: an array with //n// elements | stack input: an array with //n// elements | ||
stack output: smallint //n// | stack output: smallint //n// | ||
- | === Opcode | + | === Opcode |
stack input: //entry// (any type, second to top); an array (next to top); //index// (small or big int at top of stack) | stack input: //entry// (any type, second to top); an array (next to top); //index// (small or big int at top of stack) | ||
stack output: A (reference to a) copy of the array with the new element //entry// inserted before the // | stack output: A (reference to a) copy of the array with the new element //entry// inserted before the // | ||
- | === Opcode | + | === Opcode |
stack input: an array (next to top); //index// (small or big int at top of stack) | stack input: an array (next to top); //index// (small or big int at top of stack) | ||
stack output: A (reference to a) copy of the array with the element at position //index// removed (and all further elements moved one position to the front) | stack output: A (reference to a) copy of the array with the element at position //index// removed (and all further elements moved one position to the front) | ||
- | === Opcode | + | === Opcode |
stack input: (reference to) an array (next to top); smallint //k// (top of stack) | stack input: (reference to) an array (next to top); smallint //k// (top of stack) | ||
stack output: The // | stack output: The // | ||
- | === Opcode | + | === Opcode |
stack input: value //x// of any type (second to top); (reference to) an array (next to top); smallint //k// (at top) | stack input: value //x// of any type (second to top); (reference to) an array (next to top); smallint //k// (at top) | ||
Line 567: | Line 567: | ||
note: This operation does **not** copy the array, so the element changes globally. | note: This operation does **not** copy the array, so the element changes globally. | ||
- | === Opcode | + | === Opcode |
stack input: //n// (smallint at top of stack) | stack input: //n// (smallint at top of stack) | ||
stack output: A newly allocated array of //n// elements. All elements are initialized with smallint zero. | stack output: A newly allocated array of //n// elements. All elements are initialized with smallint zero. | ||
- | === Opcode | + | === Opcode |
stack input: value to encode (any type) | stack input: value to encode (any type) | ||
Line 582: | Line 582: | ||
* arrays are encoded as SEQUENCE (ASN.1 tag 0x30), the sequence is always encoded as unknown-length and double-zero-terminated. | * arrays are encoded as SEQUENCE (ASN.1 tag 0x30), the sequence is always encoded as unknown-length and double-zero-terminated. | ||
- | === Opcode | + | === Opcode |
stack input: //n// blobs (should contain ASN.1 encoded data, first element pushed first, last element next-to-top); | stack input: //n// blobs (should contain ASN.1 encoded data, first element pushed first, last element next-to-top); | ||
Line 589: | Line 589: | ||
note: The output is just 0x30 (SEQUENCE); 0x80 (unknown length); catenation of all blobs; 0x00; 0x00 | note: The output is just 0x30 (SEQUENCE); 0x80 (unknown length); catenation of all blobs; 0x00; 0x00 | ||
- | === Opcode | + | === Opcode |
stack input: a blob containing an ASN.1 encoded object. | stack input: a blob containing an ASN.1 encoded object. | ||
Line 604: | Line 604: | ||
===== Opcodes 60..6F ===== | ===== Opcodes 60..6F ===== | ||
- | === Opcode 0x60: Enclose Smallint === | + | === Opcode 0x60 (96): Enclose Smallint === |
stack input: A smallint | stack input: A smallint | ||
Line 611: | Line 611: | ||
Note: the blob that gets returned is non-refcounted and lives until explicit destruction (for example by opcode 08) | Note: the blob that gets returned is non-refcounted and lives until explicit destruction (for example by opcode 08) | ||
- | === Opcode 0x61: Get Enclosed Smallint === | + | === Opcode 0x61 (97): Get Enclosed Smallint === |
stack input: A blob that encloses a small integer, created by opcode 60 | stack input: A blob that encloses a small integer, created by opcode 60 | ||
stack output: The enclosed small integer | stack output: The enclosed small integer | ||
- | === Opcode 0x62: Get Significant Bits === | + | === Opcode 0x62 (98): Get Significant Bits === |
stack input: Object of any type | stack input: Object of any type | ||
stack ouput: Significant bit in that object. For smallints and bigints its the minimal number of bits to represent the absolute value of that number, for blobs the number of bytes multiplied by 8 and for arrays the sum of the number of significant bits of all entries. | stack ouput: Significant bit in that object. For smallints and bigints its the minimal number of bits to represent the absolute value of that number, for blobs the number of bytes multiplied by 8 and for arrays the sum of the number of significant bits of all entries. | ||
- | === Opcode 0x63: Immediate Crypted Byte === | + | === Opcode 0x63 (99): Immediate Crypted Byte === |
immediate data: 1 byte (encrypted if OCM code encryption is enabled) | immediate data: 1 byte (encrypted if OCM code encryption is enabled) | ||
Line 628: | Line 628: | ||
note: Is often used to refer to the dictionary index where the data is stored. | note: Is often used to refer to the dictionary index where the data is stored. | ||
- | === Opcode 0x64: Immediate Crypted Word === | + | === Opcode 0x64 (100): Immediate Crypted Word === |
immediate data: 1 16-bit-word (encrypted if OCM code encryption is enabled) | immediate data: 1 16-bit-word (encrypted if OCM code encryption is enabled) | ||
effect: pushes the signed 16 bit value of the immediate operand to the stack as small number | effect: pushes the signed 16 bit value of the immediate operand to the stack as small number | ||
- | === Opcode 0x65: Immediate Crypted BigInt === | + | === Opcode 0x65 (101): Immediate Crypted BigInt === |
immediate data: 1 big int (encrypted if OCM code encryption is enabled) | immediate data: 1 big int (encrypted if OCM code encryption is enabled) | ||
Line 640: | Line 640: | ||
note: If the OCM module uses the DWORD-based decryptor (it doesn' | note: If the OCM module uses the DWORD-based decryptor (it doesn' | ||
- | === Opcode 0x66: Immediate Crypted Blob === | + | === Opcode 0x66 (102): Immediate Crypted Blob === |
immediate data: 1 blob (encrypted if OCM code encryption is enabled) | immediate data: 1 blob (encrypted if OCM code encryption is enabled) | ||
Line 681: | Line 681: | ||
note: This opcode does only make sense in subthreads. | note: This opcode does only make sense in subthreads. | ||
- | === Opcode 0x6D: gettimeofday === | + | === Opcode 0x6D (109): gettimeofday === |
stack output: seconds since midnight (tv_sec) as bigint (next to top); microseconds within current second (tv_usec) as bigint (top of stack) | stack output: seconds since midnight (tv_sec) as bigint (next to top); microseconds within current second (tv_usec) as bigint (top of stack) | ||
- | === Opcode 0x6E: mktime === | + | === Opcode 0x6E (110): mktime === |
stack input: 6 smallint or bigint values in the following order: seconds, minutes, hours, day (1-based), month (0-based), year (top of stack) | stack input: 6 smallint or bigint values in the following order: seconds, minutes, hours, day (1-based), month (0-based), year (top of stack) | ||
stack output: the corresponding unix timestamp | stack output: the corresponding unix timestamp | ||
- | === Opcode 0x6F: localtime === | + | === Opcode 0x6F (111): localtime === |
stack input: a small/big int containing a unix timestamp | stack input: a small/big int containing a unix timestamp | ||
Line 695: | Line 695: | ||
===== Opcodes 70..7F ===== | ===== Opcodes 70..7F ===== | ||
- | === Opcode | + | === Opcode |
stack input: object of any type | stack input: object of any type | ||
stack output: The type tag of that object (see top of the page) | stack output: The type tag of that object (see top of the page) | ||
- | === Opcode 0x71 (113): Get Random Number === | + | === Opcode 0x71 (113): Get Random Number |
stack input: smallint //n// of values to skip | stack input: smallint //n// of values to skip | ||
stack output: The number generated by the user RNG after skipping //n// values. | stack output: The number generated by the user RNG after skipping //n// values. | ||
- | === Opcode 0x72 (114): Set User RNG Autoskip === | + | === Opcode 0x72 (114): Set User RNG Autoskip |
stack input: smallint //n// | stack input: smallint //n// | ||
effect: Enables autoskipping, | effect: Enables autoskipping, | ||
- | === Opcode 0x73 (115): Seed and Enable Stream Decryptor === | + | === Opcode 0x73 (115): Seed and Enable Stream Decryptor |
stack input: smallint //n// as 16 bit seed value. | stack input: smallint //n// as 16 bit seed value. | ||
Line 717: | Line 717: | ||
note: This will indicate that the following bytes are encrypted. | note: This will indicate that the following bytes are encrypted. | ||
- | === Opcode 0x74 (116): Load Stream Decryptor Table === | + | === Opcode 0x74 (116): Load Stream Decryptor Table (decrypttable) |
stack input: A reference to a block of bytes. The size must be a power of 2 | stack input: A reference to a block of bytes. The size must be a power of 2 | ||
effect: Replaces the standard table in the Stream PRNG by the one given as parameter | effect: Replaces the standard table in the Stream PRNG by the one given as parameter | ||
- | === Opcode 0x75 (117): Load Native Module === | + | === Opcode 0x75 (117): Load Native Module |
stack input: A blob containing a (possibly compressed) module of native code | stack input: A blob containing a (possibly compressed) module of native code | ||
Line 729: | Line 729: | ||
effect: The contents of that blob gets loaded into the virtual machine. The first 0x60 bytes of the blob are a header for the module that, amongst other things, contains the name of the module which is used to identify it. The module is decompressed, | effect: The contents of that blob gets loaded into the virtual machine. The first 0x60 bytes of the blob are a header for the module that, amongst other things, contains the name of the module which is used to identify it. The module is decompressed, | ||
- | === Opcode 0x76 (118): Unload native module === | + | === Opcode 0x76 (118): Unload native module |
stack input: A module handle (as smallint) | stack input: A module handle (as smallint) | ||
Line 736: | Line 736: | ||
effect: Unloads the given native module. If it is not named " | effect: Unloads the given native module. If it is not named " | ||
- | === Opcode 0x77 (119): Call a native module === | + | === Opcode 0x77 (119): Call a native module |
stack input: args for the native module (type(s) module specific); module handle (smallint at top) | stack input: args for the native module (type(s) module specific); module handle (smallint at top) | ||
Line 743: | Line 743: | ||
effect: Runs the native code associated with the given module handle. It removes the module handle from the stack before running that module. The module itself can do to the stack whatever it wants. | effect: Runs the native code associated with the given module handle. It removes the module handle from the stack before running that module. The module itself can do to the stack whatever it wants. | ||
- | === Opcode 0x78 (120): Run Unloaded Native Module === | + | === Opcode 0x78 (120): Run Unloaded Native Module |
stack input: possible module args; a blob containing a non-compressed module (at top; like for Opcode 75) | stack input: possible module args; a blob containing a non-compressed module (at top; like for Opcode 75) | ||
Line 750: | Line 750: | ||
effect: Executes the native code from the blob given as parameter. The blob is relocated and exports are loaded (unless it is a " | effect: Executes the native code from the blob given as parameter. The blob is relocated and exports are loaded (unless it is a " | ||
- | === Opcode 0x79 (121): Get Module Name === | + | === Opcode 0x79 (121): Get Module Name (modname) |
stack input: module handle (as smallint) | stack input: module handle (as smallint) | ||
stack ouput: blob containing name of that module | stack ouput: blob containing name of that module | ||
- | === Opcode 0x7A (122): Get Module Handle === | + | === Opcode 0x7A (122): Get Module Handle |
stack input: blob containing of module name | stack input: blob containing of module name | ||
stack ouput: smallint containing module handle | stack ouput: smallint containing module handle | ||
- | === Opcode 0x7B (123): Create Module For Blob === | + | === Opcode 0x7B (123): Create Module For Blob (modcreate) |
stack input: module name (blob next to top); module contents (blob at top) | stack input: module name (blob next to top); module contents (blob at top) | ||
Line 767: | Line 767: | ||
Creates an entry in the module list that references the address range of the blob. | Creates an entry in the module list that references the address range of the blob. | ||
- | === Opcode 0x7C (124): Create Bytecode Module === | + | === Opcode 0x7C (124): Create Bytecode Module |
stack input: module contents (blob); module name (blob at top, optional) | stack input: module contents (blob); module name (blob at top, optional) | ||
Line 774: | Line 774: | ||
Copies the blob contents into the interpreter as bytecode module. If top of stack is <= 8 chars, it is treated as a name. Otherwise the standard name " | Copies the blob contents into the interpreter as bytecode module. If top of stack is <= 8 chars, it is treated as a name. Otherwise the standard name " | ||
- | === Opcode 0x7D (125): Run OCM Module === | + | === Opcode 0x7D (125): Run OCM Module |
stack input: smallint containing module handle. | stack input: smallint containing module handle. | ||
Line 786: | Line 786: | ||
| | ||
- | === Opcode 0x7E (126): Seed User RNG === | + | === Opcode 0x7E (126): Seed User RNG (rng.seed) |
stack input: smallint; blob (at top of stack) | stack input: smallint; blob (at top of stack) | ||
ocmbytecode.txt · Last modified: 2023/04/23 15:05 by nopsled