You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Yasm编译x86_64 Intel语法汇编遇rbp错误,求替代BITS 64的命令行参数

Solution for Yasm "undefined symbol `rbp'" Error Without Modifying Source

Hey there, let's break down what's happening and fix that error without touching your source code.

Why You're Seeing This Error

The error pops up because Yasm is defaulting to 32-bit x86 mode when parsing your code. In 32-bit mode, rbp isn't a recognized built-in register (the 32-bit equivalent is ebp), so Yasm treats rbp like an undefined variable/symbol instead of a register. Even though you added -m amd64 to target 64-bit architecture, Yasm still needs an explicit nudge to parse the code itself in 64-bit mode.

Fixes via Command Line (No Source Changes Needed)

You have two straightforward options to force Yasm into 64-bit parsing mode:

  1. Specify a 64-bit Output Format
    Yasm will automatically switch to 64-bit parsing if you tell it to output a 64-bit binary format. Use -f elf64 for Linux/macOS ELF binaries, or -f win64 for Windows PE binaries. Your command becomes:

    yasm foo.asm -a x86 -m amd64 -f elf64
    
  2. Force 64-bit Parsing Directly
    If you don't want to lock into a specific output format, use Yasm's --force-bits 64 flag to explicitly set the parsing mode to 64-bit. Here's the command:

    yasm foo.asm -a x86 -m amd64 --force-bits 64
    

Quick Note on the BITS 64 Pseudoinstruction

Just to clarify what that pseudoinstruction does: BITS 64 tells the assembler "treat all subsequent code as 64-bit x86". This switches the register set (enables 64-bit registers like rbp, rax), adjusts instruction encoding rules, and sets address length to 64 bits. The command line flags above do exactly this same thing globally, so you don't need to add the line to your source.

内容的提问来源于stack exchange,提问作者Siler

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:06:25