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

سجل FLAGS وبتّات الحالة

استكشف سجل EFLAGS/RFLAGS وتعرّف إلى كيفية ضبط تعليمات الحساب والمقارنة لرايات الحالة مثل ZF وCF وSF وOF، التي تتحكم في كل قرار شرطي.

الدرس 4 من 413 خطوة

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

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

What is the FLAGS Register?

The FLAGS register (EFLAGS in 32-bit, RFLAGS in 64-bit) is a special register where individual bits record the result of the most recent operation.

Why Flags Matter

The CPU has no boolean type. Instead, instructions set flag bits, and conditional jumps read them. Flags are the glue between arithmetic and control flow.

The Zero Flag (ZF)

ZF is set to 1 when the result of an operation is zero. It is the basis of equality tests.

cmp eax, ebx   ; sets ZF if eax == ebx

The Carry Flag (CF)

CF is set when an unsigned operation overflows out of the most significant bit, e.g. an addition that exceeds the register width.

add al, 1      ; CF set if al was 0xFF

The Sign Flag (SF)

SF copies the most significant bit of the result, indicating a negative value in signed interpretation.

The Overflow Flag (OF)

OF is set when a signed operation produces a result too large or small for the destination, i.e. signed overflow.

How CMP Works

CMP a, b performs a - b but discards the result, keeping only the flags. This lets you test relationships without changing operands.

cmp eax, 10

TEST for Bit Checks

TEST a, b computes a bitwise AND, discards the result, and sets flags, commonly used to check if a value is zero or test specific bits.

test eax, eax  ; ZF set if eax == 0

Flags Drive Conditional Jumps

Conditional jumps read flags:

  • JE/JZ: jump if ZF=1
  • JNE/JNZ: jump if ZF=0
  • JC: jump if CF=1
  • JG: signed greater (uses ZF, SF, OF)

Signed vs Unsigned Conditions

Signed comparisons use SF and OF; unsigned comparisons use CF. Choosing the wrong jump (JA vs JG) is a classic bug.

Directly Affecting Flags

Some instructions set or clear flags explicitly, like STC (set carry) and CLC (clear carry), useful before multi-precision arithmetic.

clc            ; clear carry before add chain

Quick Check

Test your understanding of CPU flags.

Recap

You learned the FLAGS register:

  • ZF zero, CF unsigned overflow, SF sign, OF signed overflow
  • CMP and TEST set flags without storing results
  • Conditional jumps branch on flag state
  • Match signed/unsigned jumps to the comparison
البدء مجانًا

تعلم Assembly مع معلم ذكاء اصطناعي — مجانًا

اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.

الدورات
12
الدروس
48

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

هل درس «سجل FLAGS وبتّات الحالة» مجاني؟

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

ماذا ستتعلم في «سجل FLAGS وبتّات الحالة»؟

استكشف سجل EFLAGS/RFLAGS وتعرّف إلى كيفية ضبط تعليمات الحساب والمقارنة لرايات الحالة مثل ZF وCF وSF وOF، التي تتحكم في كل قرار شرطي. تتمرن على Assembly Language & x86 Low-Level Systems Programming مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

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

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

كم من الوقت يستغرق درس «سجل FLAGS وبتّات الحالة»؟

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

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

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

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

  1. تبسيط سجلات x86
  2. أنماط عنونة الذاكرة
  3. تمثيل البيانات وأنواعها
  4. سجل FLAGS وبتّات الحالة
← العودة إلى Assembly Language & x86 Low-Level Systems Programming