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 integerxinto Builderbfor0 <= cc <= 255, throws a range check exception ifxdoes not fit intocc+1bits. | 26 | 
| CBcc | [cc+1] STU | x b - b' | Stores an unsigned cc+1-bit integerxinto Builderb. In all other respects it is similar toSTI. | 26 | 
| CC | STREF | c b - b' | Stores a reference to Cell cinto Builderb. | 18 | 
| CD | STBREFRENDCST | b b'' - b | Equivalent to ENDCSWAPSTREF. | 518 | 
| CE | STSLICE | s b - b' | Stores Slice sinto Builderb. | 18 | 
| CF00 | STIX | x b l - b' | Stores a signed l-bit integerxintobfor0 <= l <= 257. | 26 | 
| CF01 | STUX | x b l - b' | Stores an unsigned l-bit integerxintobfor0 <= 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 inb, setsb'=bandf=-1.If xdoes not fit intolbits, setsb'=bandf=1.If the operation succeeds, b'is the new Builder andf=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 SWAPSTBREFR. | 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 Builderb. | 26 | 
| CF14 | STREFR | b c - b' | Equivalent to SWAPSTREF. | 26 | 
| CF15 | STBREFR_l | b b' - b'' | A longer encoding of STBREFR. | 526 | 
| CF16 | STSLICER | b s - b' | Equivalent to SWAPSTSLICE. | 26 | 
| CF17 | STBRBCONCAT | b b' - b'' | Concatenates two builders. Equivalent to SWAPSTB. | 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 | STBRQBCONCATQ | b b' - b b' -1 or b'' 0 | Quiet version of STBR. | 26 | 
| CF20 | [ref] STREFCONST | b - b’ | Equivalent to PUSHREFSTREFR. | 26 | 
| CF21 | [ref] [ref] STREF2CONST | b - b’ | Equivalent to STREFCONSTSTREFCONST. | 26 | 
| CF23 | b x - c | If x!=0, creates a special or exotic cell from Builderb.The type of the exotic cell must be stored in the first 8 bits of b.If x=0, it is equivalent toENDC. Otherwise some validity checks on the data and references ofbare 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 inb, thenx=0; otherwisexis one plus the maximum of depths of cells referred to fromb. | 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+1bits can be stored intob, where0 <= cc <= 255. | 34/84 | 
| CF39 | BCHKBITS | b x -  | Checks whether xbits can be stored intob,0 <= x <= 1023. If there is no space forxmore bits inb, or ifxis not within the range0...1023, throws an exception. | 26/76 | 
| CF3A | BCHKREFS | b y -  | Checks whether yreferences can be stored intob,0 <= y <= 7. | 26/76 | 
| CF3B | BCHKBITREFS | b x y -  | Checks whether xbits andyreferences can be stored intob,0 <= x <= 1023,0 <= y <= 7. | 26/76 | 
| CF3Ccc | [cc+1] BCHKBITSQ# | b - ? | Checks whether cc+1bits can be stored intob, where0 <= cc <= 255. | 34 | 
| CF3D | BCHKBITSQ | b x - ? | Checks whether xbits can be stored intob,0 <= x <= 1023. | 26 | 
| CF3E | BCHKREFSQ | b y - ? | Checks whether yreferences can be stored intob,0 <= y <= 7. | 26 | 
| CF3F | BCHKBITREFSQ | b x y - ? | Checks whether xbits andyreferences can be stored intob,0 <= x <= 1023,0 <= y <= 7. | 26 | 
| CF40 | STZEROES | b n - b' | Stores nbinary zeroes into Builderb. | 26 | 
| CF41 | STONES | b n - b' | Stores nbinary ones into Builderb. | 26 | 
| CF42 | STSAME | b n x - b' | Stores nbinaryxes (0 <= x <= 1) into Builderb. | 26 | 
| CFC0_xysss | [slice] STSLICECONST | b - b' | Stores a constant subslice sss.Details: sssconsists of0 <= x <= 3references and up to8y+2data bits, with0 <= y <= 7. Completion bit is assumed.Note that the assembler can replace STSLICECONSTwithPUSHSLICESTSLICERif 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 cmust be either an ordinary cell, or an exotic cell which is automatically loaded to yield an ordinary cellc', converted into a Slice afterwards. | 118/43 | 
| D1 | ENDS | s -  | Removes a Slice sfrom 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 integerxfrom Slices, and returns the remainder ofsass'. | 26 | 
| D3cc | [cc+1] LDU | s - x s' | Loads an unsigned cc+1-bit integerxfrom Slices. | 26 | 
| D4 | LDREF | s - c s' | Loads a cell reference cfroms. | 18 | 
| D5 | LDREFRTOS | s - s' s'' | Equivalent to LDREFSWAPCTOS. | 118/43 | 
| D6cc | [cc+1] LDSLICE | s - s'' s' | Cuts the next cc+1bits ofsinto a separate Slices''. | 26 | 
| D700 | LDIX | s l - x s' | Loads a signed l-bit (0 <= l <= 257) integerxfrom Slices, and returns the remainder ofsass'. | 26 | 
| D701 | LDUX | s l - x s' | Loads an unsigned l-bit integerxfrom (the firstlbits of)s, with0 <= l <= 256. | 26 | 
| D702 | PLDIX | s l - x | Preloads a signed l-bit integer from Slices, for0 <= l <= 257. | 26 | 
| D703 | PLDUX | s l - x | Preloads an unsigned l-bit integer froms, for0 <= l <= 256. | 26 | 
| D704 | LDIXQ | s l - x s' -1 or s 0 | Quiet version of LDIX: loads a signedl-bit integer fromssimilarly toLDIX, but returns a success flag, equal to-1on success or to0on failure (ifsdoes not havelbits), 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 Slices. | 34 | 
| D70Bcc | [cc+1] PLDU | s - x | Preloads an unsigned cc+1-bit integer froms. | 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 Slicesinto an unsigned integerx, for0 <= c <= 7. Ifsis shorter than necessary, missing bits are assumed to be zero. This operation is intended to be used along withIFBITJMPand similar instructions. | 26 | 
| D718 | LDSLICEX | s l - s'' s' | Loads the first 0 <= l <= 1023bits from Slicesinto a separate Slices'', returning the remainder ofsass'. | 26 | 
| D719 | PLDSLICEX | s l - s'' | Returns the first 0 <= l <= 1023bits ofsass''. | 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 <= 256bits ofsass''. | 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 <= 1023bits ofs. It is equivalent toPLDSLICEX. | 26 | 
| D721 | SDSKIPFIRST | s l - s' | Returns all but the first 0 <= l <= 1023bits ofs. It is equivalent toLDSLICEXNIP. | 26 | 
| D722 | SDCUTLAST | s l - s' | Returns the last 0 <= l <= 1023bits ofs. | 26 | 
| D723 | SDSKIPLAST | s l - s' | Returns all but the last 0 <= l <= 1023bits ofs. | 26 | 
| D724 | SDSUBSTR | s l l' - s' | Returns 0 <= l' <= 1023bits ofsstarting from offset0 <= l <= 1023, thus extracting a bit substring out of the data ofs. | 26 | 
| D726 | SDBEGINSX | s s' - s'' | Checks whether sbegins with (the data bits of)s', and removess'fromson success. On failure throws a cell deserialization exception. PrimitiveSDPFXREVcan be considered a quiet version ofSDBEGINSX. | 26 | 
| D727 | SDBEGINSXQ | s s' - s'' -1 or s 0 | A quiet version of SDBEGINSX. | 26 | 
| D72A_xsss | [slice] SDBEGINS | s - s'' | Checks whether sbegins with constant bitstringsssof length8x+3(with continuation bit assumed), where0 <= x <= 127, and removessssfromson 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 <= 1023bits and first0 <= r <= 4references ofs. | 26 | 
| D731 | SSKIPFIRST | s l r - s' | Returns all but the first lbits ofsandrreferences ofs. | 26 | 
| D732 | SCUTLAST | s l r - s' | Returns the last 0 <= l <= 1023data bits and last0 <= r <= 4references ofs. | 26 | 
| D733 | SSKIPLAST | s l r - s' | Returns all but the last lbits ofsandrreferences ofs. | 26 | 
| D734 | SUBSLICE | s l r l' r' - s' | Returns 0 <= l' <= 1023bits and0 <= r' <= 4references from Slices, after skipping the first0 <= l <= 1023bits and first0 <= r <= 4references. | 26 | 
| D736 | SPLIT | s l r - s' s'' | Splits the first 0 <= l <= 1023data bits and first0 <= r <= 4references fromsintos', returning the remainder ofsass''. | 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 cis exotic. If that be the case, its type can later be deserialized from the first eight bits ofs. | ||
| D73A | c - c' | Loads an exotic cell cand returns an ordinary cellc'. Ifcis already ordinary, does nothing. Ifccannot be loaded, throws an exception. | ||
| D73B | c - c' -1 or c 0 | Loads an exotic cell cand returns an ordinary cellc'. Ifcis already ordinary, does nothing. Ifccannot be loaded, returns 0. | ||
| D741 | SCHKBITS | s l -  | Checks whether there are at least ldata bits in Slices. 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 rreferences in Slices. | 26/76 | 
| D743 | SCHKBITREFS | s l r -  | Checks whether there are at least ldata bits andrreferences in Slices. | 26/76 | 
| D745 | SCHKBITSQ | s l - ? | Checks whether there are at least ldata bits in Slices. | 26 | 
| D746 | SCHKREFSQ | s r - ? | Checks whether there are at least rreferences in Slices. | 26 | 
| D747 | SCHKBITREFSQ | s l r - ? | Checks whether there are at least ldata bits andrreferences in Slices. | 26 | 
| D748 | PLDREFVAR | s n - c | Returns the n-th cell reference of Slicesfor0 <= 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 Slices, where0 <= 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 nof leading zero bits ins, and removes these bits froms. | 26 | 
| D761 | LDONES | s - n s' | Returns the count nof leading one bits ins, and removes these bits froms. | 26 | 
| D762 | LDSAME | s x - n s' | Returns the count nof leading bits equal to0 <= x <= 1ins, and removes these bits froms. | 26 | 
| D764 | SDEPTH | s - x | Returns the depth of Slice s. Ifshas no references, thenx=0; otherwisexis one plus the maximum of depths of cells referred to froms. | 26 | 
| D765 | CDEPTH | c - x | Returns the depth of Cell c. Ifchas no references, thenx=0; otherwisexis one plus the maximum of depths of cells referred to fromc. Ifcis a Null instead of a Cell, returns zero. | 26 |