0Pricing
Assembly Language & x86 Low-Level Systems Programming · درس

مقدمة إلى مجموعات تعليمات SSE/AVX

تعرّف بصورة عامة على مجموعات تعليمات SIMD الحديثة (SSE وAVX) ومسجلاتها، المصممة لمعالجة البيانات بالتوازي.

مقدمة إلى مجموعات تعليمات SSE/AVX درس مجاني في Assembly Language & x86 Low-Level Systems Programming على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Assembly Language & x86 Low-Level Systems Programming، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Assembly Language & x86 Low-Level Systems Programming 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Welcome to SIMD!

In this lesson, we'll explore powerful instruction sets designed for parallel processing: SSE and AVX. These extensions allow your CPU to perform the same operation on multiple pieces of data simultaneously.

This technique, called Single Instruction, Multiple Data (SIMD), is crucial for speeding up tasks like graphics rendering, scientific calculations, and video processing.

Scalar vs. Vector Processing

Imagine you need to add two lists of numbers. A traditional scalar processor adds them one pair at a time:

  • 1st number + 1st number
  • 2nd number + 2nd number
  • ...and so on.

A vector processor (using SIMD) can add multiple pairs in a single instruction, significantly faster for large datasets.

Introducing SSE

SSE stands for Streaming SIMD Extensions. Introduced by Intel, SSE brought 128-bit wide registers and instructions to x86 processors.

This means an SSE instruction can process 128 bits of data in one go. For single-precision floating-point numbers (each 32 bits), this allows processing four numbers at once.

SSE Registers: XMM0-XMM15

SSE uses a dedicated set of 16 XMM registers, named XMM0 through XMM15. Each XMM register is 128 bits wide.

  • They can hold four 32-bit single-precision floating-point numbers.
  • Or two 64-bit double-precision floating-point numbers.
  • Or sixteen 8-bit integers.

These registers are separate from the general-purpose registers (like EAX, EBX).

SSE Data Movement: MOVAPS

Let's look at a basic SSE instruction: MOVAPS. This instruction moves aligned packed single-precision floating-point values. It loads 128 bits of data from memory into an XMM register.

Try running this example (using NASM syntax for Linux x86-64):

section .data
  ; Define 4 single-precision floats (128 bits total)
  my_sse_data dd 1.0, 2.0, 3.0, 4.0

section .text
  global _start

_start:
  ; Load 128 bits from my_sse_data into XMM0
  movaps xmm0, [my_sse_data]

  ; XMM0 now holds [1.0, 2.0, 3.0, 4.0]

  ; Exit the program (Linux x86/x64 syscall)
  mov eax, 1    ; sys_exit
  xor ebx, ebx  ; exit code 0
  int 0x80      ; Invoke kernel

Beyond SSE: AVX

AVX, or Advanced Vector Extensions, is a further enhancement to SIMD processing. AVX expands the SIMD registers to 256 bits, doubling the amount of data processed per instruction compared to SSE.

AVX also introduced a new instruction encoding scheme (VEX prefix) and non-destructive operations, meaning destination registers don't overwrite source registers by default.

AVX Registers: YMM0-YMM15

AVX introduced 16 new YMM registers (YMM0 through YMM15). Each YMM register is 256 bits wide.

  • A YMM register can hold eight 32-bit single-precision floats.
  • Or four 64-bit double-precision floats.

The lower 128 bits of each YMM register overlap with the corresponding XMM register (e.g., the lower half of YMM0 is XMM0).

AVX Data Movement: VMOVAPS

The AVX equivalent of MOVAPS is VMOVAPS. The 'V' prefix indicates a VEX-encoded AVX instruction. This instruction moves aligned packed single-precision floating-point values, but now 256 bits at a time.

Here's an example demonstrating loading 8 floats into a YMM register:

section .data
  ; Define 8 single-precision floats (256 bits total)
  my_avx_data dd 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0

section .text
  global _start

_start:
  ; Load 256 bits from my_avx_data into YMM0
  vmovaps ymm0, [my_avx_data]

  ; YMM0 now holds [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]

  ; Exit the program (Linux x86/x64 syscall)
  mov eax, 1    ; sys_exit
  xor ebx, ebx  ; exit code 0
  int 0x80      ; Invoke kernel

Key Differences: SSE vs. AVX

While both SSE and AVX are SIMD extensions, AVX offers significant advancements:

  • Register Size: SSE uses 128-bit XMM registers; AVX uses 256-bit YMM registers.
  • Data Throughput: AVX can process twice as much data per instruction as SSE.
  • Non-Destructive Ops: Many AVX instructions allow a three-operand format, keeping source operands intact.
  • VEX Prefix: AVX instructions use a VEX prefix, enabling more flexible encoding and future extensions.

Quick Check: SIMD Registers

Which of the following statements about SSE and AVX registers are TRUE?

Recap: Power of SIMD

We've introduced SSE and AVX, powerful SIMD instruction sets that allow your CPU to perform operations on multiple data items simultaneously. You learned about:

  • The concept of SIMD and its benefits for parallel processing.
  • SSE with its 128-bit XMM registers (XMM0-XMM15).
  • AVX with its 256-bit YMM registers (YMM0-YMM15).
  • Basic data movement instructions like MOVAPS and VMOVAPS.

Understanding these instruction sets is key to optimizing performance for data-intensive tasks.

الأسئلة الشائعة

هل درس «مقدمة إلى مجموعات تعليمات SSE/AVX» مجاني؟

نعم — نص درس «مقدمة إلى مجموعات تعليمات SSE/AVX» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Assembly Language & x86 Low-Level Systems Programming، انتقل إلى CoddyKit PRO. تتضمن دورة Assembly Language & x86 Low-Level Systems Programming 4 دروس في المجموع.

ماذا ستتعلم في «مقدمة إلى مجموعات تعليمات SSE/AVX»؟

تعرّف بصورة عامة على مجموعات تعليمات SIMD الحديثة (SSE وAVX) ومسجلاتها، المصممة لمعالجة البيانات بالتوازي. تتمرن على Assembly Language & x86 Low-Level Systems Programming مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Assembly Language & x86 Low-Level Systems Programming؟

لا تُشترط خبرة سابقة. Assembly Language & x86 Low-Level Systems Programming على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «مقدمة إلى مجموعات تعليمات SSE/AVX»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Assembly Language & x86 Low-Level Systems Programming هذا؟

نعم. كل درس في Assembly Language & x86 Low-Level Systems Programming يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. أساسيات برمجة x87 FPU
  2. مقدمة إلى مجموعات تعليمات SSE/AVX
  3. توجيه الشيفرة باستخدام SIMD
  4. دقة الأعداد ذات الفاصلة العائمة والتقريب والاستثناءات
← العودة إلى Assembly Language & x86 Low-Level Systems Programming