turshi/
flags.rs

1//! Definition of some constants for easier readability of the steps.
2//! When they refer to single bit flagsets, only one constant is needed.
3
4/// Number of Cairo flags
5pub const NUM_FLAGS: usize = 16;
6/// Position of destination offset of 16 bits within instruction decomposition
7pub const POS_DST: usize = 0;
8/// Position of first operand offset of 16 bits within instruction decomposition
9pub const POS_OP0: usize = 1;
10/// Position of second operand offset of 16 bits within instruction decomposition
11pub const POS_OP1: usize = 2;
12/// Bit position of the beginning of the flags in a Cairo instruction
13pub const POS_FLAGS: usize = 48;
14
15/// Destination refers to ap register
16pub const DST_AP: u8 = 0;
17
18/// First operand refers to ap register
19pub const OP0_AP: u8 = 0;
20
21/// Second operand is double indexing
22pub const OP1_DBL: u8 = 0;
23/// Second operand is immediate value
24pub const OP1_VAL: u8 = 1;
25/// Second operand refers to fp register
26pub const OP1_FP: u8 = 2;
27/// Second operand refers to ap register
28pub const OP1_AP: u8 = 4;
29
30/// Result is a single operand
31pub const RES_ONE: u8 = 0;
32/// Result is an addition
33pub const RES_ADD: u8 = 1;
34/// Result is a multiplication
35pub const RES_MUL: u8 = 2;
36
37/// Default increase of pc by adding instruction size
38pub const PC_SIZ: u8 = 0;
39/// Update pc by an absolute jump
40pub const PC_ABS: u8 = 1;
41/// Update pc by a relative jump
42pub const PC_REL: u8 = 2;
43/// Update pc by a conditional relative jump
44pub const PC_JNZ: u8 = 4;
45
46/// Update by 2 in call instructions or zero behaviour for other instructions
47pub const AP_Z2: u8 = 0;
48/// Update ap by adding a number of positions
49pub const AP_ADD: u8 = 1;
50/// Update ap by self increment
51pub const AP_ONE: u8 = 2;
52
53/// Operation code is a jump or an increment
54pub const OPC_JMP_INC: u8 = 0;
55/// Operation code is a call
56pub const OPC_CALL: u8 = 1;
57/// Operation code is a return
58pub const OPC_RET: u8 = 2;
59/// Operation code is an assert-equal
60pub const OPC_AEQ: u8 = 4;