Instruction Format Classes#
- class pairipcore.insn.InsnFormat[source]#
- A: int#
- B: int#
- C: int#
- D: int#
- E: int#
- __init__(info_off: int, stack_vars: int = 0, extra_vars: int = 0, storage_var: str | None = None) None [source]#
- Parameters:
info_off (int)
stack_vars (int)
extra_vars (int)
storage_var (str | None)
- Return type:
None
- static parse(format_id: str) InsnFormat [source]#
Parses a format ID string to create an InsnFormat object.
- Parameters:
format_id (str) – A string representing the instruction format.
- Returns:
The corresponding InsnFormat object.
- Return type:
- Raises:
ValueError – If the format ID is empty.
- property next_addr_off: int#
Calculates the offset for the next instruction address.
- property fallback_addr_off: int#
Calculates the offset for the fallback instruction address.
- property hash_off: int#
Calculates the offset for the hash value.
- property hash_xor_value_off: int#
Calculates the offset for the XOR value used in the hash.
- property hash_data_off: int#
Calculates the offset for the hash data.
- property hash_data_length_off: int#
Calculates the offset for the length of the hash data.
- Returns:
The offset for the length of the hash data.
- Return type:
int
- property store_var_off: int#
Returns the offset of the storage variable.
- Returns:
The offset of the storage variable.
- Return type:
int
- vars() dict[str, int] [source]#
Returns the offsets of each stack variable.
- Returns:
A dictionary mapping variable names (A, B, C, etc.) to their offsets.
- Return type:
dict[str, int]
- property stack_vars: int#
- property extra_vars: int#
- class pairipcore.insn.InsnInfo[source]#
Represents the metadata and control flow information associated with a particular instruction in the VM.
- __init__(vm: VM, insn_format: InsnFormat) None [source]#
- Parameters:
vm (VM)
insn_format (InsnFormat)
- Return type:
None
- property hash: int#
Returns the expected hash value for verification.
- property hash_data_addr: addr_t#
Returns the memory address where the data to be hashed is located.
- property hash_data_length: int#
Returns the length of the data to be hashed.
- property xor_value_addr: addr_t#
Returns the memory address of the XOR value used in the hash calculation.
- property fallback: addr_t#
Returns the address of the fallback instruction if the hash verification fails.
- property next: addr_t#
Returns the address of the next instruction to execute if the hash verification succeeds.
- class pairipcore.insn.Insn[source]#
Represents an instruction in the virtual machine, including its format, address, and associated metadata.
- A: addr_t#
- B: addr_t#
- C: addr_t#
- D: addr_t#
- E: addr_t#
- R: addr_t#
Address where the result of the instruction is stored.
- __init__(vm: VM, insn_format: InsnFormat) None [source]#
- Parameters:
vm (VM)
insn_format (InsnFormat)
- Return type:
None
- property address: addr_t#
Returns the address of this instruction (excluding the opcode).
- property opcode_address: addr_t#
Returns the address where the opcode for this instruction is located.
- property insn_format: InsnFormat#
Returns the format of this instruction.
- pairipcore.insn.O(name: str, opcode: int, format_id: str) int [source]#
Registers an opcode with its corresponding format and name.
This function associates an opcode with a specific instruction format (represented by the format ID) and a mnemonic name. The format and name are stored in the
FormatIDs
andOpcodeIDs
dictionaries, respectively.- Parameters:
name (str) – The mnemonic name of the opcode. If the name is
"_"
, it will be auto-generated based on the format ID.opcode (int) – The numeric opcode to be registered.
format_id (str) – The format ID string that describes the structure of the instruction.
- Returns:
The opcode that was registered.
- Return type:
int