87 lines
2.8 KiB
Plaintext
87 lines
2.8 KiB
Plaintext
_section: Utilities @<asm-utilities>
|
|
|
|
_subsection: Assembler
|
|
|
|
The assembler utilities allow parsing and assembling an
|
|
[Ethers ASM Dialect](asm-dialect) source file.
|
|
|
|
_property: asm.parse(code) => [[asm-node]] @<asm-parse> @SRC<asm/assembler>
|
|
Parse an ethers-format assembly file and return the [[asm-ast]].
|
|
|
|
_property: asm.assemble(node) => string<[[DataHexString]]> @SRC<asm/assembler:function.assemble>
|
|
Performs assembly of the [[asm-ast]] //node// and return the
|
|
resulting bytecode representation.
|
|
|
|
|
|
_subsection: Disassembler
|
|
|
|
The **Disassembler** utilities make it easy to convert bytecode
|
|
into an object which can easily be examined for program structure.
|
|
|
|
_property: asm.disassemble(bytecode) => [[asm-bytecode]] @SRC<asm/assembler>
|
|
Returns an array of Operations given //bytecode//.
|
|
|
|
_property: asm.formatBytecode(operations) => string @SRC<asm/assembler>
|
|
Create a formatted output of an array of [[asm-operation]].
|
|
|
|
_heading: Bytecode @<asm-bytecode> @INHERIT<Array\<[[asm-operation]]\>>
|
|
|
|
Each arary index represents an operation, collapsing multi-byte operations
|
|
(i.e. ``PUSH``) into a single operation.
|
|
|
|
_property: bytecode.getOperation(offset) => [[asm-operation]]
|
|
Get the operation at a given //offset// into the bytecode. This ensures that
|
|
the byte at //offset// is an operation and not data contained within a ``PUSH``,
|
|
in which case null it returned.
|
|
|
|
_heading: Operation @<asm-operation>
|
|
|
|
An **Operation** is a single command from a disassembled bytecode
|
|
stream.
|
|
|
|
_property: operation.opcode => [[asm-opcode]]
|
|
The opcode for this Operation.
|
|
|
|
_property: operation.offset => number
|
|
The offset into the bytecode for this Operation.
|
|
|
|
_property: operation.pushValue => string<[[DataHexString]]>
|
|
If the opcode is a ``PUSH``, this is the value of that push
|
|
|
|
|
|
_subsection: Opcode @<asm-opcode> @SRC<asm/opcodes:class.Opcode>
|
|
|
|
_property: asm.Opcode.from(valueOrMnemonic) => [[asm-opcode]]
|
|
Create a new instnace of an Opcode for a given numeric value
|
|
(e.g. 0x60 is PUSH1) or mnemonic string (e.g. "PUSH1").
|
|
|
|
_heading: Properties
|
|
|
|
_property: opcode.value => number
|
|
The value (bytecode as a number) of this opcode.
|
|
|
|
_property: opcode.mnemonic => string
|
|
The mnemonic string of this opcode.
|
|
|
|
_property: opcode.delta => number
|
|
The number of items this opcode will consume from the stack.
|
|
|
|
_property: opcode.alpha => number
|
|
The number of items this opcode will push onto the stack.
|
|
|
|
_property: opcode.doc => string
|
|
A short description of what this opcode does.
|
|
|
|
_property: opcode.isMemory() => "read" | "write" | "full"
|
|
Returns true if the opcode accesses memory.
|
|
|
|
_property: opcode.isStatic() => boolean
|
|
Returns true if the opcode cannot change state.
|
|
|
|
_property: opcode.isJump() => boolean
|
|
Returns true if the opcode is a jumper operation.
|
|
|
|
_property: opcode.isPush() => number
|
|
Returns 0 if the opcode is not a ``PUSH*``, or the number
|
|
of bytes this opcode will push if it is.
|