0Pricing
Assembly Language & x86 Low-Level Systems Programming · Lekcja

Rejestr FLAGS i bity stanu

Poznaj rejestr EFLAGS/RFLAGS: dowiedz się, jak instrukcje arytmetyczne i porównania ustawiają flagi stanu, takie jak ZF, CF, SF i OF, które sterują każdą decyzją warunkową.

Rejestr FLAGS i bity stanu to bezpłatna lekcja Assembly Language & x86 Low-Level Systems Programming na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Assembly Language & x86 Low-Level Systems Programming, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Assembly Language & x86 Low-Level Systems Programming zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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

Często zadawane pytania

Czy lekcja „Rejestr FLAGS i bity stanu” jest bezpłatna?

Tak — pełny tekst „Rejestr FLAGS i bity stanu” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Assembly Language & x86 Low-Level Systems Programming, przejdź na CoddyKit PRO. Kurs Assembly Language & x86 Low-Level Systems Programming zawiera 4 lekcji w sumie.

Co nauczysz się w „Rejestr FLAGS i bity stanu”?

Poznaj rejestr EFLAGS/RFLAGS: dowiedz się, jak instrukcje arytmetyczne i porównania ustawiają flagi stanu, takie jak ZF, CF, SF i OF, które sterują każdą decyzją warunkową. Ćwiczysz Assembly Language & x86 Low-Level Systems Programming z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Assembly Language & x86 Low-Level Systems Programming?

Nie wymagamy żadnego doświadczenia. Assembly Language & x86 Low-Level Systems Programming w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Rejestr FLAGS i bity stanu”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Assembly Language & x86 Low-Level Systems Programming?

Tak. Każda lekcja Assembly Language & x86 Low-Level Systems Programming zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Rejestry x86 bez tajemnic
  2. Tryby adresowania pamięci
  3. Reprezentacja danych i typy
  4. Rejestr FLAGS i bity stanu
← Powrót do Assembly Language & x86 Low-Level Systems Programming