Skip to main content

Cell Primitives

TVM Instructions Content List

OpcodeFift syntaxStackDescriptionGas
Please enter a search query
No results found

Cell Primitives

Cell serialization primitives

xxxxxxx
Opcode
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Fift syntax
xxxxxxxxxxxxxxxxx
Stack
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Description
xxxx
Gas
C8NEWC- bCreates a new empty Builder.18
C9ENDCb - cConverts a Builder into an ordinary Cell.518
CAcc[cc+1] STIx b - b'Stores a signed cc+1-bit integer x into Builder b for 0 <= cc <= 255, throws a range check exception if x does not fit into cc+1 bits.26
CBcc[cc+1] STUx b - b'Stores an unsigned cc+1-bit integer x into Builder b. In all other respects it is similar to STI.26
CCSTREFc b - b'Stores a reference to Cell c into Builder b.18
CDSTBREFR
ENDCST
b b'' - bEquivalent to ENDC SWAP STREF.518
CESTSLICEs b - b'Stores Slice s into Builder b.18
CF00STIXx b l - b'Stores a signed l-bit integer x into b for 0 <= l <= 257.26
CF01STUXx b l - b'Stores an unsigned l-bit integer x into b for 0 <= l <= 256.26
CF02STIXRb x l - b'Similar to STIX, but with arguments in a different order.26
CF03STUXRb x l - b'Similar to STUX, but with arguments in a different order.26
CF04STIXQx b l - x b f or b' 0A quiet version of STIX. If there is no space in b, sets b'=b and f=-1.
If x does not fit into l bits, sets b'=b and f=1.
If the operation succeeds, b' is the new Builder and f=0.
However, 0 <= l <= 257, with a range check exception if this is not so.
26
CF05STUXQx b l - x b f or b' 0A quiet version of STUX.26
CF06STIXRQb x l - b x f or b' 0A quiet version of STIXR.26
CF07STUXRQb x l - b x f or b' 0A quiet version of STUXR.26
CF08cc[cc+1] STI_lx b - b'A longer version of [cc+1] STI.34
CF09cc[cc+1] STU_lx b - b'A longer version of [cc+1] STU.34
CF0Acc[cc+1] STIRb x - b'Equivalent to SWAP [cc+1] STI.34
CF0Bcc[cc+1] STURb x - b'Equivalent to SWAP [cc+1] STU.34
CF0Ccc[cc+1] STIQx b - x b f or b' 0A quiet version of STI.34
CF0Dcc[cc+1] STUQx b - x b f or b' 0A quiet version of STU.34
CF0Ecc[cc+1] STIRQb x - b x f or b' 0A quiet version of STIR.34
CF0Fcc[cc+1] STURQb x - b x f or b' 0A quiet version of STUR.34
CF10STREF_lc b - b'A longer version of STREF.26
CF11STBREFb' b - b''Equivalent to SWAP STBREFR.526
CF12STSLICE_ls b - b'A longer version of STSLICE.26
CF13STBb' b - b''Appends all data from Builder b' to Builder b.26
CF14STREFRb c - b'Equivalent to SWAP STREF.26
CF15STBREFR_lb b' - b''A longer encoding of STBREFR.526
CF16STSLICERb s - b'Equivalent to SWAP STSLICE.26
CF17STBR
BCONCAT
b b' - b''Concatenates two builders.
Equivalent to SWAP STB.
26
CF18STREFQc b - c b -1 or b' 0Quiet version of STREF.26
CF19STBREFQb' b - b' b -1 or b'' 0Quiet version of STBREF.526
CF1ASTSLICEQs b - s b -1 or b' 0Quiet version of STSLICE.26
CF1BSTBQb' b - b' b -1 or b'' 0Quiet version of STB.26
CF1CSTREFRQb c - b c -1 or b' 0Quiet version of STREFR.26
CF1DSTBREFRQb b' - b b' -1 or b'' 0Quiet version of STBREFR.526
CF1ESTSLICERQb s - b s -1 or b'' 0Quiet version of STSLICER.26
CF1FSTBRQ
BCONCATQ
b b' - b b' -1 or b'' 0Quiet version of STBR.26
CF20[ref] STREFCONSTb - b’Equivalent to PUSHREF STREFR.26
CF21[ref] [ref] STREF2CONSTb - b’Equivalent to STREFCONST STREFCONST.26
CF23b x - cIf x!=0, creates a special or exotic cell from Builder b.
The type of the exotic cell must be stored in the first 8 bits of b.
If x=0, it is equivalent to ENDC. Otherwise some validity checks on the data and references of b are performed before creating the exotic cell.
526
CF28STILE4x b - b'Stores a little-endian signed 32-bit integer.26
CF29STULE4x b - b'Stores a little-endian unsigned 32-bit integer.26
CF2ASTILE8x b - b'Stores a little-endian signed 64-bit integer.26
CF2BSTULE8x b - b'Stores a little-endian unsigned 64-bit integer.26
CF30BDEPTHb - xReturns the depth of Builder b. If no cell references are stored in b, then x=0; otherwise x is one plus the maximum of depths of cells referred to from b.26
CF31BBITSb - xReturns the number of data bits already stored in Builder b.26
CF32BREFSb - yReturns the number of cell references already stored in b.26
CF33BBITREFSb - x yReturns the numbers of both data bits and cell references in b.26
CF35BREMBITSb - x'Returns the number of data bits that can still be stored in b.26
CF36BREMREFSb - y'Returns the number of references that can still be stored in b.26
CF37BREMBITREFSb - x' y'Returns the numbers of both data bits and references that can still be stored in b.26
CF38cc[cc+1] BCHKBITS#b -Checks whether cc+1 bits can be stored into b, where 0 <= cc <= 255.34/84
CF39BCHKBITSb x - Checks whether x bits can be stored into b, 0 <= x <= 1023. If there is no space for x more bits in b, or if x is not within the range 0...1023, throws an exception.26/76
CF3ABCHKREFSb y - Checks whether y references can be stored into b, 0 <= y <= 7.26/76
CF3BBCHKBITREFSb x y - Checks whether x bits and y references can be stored into b, 0 <= x <= 1023, 0 <= y <= 7.26/76
CF3Ccc[cc+1] BCHKBITSQ#b - ?Checks whether cc+1 bits can be stored into b, where 0 <= cc <= 255.34
CF3DBCHKBITSQb x - ?Checks whether x bits can be stored into b, 0 <= x <= 1023.26
CF3EBCHKREFSQb y - ?Checks whether y references can be stored into b, 0 <= y <= 7.26
CF3FBCHKBITREFSQb x y - ?Checks whether x bits and y references can be stored into b, 0 <= x <= 1023, 0 <= y <= 7.26
CF40STZEROESb n - b'Stores n binary zeroes into Builder b.26
CF41STONESb n - b'Stores n binary ones into Builder b.26
CF42STSAMEb n x - b'Stores n binary xes (0 <= x <= 1) into Builder b.26
CFC0_xysss[slice] STSLICECONSTb - b'Stores a constant subslice sss.
Details: sss consists of 0 <= x <= 3 references and up to 8y+2 data bits, with 0 <= y <= 7. Completion bit is assumed.
Note that the assembler can replace STSLICECONST with PUSHSLICE STSLICER if the slice is too big.
24
CF81STZEROb - b'Stores one binary zero.24
CF83STONEb - b'Stores one binary one.24

