ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!
Other languages

Understanding AMD64: x32 vs x64 & WTF are registers?

Submitted by Remio at 01-05-2025, 10:02 AM


Understanding AMD64: x32 vs x64 & WTF are registers?
631 Views
Remio's Avatar'
Remio
Offline
#1
Remy’s Introduction to AMD64 Assembly on Modern Windows: Registers & Architecture Overview

Hello there. If you want to start exploring lower-level programming and start looking at x64 assembly on modern AMD/Intel CPUs, then this guide is a great place to start. Whether you already know a bit about assembly or know about assembly on Linux, here’s what you need to know for getting started with modern x64 assembly code on Windows:

A quick question: Why is it called AMD64 and not intel64!?  
Although both Intel and AMD use the x64 architecture today, it was originally AMD that first extended the original x86 architecture (a 32bit CPU design used in most PCs) to 64bit. The x86 architecture itself dates back to the 16-bit Intel 8086 processor and evolved through 32-bit chips like the 80386, paving the way for what processors we use today. Because AMD introduced this 64bit extension first, it became known as AMD64, even though Intel later adopted and supported it too. So when you hear me say AMD64, I basically mean x64 for both AMD and Intel — it’s the same thing.

What the fuck are registers?  
They’re used to hold variables, function arguments, return values, pointers, counters, and more. When you make a variable or pointer, this is often where it actually lives (at least temporarily).  
For example, the x64 RAX register typically holds return values, RCX is used for function arguments, and RSP serves as the stack pointer.  
Having more registers means the CPU can keep more data “to hand,” reducing the need to fetch it from RAM — making things much faster.


Where do register names come from?

In 32-bit (x86) assembly there are eight general-purpose registers:  

EAX, EBX, ECX, EDX, ESI, EDI, EBP, and ESP

When the architecture moved to 64-bit (x64), these same registers were extended to hold 64 bits instead of 32. They were renamed by adding an “R” at the front, making them:  

RAX, RBX, RCX, RDX, RSI, RDI, RBP, and RSP

In addition to these, x64 introduced eight new general-purpose registers, named:  

R8, R9, R10, R11, R12, R13, R14, and R15

So in 64-bit mode, there are now 16 general-purpose registers.

Each 64-bit register can also be accessed in smaller parts, depending on how much data you’re working with. This is one reason why 64-bit CPUs can still run 32-bit programs — they just use the lower 32 bits of the register. Here is an example using the RAX register:


- RAX = full 64-bit register  
- EAX = lower 32 bits of RAX  
- AX = lower 16 bits of EAX  
- AL = lower 8 bits of AX


The same pattern works for the new R8–R15 registers:

- R8 = 64-bit  
- R8D = lower 32 bits  
- R8W = lower 16 bits  
- R8B = lower 8 bits


Even in a 64-bit environment, you can use just a part of a register when needed.  
This flexibility makes it easier to handle different data sizes without needing completely different registers or instructions.


No inline assembly in x64 C/C++  
A quick FYI: Most modern C/C++ compilers like MSVC and Clang don’t support inline assembly in 64-bit mode.  
This means you can’t just drop `__asm {}` blocks in your C/C++ code like you could in 32-bit.  
To write 64-bit assembly, you’ll usually need to use external `.asm` files with an assembler like MASM, NASM, or FASM.


Why it matters  
- More registers = fewer memory accesses, faster code  
- Wider registers = better for large values and pointer arithmetic  
- Backward compatibility = you can still run old x86 code

x64 is a modernized x86 and not a complete rewrite.  
You get more power without throwing away everything old.


- Remy
0
Reply



Users browsing this thread: 1 Guest(s)