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 16:12] – [Opcodes 50..5F] nopsledocmbytecode [2023/04/14 08:38] – [Opcodes 70..7F] 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 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
  
Line 695: Line 695:
  
 ===== Opcodes 70..7F ===== ===== Opcodes 70..7F =====
-=== Opcode 70 (112): Get Type ===+=== Opcode 0x70 (112): Get Type (type) ===
 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 (rng.skipget) ===
 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 (rng.autoskip) ===
 stack input: smallint //n// stack input: smallint //n//
  
 effect: Enables autoskipping, i.e. advancing the user RNG by //n// for every opcode executed. //n//==0 disables it. effect: Enables autoskipping, i.e. advancing the user RNG by //n// for every opcode executed. //n//==0 disables it.
  
-=== Opcode 0x73 (115): Seed and Enable Stream Decryptor ===+=== Opcode 0x73 (115): Seed and Enable Stream Decryptor (decryptseed) ===
 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 (natmod) ===
 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, relocated and the exported names are put into the salwrap global exports table (unless the module is named "bc", in that case, exports are not yet loaded) 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, relocated and the exported names are put into the salwrap global exports table (unless the module is named "bc", in that case, exports are not yet loaded)
  
-=== Opcode 0x76 (118): Unload native module ===+=== Opcode 0x76 (118): Unload native module (addexports) ===
 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 "bc", the exports are removed from the global symbol table before unloading the module. effect: Unloads the given native module. If it is not named "bc", the exports are removed from the global symbol table before unloading the module.
  
-=== Opcode 0x77 (119): Call a native module ===+=== Opcode 0x77 (119): Call a native module (callmod) ===
 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 (callblobmod) ===
 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 "bc" named blob). As the blob is non-permanent, there better are no exports. The entrypoint is finally called (Like Opcode 77 does for a loaded module) effect: Executes the native code from the blob given as parameter. The blob is relocated and exports are loaded (unless it is a "bc" named blob). As the blob is non-permanent, there better are no exports. The entrypoint is finally called (Like Opcode 77 does for a loaded module)
  
-=== 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 (modhnd) ===
 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 (bcmodcreate) ===
 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 "bc" is used instead. 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 "bc" is used instead.
  
-=== Opcode 0x7D (125): Run OCM Module ===+=== Opcode 0x7D (125): Run OCM Module (bcmodcall) ===
 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

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki