The architecture of the virtual processor is quite simple-it has a few registers that store the current execution state:
Register Name | Register function |
register_a | An 8-bit general purpose register. The register is accessible to the VM code. |
register_b | An 8-bit general purpose register. The register is accessible to the VM code. |
register_key | An 8-bit register. This holds the encryption key byte. |
register_cnt | An 8-bit register. This holds the counter for vm_loop instruction. The register is accessible to VM code. |
data_base | A 32-bit (64-bit for the long mode) register. This holds the address of the data to be encrypted. |
data_length | A 32-bit register. This holds the length of the data to be encrypted (only 8 bits are used, so the data cannot be longer than 256 bytes). |
The virtual processor has a very limited instruction set, but they are not encoded sequentially:
Opcode | Mnemonic |
Meaning |
0x00 | vm_load_key |
This loads the key parameter of the VM procedure into the key register of the virtual processor. |
0x01 | vm_nop |
This is the NOP instruction. No operation is performed. |
0x02 | vm_load_data_length |
This loads the length of the string to be encrypted into the data length register of the virtual processor. |
0x10 | vm_loop target |
This jumps to target if the counter register is less than the data length register. |
0x11 | vm_jump target |
This unconditionally jumps to the target address. |
0x12 | vm_exit |
This notifies the virtual processor that it should stop. |
0x20 | vm_encrypt regId |
Performs the XOR operation on the content of register[regId] with the content of the key register. |
0x21 | vm_decrement regId |
This decrements the content of register[regId]. |
0x22 | vm_increment regId |
This increments the content of register[regId]. |
0x30 | vm_load_data_byte regId |
Load byte from data_base_address + counter_register into register[regId]. |
0x31 | vm_store_data_byte regId |
Store byte from register[regId] to data_base_address + counter_register. |