RBX Register
RBX is a callee-saved x86-64 register: why it holds values across calls, what CPUID and CMPXCHG16B do to it, and its old jobs as base register and GOT pointer.
RBX is the register that survives. It is callee-saved in both the System V and Microsoft x64 ABIs, so compilers reach for it whenever a value has to outlive a function call. It has almost no implicit uses, which makes it the most ordinary of the original eight registers and one of the easiest to read.
What it means when you see it
A function that opens with push rbx is going to call something and wants to keep a value across that call. The next instruction usually tells you which value:
push rbx
mov rbx, rdi ; keep the first argument (System V)
call lock_acquire
mov rdi, rbx ; and here it is again
call do_work
pop rbx
retOn Windows the same pattern reads mov rbx, rcx, and in C++ code the value kept this way is very often this. Rename rbx once at the top of the function and half of it becomes readable.
The save is not always a push. MSVC frequently stores it in the caller's shadow space instead:
mov [rsp+0x8], rbx
push rdi
sub rsp, 0x20Sub-registers
EBX is the low 32 bits, BX the low 16, BL the low 8 and BH bits 8 to 15. Writing EBX zeroes the upper half of RBX; the narrower writes preserve it.
The few instructions that touch it implicitly
cpuid overwrites eax, ebx, ecx and edx. Leaf 0 returns the vendor string split across three registers in an odd order: ebx, then edx, then ecx, giving Genu ineI ntel. Leaf 0x40000000 returns the hypervisor vendor the same way (VMwareVMware, KVMKVMKVM, Microsoft Hv), which is one of the most common virtual machine checks in malware:
mov eax, 0x40000000
cpuid
cmp ebx, 0x61774d56 ; "VMwa"
je .in_vmBecause RBX is callee-saved, any function using cpuid has to save it first. A push rbx directly before a cpuid is that and nothing more.
cmpxchg16b compares rdx:rax with a 16-byte memory operand and, if equal, stores rcx:rbx. It shows up in lock-free queues and in Windows SLIST code.
xlat replaces al with the byte at [rbx+al]. Compilers never emit it. Hand-written decoders and some obfuscators do, as a compact substitution-table lookup.
Legacy roles in 32-bit code
EBX carries two conventions on 32-bit Linux that have no 64-bit equivalent. Position-independent code keeps the address of the GOT in it, loaded by a thunk:
call __x86.get_pc_thunk.bx
add ebx, 0x2e3f ; ebx = &_GLOBAL_OFFSET_TABLE_
lea eax, [ebx-0x1ff8] ; a string, addressed from the GOTUntil you recognise that, every data reference in a 32-bit shared object looks like an unexplained offset from ebx. And int 0x80 system calls take their first argument in ebx, so 32-bit shellcode for execve sets ebx to the path.
In 16-bit code BX was the only general register usable as a memory base, which is where the "base" name comes from.
Reverse-engineering notes
If RBX changes across a call to compiled code, something is wrong: a stack corruption overwrote the saved copy, the callee is hand-written assembly that ignores the ABI, or the function does not return where you think it does. Watching a callee-saved register is a quick way to notice a smashed frame before the crash.
Compilers allocate callee-saved registers in a fairly stable order, rbx first, then rbp, then r12 to r15. A function that pushes all six is holding a lot of state across calls, and is usually a parser, a dispatcher or a main loop.
Related: calling conventions, push and pop, the register map, and RAX.