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

x86-64汇编疑问:rbx为何不影响al?mov寄存器赋值困惑

Understanding x86-64 Register Behavior in Your Example

Let’s walk through your two questions clearly—this is a key concept to nail down when starting out with x86-64 assembly!

1. Why does mov rbx, 0 not leave rbx as 0 in the end?

First off, mov rbx, 0 does set the entire 64-bit rbx register to 0 when it executes. The confusion comes from the instruction that follows it: mov bl, al.

x86-64 registers are structured with overlapping subsets:

  • rbx = full 64-bit register
  • ebx = lower 32 bits of rbx
  • bx = lower 16 bits of rbx
  • bl = lower 8 bits of rbx (the rightmost 8 bits)
  • bh = upper 8 bits of bx (bits 8-15 of rbx)

When you execute mov bl, al, you’re only writing to the lowest 8 bits of rbx. The rest of the register (bits 8-63) stays exactly as they were set by mov rbx, 0—which is 0. So after these three instructions:

  1. mov al, 50 → al = 50 (0x32 in hex)
  2. mov rbx, 0 → rbx = 0x0000000000000000
  3. mov bl, al → bl = 50, so rbx becomes 0x0000000000000032 (which is decimal 50)

That’s why the final value of rbx is 50, not 0—you overwrote the lowest 8 bits after setting the whole register to zero.

2. Why doesn’t modifying rbx affect al?

Simple: al and rbx are part of completely separate register families.

  • al is the lowest 8 bits of the rax register (one of x86-64’s general-purpose registers)
  • rbx is an entirely independent general-purpose register, with its own set of sub-registers (bl, bx, ebx)

In x86-64 architecture, these registers don’t overlap or share bits. Modifying any part of rbx (bl, bx, ebx, or rbx itself) has no impact on rax or its sub-registers (al, ax, eax). They’re separate storage locations in the CPU, so changes to one don’t bleed into the other.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:41:25