<divclass="link title"><ahref="/v5/">Documentation</a></div><divclass="base show link depth-1"><ahref="/v5/getting-started/">Getting Started</a></div><divclass="base show link depth-1"><ahref="/v5/concepts/">Ethereum Basics</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/events/">Events</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/gas/">Gas</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/security/">Security</a></div><divclass="base show link depth-1"><ahref="/v5/api/">Application Programming Interface</a></div><divclass="hide link depth-2"><ahref="/v5/api/contract/">Contract Interaction</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract/">Contract</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract-factory/">ContractFactory</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><divclass="hide link depth-2"><ahref="/v5/api/signer/">Signers</a></div><divclass="hide link depth-2"><ahref="/v5/api/providers/">Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/provider/">Provider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/api-providers/">API Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/other/">Other Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/types/">Types</a></div><divclass="hide link depth-2"><ahref="/v5/api/utils/">Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/abi/">Application Binary Interface</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/coder/">AbiCoder</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/formats/">ABI Formats</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/fragments/">Fragments</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/interface/">Interface</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/address/">Addresses</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bignumber/">BigNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bytes/">Byte Manipulation</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/constants/">Constants</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/display-logic/">Display Logic and Input</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/encoding/">Encoding Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hashing/">Hashing Algorithms</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hdnode/">HD Wallet</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/logger/">Logging</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/properties/">Property Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/signing-key/">Signing Key</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/strings/">Strings</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/transactions/">Transactions</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/web/">Web Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/wordlists/">Wordlists</a></div><divclass="hide link depth-2"><ahref="/v5/api/other/">Other Libraries</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/assembly/">Assembly</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/api/">Utilities</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/hardware/">Hardware Wallets</a></div><divclass="hide link depth-2"><ahref="/v5/api/experiment
<divclass="breadcrumbs"><ahref="/v5/">Documentation</a> » <ahref="/v5/cli/">Command Line Interfaces</a> » <spanclass="current">Assembler</span></div>
<aname="cli-asm"></a><aname="cli-asm"></a><h1class="show-anchors"><div>Assembler<divclass="anchors"><aclass="self"href="/v5/cli/asm/#cli-asm"></a></div></div></h1><p>The assembler Command-Line utility allows you to assemble the <ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a> into deployable EVM bytecode and disassemle EVM bytecode into human-readable mnemonics.</p>
--version Show this version and exit</div><aname="cli-asm--example-input-files"></a><h2class="show-anchors"><div>Example Input Files<divclass="anchors"><aclass="self"href="/v5/cli/asm/#cli-asm--example-input-files"></a></div></div></h2>
0xf35b6024361415601e5760043560005560006000f3</div><divclass="definition container-box note"><divclass="term">Note: Bytecode File Syntax</div><divclass="body"><p>A bin file may be made up of multiple blocks of bytecode, each may optionally begin with a <codeclass="inline">0x</code> prefix, all of which <b>must</b> be of even length (since bytes are required, with 2 nibbles per byte)</p>
<p>All whitespace is ignored.</p>
</div></div><aname="cli-asm--assembler-examples"></a><h2class="show-anchors"><div>Assembler Examples<divclass="anchors"><aclass="self"href="/v5/cli/asm/#cli-asm--assembler-examples"></a></div></div></h2><p>The assembler converts an <ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a> into bytecode by running multiple passes of an assemble stage, each pass more closely approximating the final result.</p>
<p>This allows small portions of the bytecode to be massaged and tweaked until the bytecode stablizes. This allows for more compact jump destinations and for code to be include more advanced meta-programming techniques.</p>
<divclass="definition"><divclass="term"><b>--define KEY=VALUE</b><i>or</i><b>--define FLAG</b></div><divclass="body"><p>This allows key/value pairs (where the value is a string) and flags (which the value is <codeclass="inline">true</code>) to be passed along to the assembler, which can be accessed in <ahref="/v5/api/other/assembly/dialect/#asm-dialect-scripting">Scripting Blocks</a>, such as <codeclass="inline">{{= defined.someKey }}</code>.</p>
</div></div><divclass="definition"><divclass="term"><b>--ignore-warnings</b></div><divclass="body"><p>By default any warning will be treated like an error. This enabled by-passing warnings.</p>
</div></div><divclass="definition"><divclass="term"><b>--pic</b></div><divclass="body"><p>When a program is assembled, the labels are usually given as an absolute byte position, which can be jumped to for loops and control flow. This means that a program must be installed at a specific location.</p>
<p>Byt specifying the <b>Position Independent Code</b> flag, code will be generated in a way such that all offsets are relative, allowing the program to be moved without any impact to its logic.</p>
<p>This does incur an additional gsas cost of 8 gas per offset access though.</p>
</div></div><divclass="definition"><divclass="term"><b>--target LABEL</b></div><divclass="body"><p>All programs have a root scope named <codeclass="inline">_</code> which is by default assembled. This option allows another labelled target (either a <ahref="/v5/api/other/assembly/dialect/#asm-dialect-scope">Scopes</a> or a <ahref="/v5/api/other/assembly/dialect/#asm-dialect-datasegment">Data Segment</a> to be assembled instead. The entire program is still assembled per usual, so this only impacts which part of the program is output.</p>
</div></div><aname="cli-asm--disassembler-examples"></a><h2class="show-anchors"><div>Disassembler Examples<divclass="anchors"><aclass="self"href="/v5/cli/asm/#cli-asm--disassembler-examples"></a></div></div></h2><p>A disassembled program shows offsets and mnemonics for the given bytecode. This format may change in the future to be more human-readable.</p>
<divclass="copyright">The content of this site is licensed under the <ahref="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on June 12, 2020, 3:31am.</div>