Crates.io | everscale-asm |
lib.rs | everscale-asm |
version | 0.0.9 |
source | src |
created_at | 2023-10-24 16:26:59.926809 |
updated_at | 2024-06-27 14:18:33.480381 |
description | Rust implementation of TVM Assembler |
homepage | |
repository | https://github.com/broxus/everscale-asm |
max_upload_size | |
id | 1012561 |
size | 109,472 |
Status: WIP
Rust implementation of TVM Assembler.
cargo install --locked tvmasm
tvmasm build ./src/tests/walletv3.tvm -o walletv3.boc
Output:
Code path: walletv3.boc
Code hash: 84dafa449f98a6987789ba232358072bc0f76dc4524002a5d0918b9a75d2d599
Unique cells: 1
Unique bits: 888
Runtime:
use everscale_asm::Code;
use everscale_types::prelude::Cell;
let code: Cell = Code::assemble(r#"
PUSHINT 1
SWAP DUP
PUSHCONT {
TUCK
MUL
SWAP
DEC
}
REPEAT
DROP
"#)?;
Compile time:
use everscale_asm_macros::tvmasm;
use everscale_types::prelude::{Boc, Cell};
const CODE: &[u8] = tvmasm!(
"PUSHINT 1",
"PUSHCONT { INC PUSHINT 10 LESS }",
"PUSHCONT { DUMPSTK }",
"WHILE",
);
let code: Cell = Boc::decode(CODE)?;
// Single-line comments
// Opcodes must be in uppercase, can start with a digit or minus,
// and can contain '#' or '_'
NOP
2DROP
-ROT
STREF_L
// Opcodes with number as an argument
PUSHINT 12
PUSHINT -0xded
PUSHINT 0b10110101
// Opcodes with stack register as an argument
PUSH s1
XCHG s10, s100
PU2XC s1, s(-1), s(-2)
// Opcodes with control registers (c0, .., c5, c7)
PUSH c3
PUSHCTR c7
// Opcodes with slice or continuation
PUSHSLICE x{123123_}
PUSHSLICE b{10001001}
IFREFELSEREF {
PUSHINT 1
}, {
PUSHINT 2
}
// Insert raw slices into code
@inline x{a924}
We welcome contributions to the project! If you notice any issues or errors, feel free to open an issue or submit a pull request.
Licensed under either of
at your option.