Cell Primitives
TVM Instructions Content List
- Overview
- Stack Manipulation
- Tuple, List and Null
- Constants and Literals
- Arithmetic Operations
- Data Comparison
- Cell Manipulation
- Continuation and Control Flow
- Exception Generation and Handling
- Dictionary Manipulation
- Application-specific Primitives
- Miscellaneous
Opcode | Fift syntax | Stack | Description | Gas |
---|---|---|---|---|
Please enter a search query | ||||
No results found |
Cell Primitives
Cell serialization primitives
xxxxxxx Opcode | xxxxxxxxxxxxxxxxxxxxxxxxxxxx Fift syntax | xxxxxxxxxxxxxxxxx Stack | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Description | xxxx Gas |
---|---|---|---|---|
C8 | NEWC | - b | Creates a new empty Builder. | 18 |
C9 | ENDC | b - c | Converts a Builder into an ordinary Cell. | 518 |
CAcc | [cc+1] STI | x 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] STU | x b - b' | Stores an unsigned cc+1 -bit integer x into Builder b . In all other respects it is similar to STI . | 26 |
CC | STREF | c b - b' | Stores a reference to Cell c into Builder b . | 18 |
CD | STBREFR ENDCST | b b'' - b | Equivalent to ENDC SWAP STREF . | 518 |
CE | STSLICE | s b - b' | Stores Slice s into Builder b . | 18 |
CF00 | STIX | x b l - b' | Stores a signed l -bit integer x into b for 0 <= l <= 257 . | 26 |
CF01 | STUX | x b l - b' | Stores an unsigned l -bit integer x into b for 0 <= l <= 256 . | 26 |
CF02 | STIXR | b x l - b' | Similar to STIX , but with arguments in a different order. | 26 |
CF03 | STUXR | b x l - b' | Similar to STUX , but with arguments in a different order. | 26 |
CF04 | STIXQ | x b l - x b f or b' 0 | A 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 |
CF05 | STUXQ | x b l - x b f or b' 0 | A quiet version of STUX . | 26 |
CF06 | STIXRQ | b x l - b x f or b' 0 | A quiet version of STIXR . | 26 |
CF07 | STUXRQ | b x l - b x f or b' 0 | A quiet version of STUXR . | 26 |
CF08cc | [cc+1] STI_l | x b - b' | A longer version of [cc+1] STI . | 34 |
CF09cc | [cc+1] STU_l | x b - b' | A longer version of [cc+1] STU . | 34 |
CF0Acc | [cc+1] STIR | b x - b' | Equivalent to SWAP [cc+1] STI . | 34 |
CF0Bcc | [cc+1] STUR | b x - b' | Equivalent to SWAP [cc+1] STU . | 34 |
CF0Ccc | [cc+1] STIQ | x b - x b f or b' 0 | A quiet version of STI . | 34 |
CF0Dcc | [cc+1] STUQ | x b - x b f or b' 0 | A quiet version of STU . | 34 |
CF0Ecc | [cc+1] STIRQ | b x - b x f or b' 0 | A quiet version of STIR . | 34 |
CF0Fcc | [cc+1] STURQ | b x - b x f or b' 0 | A quiet version of STUR . | 34 |
CF10 | STREF_l | c b - b' | A longer version of STREF . | 26 |
CF11 | STBREF | b' b - b'' | Equivalent to SWAP STBREFR . | 526 |
CF12 | STSLICE_l | s b - b' | A longer version of STSLICE . | 26 |
CF13 | STB | b' b - b'' | Appends all data from Builder b' to Builder b . | 26 |
CF14 | STREFR | b c - b' | Equivalent to SWAP STREF . | 26 |
CF15 | STBREFR_l | b b' - b'' | A longer encoding of STBREFR . | 526 |
CF16 | STSLICER | b s - b' | Equivalent to SWAP STSLICE . | 26 |
CF17 | STBR BCONCAT | b b' - b'' | Concatenates two builders. Equivalent to SWAP STB . | 26 |
CF18 | STREFQ | c b - c b -1 or b' 0 | Quiet version of STREF . | 26 |
CF19 | STBREFQ | b' b - b' b -1 or b'' 0 | Quiet version of STBREF . | 526 |
CF1A | STSLICEQ | s b - s b -1 or b' 0 | Quiet version of STSLICE . | 26 |
CF1B | STBQ | b' b - b' b -1 or b'' 0 | Quiet version of STB . | 26 |
CF1C | STREFRQ | b c - b c -1 or b' 0 | Quiet version of STREFR . | 26 |
CF1D | STBREFRQ | b b' - b b' -1 or b'' 0 | Quiet version of STBREFR . | 526 |
CF1E | STSLICERQ | b s - b s -1 or b'' 0 | Quiet version of STSLICER . | 26 |
CF1F | STBRQ BCONCATQ | b b' - b b' -1 or b'' 0 | Quiet version of STBR . | 26 |
CF20 | [ref] STREFCONST | b - b’ | Equivalent to PUSHREF STREFR . | 26 |
CF21 | [ref] [ref] STREF2CONST | b - b’ | Equivalent to STREFCONST STREFCONST . | 26 |
CF23 | b x - c | If 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 | |
CF28 | STILE4 | x b - b' | Stores a little-endian signed 32-bit integer. | 26 |
CF29 | STULE4 | x b - b' | Stores a little-endian unsigned 32-bit integer. | 26 |
CF2A | STILE8 | x b - b' | Stores a little-endian signed 64-bit integer. | 26 |
CF2B | STULE8 | x b - b' | Stores a little-endian unsigned 64-bit integer. | 26 |
CF30 | BDEPTH | b - x | Returns 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 |
CF31 | BBITS | b - x | Returns the number of data bits already stored in Builder b . | 26 |
CF32 | BREFS | b - y | Returns the number of cell references already stored in b . | 26 |
CF33 | BBITREFS | b - x y | Returns the numbers of both data bits and cell references in b . | 26 |
CF35 | BREMBITS | b - x' | Returns the number of data bits that can still be stored in b . | 26 |
CF36 | BREMREFS | b - y' | Returns the number of references that can still be stored in b . | 26 |
CF37 | BREMBITREFS | b - 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 |
CF39 | BCHKBITS | b 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 |
CF3A | BCHKREFS | b y - | Checks whether y references can be stored into b , 0 <= y <= 7 . | 26/76 |
CF3B | BCHKBITREFS | b 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 |
CF3D | BCHKBITSQ | b x - ? | Checks whether x bits can be stored into b , 0 <= x <= 1023 . | 26 |
CF3E | BCHKREFSQ | b y - ? | Checks whether y references can be stored into b , 0 <= y <= 7 . | 26 |
CF3F | BCHKBITREFSQ | b x y - ? | Checks whether x bits and y references can be stored into b , 0 <= x <= 1023 , 0 <= y <= 7 . | 26 |
CF40 | STZEROES | b n - b' | Stores n binary zeroes into Builder b . | 26 |
CF41 | STONES | b n - b' | Stores n binary ones into Builder b . | 26 |
CF42 | STSAME | b n x - b' | Stores n binary x es (0 <= x <= 1 ) into Builder b . | 26 |
CFC0_xysss | [slice] STSLICECONST | b - 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 |
CF81 | STZERO | b - b' | Stores one binary zero. | 24 |
CF83 | STONE | b - b' | Stores one binary one. | 24 |
Cell Deserialization Primitives
xxxxxxx Opcode | xxxxxxxxxxxxxxxxxxxxxxxxxxxx Fift syntax | xxxxxxxxxxxxxxxxx Stack | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Description | xxxx Gas |
---|---|---|---|---|
D0 | CTOS | c - s | Converts 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 |
D1 | ENDS | s - | Removes a Slice s from the stack, and throws an exception if it is not empty. | 18/68 |
D2cc | [cc+1] LDI | s - 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] LDU | s - x s' | Loads an unsigned cc+1 -bit integer x from Slice s . | 26 |
D4 | LDREF | s - c s' | Loads a cell reference c from s . | 18 |
D5 | LDREFRTOS | s - s' s'' | Equivalent to LDREF SWAP CTOS . | 118/43 |
D6cc | [cc+1] LDSLICE | s - s'' s' | Cuts the next cc+1 bits of s into a separate Slice s'' . | 26 |
D700 | LDIX | s 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 |
D701 | LDUX | s l - x s' | Loads an unsigned l -bit integer x from (the first l bits of) s , with 0 <= l <= 256 . | 26 |
D702 | PLDIX | s l - x | Preloads a signed l -bit integer from Slice s , for 0 <= l <= 257 . | 26 |
D703 | PLDUX | s l - x | Preloads an unsigned l -bit integer from s , for 0 <= l <= 256 . | 26 |
D704 | LDIXQ | s l - x s' -1 or s 0 | Quiet 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 |
D705 | LDUXQ | s l - x s' -1 or s 0 | Quiet version of LDUX . | 26 |
D706 | PLDIXQ | s l - x -1 or 0 | Quiet version of PLDIX . | 26 |
D707 | PLDUXQ | s l - x -1 or 0 | Quiet version of PLDUX . | 26 |
D708cc | [cc+1] LDI_l | s - x s' | A longer encoding for LDI . | 34 |
D709cc | [cc+1] LDU_l | s - x s' | A longer encoding for LDU . | 34 |
D70Acc | [cc+1] PLDI | s - x | Preloads a signed cc+1 -bit integer from Slice s . | 34 |
D70Bcc | [cc+1] PLDU | s - x | Preloads an unsigned cc+1 -bit integer from s . | 34 |
D70Ccc | [cc+1] LDIQ | s - x s' -1 or s 0 | A quiet version of LDI . | 34 |
D70Dcc | [cc+1] LDUQ | s - x s' -1 or s 0 | A quiet version of LDU . | 34 |
D70Ecc | [cc+1] PLDIQ | s - x -1 or 0 | A quiet version of PLDI . | 34 |
D70Fcc | [cc+1] PLDUQ | s - x -1 or 0 | A quiet version of PLDU . | 34 |
D714_c | [32(c+1)] PLDUZ | s - s x | Preloads 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 |
D718 | LDSLICEX | s 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 |
D719 | PLDSLICEX | s l - s'' | Returns the first 0 <= l <= 1023 bits of s as s'' . | 26 |
D71A | LDSLICEXQ | s l - s'' s' -1 or s 0 | A quiet version of LDSLICEX . | 26 |
D71B | PLDSLICEXQ | s l - s' -1 or 0 | A quiet version of LDSLICEXQ . | 26 |
D71Ccc | [cc+1] LDSLICE_l | s - s'' s' | A longer encoding for LDSLICE . | 34 |
D71Dcc | [cc+1] PLDSLICE | s - s'' | Returns the first 0 < cc+1 <= 256 bits of s as s'' . | 34 |
D71Ecc | [cc+1] LDSLICEQ | s - s'' s' -1 or s 0 | A quiet version of LDSLICE . | 34 |
D71Fcc | [cc+1] PLDSLICEQ | s - s'' -1 or 0 | A quiet version of PLDSLICE . | 34 |
D720 | SDCUTFIRST | s l - s' | Returns the first 0 <= l <= 1023 bits of s . It is equivalent to PLDSLICEX . | 26 |
D721 | SDSKIPFIRST | s l - s' | Returns all but the first 0 <= l <= 1023 bits of s . It is equivalent to LDSLICEX NIP . | 26 |
D722 | SDCUTLAST | s l - s' | Returns the last 0 <= l <= 1023 bits of s . | 26 |
D723 | SDSKIPLAST | s l - s' | Returns all but the last 0 <= l <= 1023 bits of s . | 26 |
D724 | SDSUBSTR | s 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 |
D726 | SDBEGINSX | s 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 |
D727 | SDBEGINSXQ | s s' - s'' -1 or s 0 | A quiet version of SDBEGINSX . | 26 |
D72A_xsss | [slice] SDBEGINS | s - 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] SDBEGINSQ | s - s'' -1 or s 0 | A quiet version of SDBEGINS . | 31 |
D730 | SCUTFIRST | s l r - s' | Returns the first 0 <= l <= 1023 bits and first 0 <= r <= 4 references of s . | 26 |
D731 | SSKIPFIRST | s l r - s' | Returns all but the first l bits of s and r references of s . | 26 |
D732 | SCUTLAST | s l r - s' | Returns the last 0 <= l <= 1023 data bits and last 0 <= r <= 4 references of s . | 26 |
D733 | SSKIPLAST | s l r - s' | Returns all but the last l bits of s and r references of s . | 26 |
D734 | SUBSLICE | s 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 |
D736 | SPLIT | s 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 |
D737 | SPLITQ | s l r - s' s'' -1 or s 0 | A quiet version of SPLIT . | 26 |
D739 | c - 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 . | ||
D73A | c - 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. | ||
D73B | c - c' -1 or c 0 | Loads an exotic cell c and returns an ordinary cell c' . If c is already ordinary, does nothing. If c cannot be loaded, returns 0. | ||
D741 | SCHKBITS | s 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 |
D742 | SCHKREFS | s r - | Checks whether there are at least r references in Slice s . | 26/76 |
D743 | SCHKBITREFS | s l r - | Checks whether there are at least l data bits and r references in Slice s . | 26/76 |
D745 | SCHKBITSQ | s l - ? | Checks whether there are at least l data bits in Slice s . | 26 |
D746 | SCHKREFSQ | s r - ? | Checks whether there are at least r references in Slice s . | 26 |
D747 | SCHKBITREFSQ | s l r - ? | Checks whether there are at least l data bits and r references in Slice s . | 26 |
D748 | PLDREFVAR | s n - c | Returns the n -th cell reference of Slice s for 0 <= n <= 3 . | 26 |
D749 | SBITS | s - l | Returns the number of data bits in Slice s . | 26 |
D74A | SREFS | s - r | Returns the number of references in Slice s . | 26 |
D74B | SBITREFS | s - l r | Returns both the number of data bits and the number of references in s . | 26 |
D74E_n | [n] PLDREFIDX | s - c | Returns the n -th cell reference of Slice s , where 0 <= n <= 3 . | 26 |
D74C | PLDREF | s - c | Preloads the first cell reference of a Slice. | 26 |
D750 | LDILE4 | s - x s' | Loads a little-endian signed 32-bit integer. | 26 |
D751 | LDULE4 | s - x s' | Loads a little-endian unsigned 32-bit integer. | 26 |
D752 | LDILE8 | s - x s' | Loads a little-endian signed 64-bit integer. | 26 |
D753 | LDULE8 | s - x s' | Loads a little-endian unsigned 64-bit integer. | 26 |
D754 | PLDILE4 | s - x | Preloads a little-endian signed 32-bit integer. | 26 |
D755 | PLDULE4 | s - x | Preloads a little-endian unsigned 32-bit integer. | 26 |
D756 | PLDILE8 | s - x | Preloads a little-endian signed 64-bit integer. | 26 |
D757 | PLDULE8 | s - x | Preloads a little-endian unsigned 64-bit integer. | 26 |
D758 | LDILE4Q | s - x s' -1 or s 0 | Quietly loads a little-endian signed 32-bit integer. | 26 |
D759 | LDULE4Q | s - x s' -1 or s 0 | Quietly loads a little-endian unsigned 32-bit integer. | 26 |
D75A | LDILE8Q | s - x s' -1 or s 0 | Quietly loads a little-endian signed 64-bit integer. | 26 |
D75B | LDULE8Q | s - x s' -1 or s 0 | Quietly loads a little-endian unsigned 64-bit integer. | 26 |
D75C | PLDILE4Q | s - x -1 or 0 | Quietly preloads a little-endian signed 32-bit integer. | 26 |
D75D | PLDULE4Q | s - x -1 or 0 | Quietly preloads a little-endian unsigned 32-bit integer. | 26 |
D75E | PLDILE8Q | s - x -1 or 0 | Quietly preloads a little-endian signed 64-bit integer. | 26 |
D75F | PLDULE8Q | s - x -1 or 0 | Quietly preloads a little-endian unsigned 64-bit integer. | 26 |
D760 | LDZEROES | s - n s' | Returns the count n of leading zero bits in s , and removes these bits from s . | 26 |
D761 | LDONES | s - n s' | Returns the count n of leading one bits in s , and removes these bits from s . | 26 |
D762 | LDSAME | s x - n s' | Returns the count n of leading bits equal to 0 <= x <= 1 in s , and removes these bits from s . | 26 |
D764 | SDEPTH | s - x | Returns 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 |
D765 | CDEPTH | c - x | Returns 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 |