# assembly\_to\_bytecode\_legacy

将 EVM Assembly 转为 EVM Bytecode。由于依赖的第三方库 pyevmasm 很久没有更新,所以该功能不一定能支持最新的 EVM 版本。

## 方法定义

```python
@staticmethod
def assembly_to_bytecode_legacy(assembly: str) -> Optional[HexBytes]
```

## 参数说明

| 参数       | 类型  | 说明           |
| -------- | --- | ------------ |
| assembly | str | EVM Assembly |

## 返回值

| 类型                  | 说明           |
| ------------------- | ------------ |
| Optional\[HexBytes] | EVM Bytecode |

## 示例代码

```python
# 将汇编转换为字节码
assembly = """
    PUSH1 0x80
    PUSH1 0x40
    MSTORE
    CALLVALUE
    DUP1
    ISZERO
    PUSH2 0x000f
    JUMPI
"""
bytecode = Utils.assembly_to_bytecode_legacy(assembly)
if bytecode:
    print(f"Bytecode: {bytecode.hex()}")
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://poseidon.seaeye.cn/evm/utils/assembly_to_bytecode_legacy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
