Urgent.News

What's breaking now, across thousands of outlets.

Tech

Introduction to x86_64 Assembly

Before diving further into the study of crackmes, it seemed appropriate to write a short introduction to x86_64 assembly language. It is a complex architecture, mainly due to the vast number of instructions in its instruction set. Registers On the x86_64 architecture, there are 16 general-purpose 64-bit registers. Each register has a full 64-bit name and can be divided into sub-registers to…

Before delving into the study of crackmes, it is prudent to familiarize oneself with x86_64 assembly language. This complex architecture boasts a broad spectrum of instructions, largely due to the substantial quantity of instructions contained within its instruction set.

Registers on the x86_64 architecture are 64 bits in length, with 16 of them available for general-purpose use. Each register possesses a precise 64-bit designation and can be subdivided into sub-registers to handle 32-bit, 16-bit, or 8-bit data.

The 16 general-purpose registers, each measuring 64 bits, include:

1. RAX - Accumulator, responsible for storing the function or syscall return value.

2. RBX - Base register, designated as callee-saved.

3. RCX - Loop counter and the fourth function argument.

4. RDX - Data holding the third function argument or the third syscall argument.

5. RSI - Source index, representing the second function and syscall argument.

6. RDI - Destination index, corresponding to the first function and syscall argument.

7. RBP - Base Pointer, also known as the frame pointer.

8. RSP - Stack Pointer, marking the top of the current stack.

9. R8 - Fifth function argument or syscall argument.

10. R9 - Sixth function argument or syscall argument.

11. R10 - Temporary register serving as the fourth syscall argument.

12. R11 - Temporary register, acting as a scratch space.

13. R12 - Through R15 - Additional callee-saved registers.

In addition to these general-purpose registers, the x86_64 architecture features special and control registers, as well as vector and floating-point registers, which are utilized for performing floating-point calculations and vector processing through extensions like SSE, AVX, AVX-512, AMX, and VMX.

A vital aspect of understanding x86_64 assembly language is grasping the mechanics of the stack. As an LIFO (Last-In, First-Out) structure, the stack grows downward in memory. When data is pushed onto the stack using the PUSH or CALL instruction, the Stack Pointer (RSP) is decremented by 8 bytes. Conversely, when data is popped using the POP or RET instruction, RSP is incremented.

The stack is extensively employed in binaries to store local variables, accommodate function parameters beyond the sixth argument, and maintain track of function return addresses. Familiarity with the instructions involved in stack manipulation is crucial for binary analysis.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

How I Built a Free Attendance Calculator for KL University Students

Every KL University student knows the panic - semester end approaching, attendance borderline, no idea if you're going to get a hall ticket or not.

  • KL University students face exam stress over attendance requirements.
  • KL Attendance Calculator offers weighted LTPS, bunk planner, and recovery tools.
  • Free web app accessible on Vaddeswaram and Hyderabad campuses.

More from Saturday 29 August →