## x86/x64 Assembly Essentials

You don't need to write Assembly, but you must read it.

### Registers (The CPU's pockets)
The CPU has small storage slots called Registers.
*   **EAX / RAX**: The "Accumulator". Used for math and **Return Values**. (If a function returns "Success", EAX is usually 1 or 0).
*   **EBX / RBX**: Base.
*   **ECX / RCX**: Counter. Used in loops.
*   **EDX / RDX**: Data.
*   **EIP / RIP**: **Instruction Pointer**. This is the most important register. It points to the *next instruction* the CPU will execute.
    *   *Buffer Overflow*: If you can overwrite EIP, you control the CPU.
*   **ESP / RSP**: Stack Pointer. Points to the top of the stack.

### Common Instructions
1.  **MOV destination, source**: Copy data.
    *   `MOV EAX, 5` -> Put 5 into EAX.
2.  **ADD / SUB**: Math.
3.  **CMP A, B**: Compare A and B.
4.  **JMP / JZ / JNZ** (Jumps): The logic flow (If statements).
    *   `CMP EAX, 0` (Check if EAX is 0)
    *   `JZ 402000` (Jump if Zero to memory address 402000).
    *   *Hacking Tip*: If you change `JZ` (Jump if Zero) to `JNZ` (Jump if NOT Zero), you can flip the logic of the program. (e.g., "Is Password Correct?" -> "No" -> "Login Anyway").

### The Stack (LIFO)
Temporary memory for functions.
*   **PUSH**: Put something on top of the stack.
*   **POP**: Take it off.
*   Think of it like a stack of plates.