Cell Deserialization Primitives

xxxxxxx
Opcode
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Fift syntax
xxxxxxxxxxxxxxxxx
Stack
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Description
xxxx
Gas
D0CTOSc - sConverts a Cell into a Slice. Notice that c must be either an ordinary cell, or an exotic cell which is automatically loaded to yield an ordinary cell c', converted into a Slice afterwards.118/43
D1ENDSs - Removes a Slice s from the stack, and throws an exception if it is not empty.18/68
D2cc[cc+1] LDIs - x s'Loads (i.e., parses) a signed cc+1-bit integer x from Slice s, and returns the remainder of s as s'.26
D3cc[cc+1] LDUs - x s'Loads an unsigned cc+1-bit integer x from Slice s.26
D4LDREFs - c s'Loads a cell reference c from s.18
D5LDREFRTOSs - s' s''Equivalent to LDREF SWAP CTOS.118/43
D6cc[cc+1] LDSLICEs - s'' s'Cuts the next cc+1 bits of s into a separate Slice s''.26
D700LDIXs l - x s'Loads a signed l-bit (0 <= l <= 257) integer x from Slice s, and returns the remainder of s as s'.26
D701LDUXs l - x s'Loads an unsigned l-bit integer x from (the first l bits of) s, with 0 <= l <= 256.26
D702PLDIXs l - xPreloads a signed l-bit integer from Slice s, for 0 <= l <= 257.26
D703PLDUXs l - xPreloads an unsigned l-bit integer from s, for 0 <= l <= 256.26
D704LDIXQs l - x s' -1 or s 0Quiet version of LDIX: loads a signed l-bit integer from s similarly to LDIX, but returns a success flag, equal to -1 on success or to 0 on failure (if s does not have l bits), instead of throwing a cell underflow exception.26
D705LDUXQs l - x s' -1 or s 0Quiet version of LDUX.26
D706PLDIXQs l - x -1 or 0Quiet version of PLDIX.26
D707PLDUXQs l - x -1 or 0Quiet version of PLDUX.26
D708cc[cc+1] LDI_ls - x s'A longer encoding for LDI.34
D709cc[cc+1] LDU_ls - x s'A longer encoding for LDU.34
D70Acc[cc+1] PLDIs - xPreloads a signed cc+1-bit integer from Slice s.34
D70Bcc[cc+1] PLDUs - xPreloads an unsigned cc+1-bit integer from s.34
D70Ccc[cc+1] LDIQs - x s' -1 or s 0A quiet version of LDI.34
D70Dcc[cc+1] LDUQs - x s' -1 or s 0A quiet version of LDU.34
D70Ecc[cc+1] PLDIQs - x -1 or 0A quiet version of PLDI.34
D70Fcc[cc+1] PLDUQs - x -1 or 0A quiet version of PLDU.34
D714_c[32(c+1)] PLDUZs - s xPreloads the first 32(c+1) bits of Slice s into an unsigned integer x, for 0 <= c <= 7. If s is shorter than necessary, missing bits are assumed to be zero. This operation is intended to be used along with IFBITJMP and similar instructions.26
D718LDSLICEXs l - s'' s'Loads the first 0 <= l <= 1023 bits from Slice s into a separate Slice s'', returning the remainder of s as s'.26
D719PLDSLICEXs l - s''Returns the first 0 <= l <= 1023 bits of s as s''.26
D71ALDSLICEXQs l - s'' s' -1 or s 0A quiet version of LDSLICEX.26
D71BPLDSLICEXQs l - s' -1 or 0A quiet version of LDSLICEXQ.26
D71Ccc[cc+1] LDSLICE_ls - s'' s'A longer encoding for LDSLICE.34
D71Dcc[cc+1] PLDSLICEs - s''Returns the first 0 < cc+1 <= 256 bits of s as s''.34
D71Ecc[cc+1] LDSLICEQs - s'' s' -1 or s 0A quiet version of LDSLICE.34
D71Fcc[cc+1] PLDSLICEQs - s'' -1 or 0A quiet version of PLDSLICE.34
D720SDCUTFIRSTs l - s'Returns the first 0 <= l <= 1023 bits of s. It is equivalent to PLDSLICEX.26
D721SDSKIPFIRSTs l - s'Returns all but the first 0 <= l <= 1023 bits of s. It is equivalent to LDSLICEX NIP.26
D722SDCUTLASTs l - s'Returns the last 0 <= l <= 1023 bits of s.26
D723SDSKIPLASTs l - s'Returns all but the last 0 <= l <= 1023 bits of s.26
D724SDSUBSTRs l l' - s'Returns 0 <= l' <= 1023 bits of s starting from offset 0 <= l <= 1023, thus extracting a bit substring out of the data of s.26
D726SDBEGINSXs s' - s''Checks whether s begins with (the data bits of) s', and removes s' from s on success. On failure throws a cell deserialization exception. Primitive SDPFXREV can be considered a quiet version of SDBEGINSX.26
D727SDBEGINSXQs s' - s'' -1 or s 0A quiet version of SDBEGINSX.26
D72A_xsss[slice] SDBEGINSs - s''Checks whether s begins with constant bitstring sss of length 8x+3 (with continuation bit assumed), where 0 <= x <= 127, and removes sss from s on success.31
D72E_xsss[slice] SDBEGINSQs - s'' -1 or s 0A quiet version of SDBEGINS.31
D730SCUTFIRSTs l r - s'Returns the first 0 <= l <= 1023 bits and first 0 <= r <= 4 references of s.26
D731SSKIPFIRSTs l r - s'Returns all but the first l bits of s and r references of s.26
D732SCUTLASTs l r - s'Returns the last 0 <= l <= 1023 data bits and last 0 <= r <= 4 references of s.26
D733SSKIPLASTs l r - s'Returns all but the last l bits of s and r references of s.26
D734SUBSLICEs l r l' r' - s'Returns 0 <= l' <= 1023 bits and 0 <= r' <= 4 references from Slice s, after skipping the first 0 <= l <= 1023 bits and first 0 <= r <= 4 references.26
D736SPLITs l r - s' s''Splits the first 0 <= l <= 1023 data bits and first 0 <= r <= 4 references from s into s', returning the remainder of s as s''.26
D737SPLITQs l r - s' s'' -1 or s 0A quiet version of SPLIT.26
D739c - s ?Transforms an ordinary or exotic cell into a Slice, as if it were an ordinary cell. A flag is returned indicating whether c is exotic. If that be the case, its type can later be deserialized from the first eight bits of s.
D73Ac - c'Loads an exotic cell c and returns an ordinary cell c'. If c is already ordinary, does nothing. If c cannot be loaded, throws an exception.
D73Bc - c' -1 or c 0Loads an exotic cell c and returns an ordinary cell c'. If c is already ordinary, does nothing. If c cannot be loaded, returns 0.
D741SCHKBITSs l - Checks whether there are at least l data bits in Slice s. If this is not the case, throws a cell deserialisation (i.e., cell underflow) exception.26/76
D742SCHKREFSs r - Checks whether there are at least r references in Slice s.26/76
D743SCHKBITREFSs l r - Checks whether there are at least l data bits and r references in Slice s.26/76
D745SCHKBITSQs l - ?Checks whether there are at least l data bits in Slice s.26
D746SCHKREFSQs r - ?Checks whether there are at least r references in Slice s.26
D747SCHKBITREFSQs l r - ?Checks whether there are at least l data bits and r references in Slice s.26
D748PLDREFVARs n - cReturns the n-th cell reference of Slice s for 0 <= n <= 3.26
D749SBITSs - lReturns the number of data bits in Slice s.26
D74ASREFSs - rReturns the number of references in Slice s.26
D74BSBITREFSs - l rReturns both the number of data bits and the number of references in s.26
D74E_n[n] PLDREFIDXs - cReturns the n-th cell reference of Slice s, where 0 <= n <= 3.26
D74CPLDREFs - cPreloads the first cell reference of a Slice.26
D750LDILE4s - x s'Loads a little-endian signed 32-bit integer.26
D751LDULE4s - x s'Loads a little-endian unsigned 32-bit integer.26
D752LDILE8s - x s'Loads a little-endian signed 64-bit integer.26
D753LDULE8s - x s'Loads a little-endian unsigned 64-bit integer.26
D754PLDILE4s - xPreloads a little-endian signed 32-bit integer.26
D755PLDULE4s - xPreloads a little-endian unsigned 32-bit integer.26
D756PLDILE8s - xPreloads a little-endian signed 64-bit integer.26
D757PLDULE8s - xPreloads a little-endian unsigned 64-bit integer.26
D758LDILE4Qs - x s' -1 or s 0Quietly loads a little-endian signed 32-bit integer.26
D759LDULE4Qs - x s' -1 or s 0Quietly loads a little-endian unsigned 32-bit integer.26
D75ALDILE8Qs - x s' -1 or s 0Quietly loads a little-endian signed 64-bit integer.26
D75BLDULE8Qs - x s' -1 or s 0Quietly loads a little-endian unsigned 64-bit integer.26
D75CPLDILE4Qs - x -1 or 0Quietly preloads a little-endian signed 32-bit integer.26
D75DPLDULE4Qs - x -1 or 0Quietly preloads a little-endian unsigned 32-bit integer.26
D75EPLDILE8Qs - x -1 or 0Quietly preloads a little-endian signed 64-bit integer.26
D75FPLDULE8Qs - x -1 or 0Quietly preloads a little-endian unsigned 64-bit integer.26
D760LDZEROESs - n s'Returns the count n of leading zero bits in s, and removes these bits from s.26
D761LDONESs - n s'Returns the count n of leading one bits in s, and removes these bits from s.26
D762LDSAMEs x - n s'Returns the count n of leading bits equal to 0 <= x <= 1 in s, and removes these bits from s.26
D764SDEPTHs - xReturns the depth of Slice s. If s has no references, then x=0; otherwise x is one plus the maximum of depths of cells referred to from s.26
D765CDEPTHc - xReturns the depth of Cell c. If c has no references, then x=0; otherwise x is one plus the maximum of depths of cells referred to from c. If c is a Null instead of a Cell, returns zero.26

TVM Instructions Content List