User Tools

Site Tools


ocmbytecode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
ocmbytecode [2023/04/13 15:16] – [Opcodes 40..4F] nopsledocmbytecode [2023/04/13 16:16] – [Opcodes 00..0F] nopsled
Line 69: Line 69:
  
 ===== Opcodes 00..0F ===== ===== Opcodes 00..0F =====
-=== Opcode 00: NOP ====+=== Opcode 0x00: NOP ====
 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 501: Line 501:
  
 ===== Opcodes 50..5F ===== ===== Opcodes 50..5F =====
-=== Opcode 50: Convert to signed number ===+=== Opcode 0x50 (80): Convert to signed number ===
 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 51: Convert to unsigned number ===+=== Opcode 0x51 (81): Convert to unsigned number ===
 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 52: Make blob ===+=== Opcode 0x52 (82): Make blob ===
 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 53: Make operand unsigned ===+=== Opcode 0x53 (83): Make operand unsigned ===
 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 54: Truncate to Small Int ===+=== Opcode 0x54 (84): Truncate to Small Int ===
 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 55: Pack to Array ===+=== Opcode 0x55 (85): Pack to Array ===
 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 56: Unpack Array ===+=== Opcode 0x56 (86): Unpack Array ===
 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 57: Array Length ===+=== Opcode 0x57 (87): Array Length ===
 stack input: an array with //n// elements stack input: an array with //n// elements
  
 stack output: smallint //n// stack output: smallint //n//
  
-=== Opcode 58: Insert to Array ===+=== Opcode 0x58 (88): Insert to Array ===
 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 //index//'th element (moving all elements after the inserted one position to the end of the array) stack output: A (reference to a) copy of the array with the new element //entry// inserted before the //index//'th element (moving all elements after the inserted one position to the end of the array)
  
-=== Opcode 59: Delete from Array ===+=== Opcode 0x59 (89): Delete from Array ===
 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 5A: Get Array Element ===+=== Opcode 0x5A (90): Get Array Element ===
 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 //k//'th element of the array. stack output: The //k//'th element of the array.
  
-=== Opcode 5B: Set Array Element ===+=== Opcode 0x5B (91): Set Array Element ===
 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 5C: Create Array ===+=== Opcode 0x5C (92): Create Array ===
 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 5D: Encode ASN.1 ===+=== Opcode 0x5D (93): Encode ASN.1 ===
 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 5E: Catenate to Sequence ===+=== Opcode 0x5E (94): Catenate to Sequence ===
 stack input: //n// blobs (should contain ASN.1 encoded data, first element pushed first, last element next-to-top); //n// (smallint at top of stack) stack input: //n// blobs (should contain ASN.1 encoded data, first element pushed first, last element next-to-top); //n// (smallint at top of stack)
  
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 5F: Decode ASN.1 ===+=== Opcode 0x5F (95): Decode ASN.1 ===
 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't start with 03 01 in that case, we did not encounter such a module yet), it is important to know that the immediate arg is decrypted in three parts: (1) initial length byte, (2) extra length bytes, optional, (3) data bytes. note: If the OCM module uses the DWORD-based decryptor (it doesn't start with 03 01 in that case, we did not encounter such a module yet), it is important to know that the immediate arg is decrypted in three parts: (1) initial length byte, (2) extra length bytes, optional, (3) data bytes.
  
-=== 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
  
ocmbytecode.txt · Last modified: 2023/04/23 15:05 by nopsled

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki