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:19] – [Opcodes 10..1F] nopsledocmbytecode [2023/04/13 16:20] – [Opcodes 30..3F] 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 367: Line 367:
 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, just the condition flag on the standard stack. note: The blob reference on the alternate stack is **not** removed by this instruction, just the condition flag on the standard stack.
  
-=== 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
  
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