El registro FLAGS y los bits de estado
Explore el registro EFLAGS/RFLAGS: cómo las instrucciones aritméticas y de comparación establecen indicadores de estado como ZF, CF, SF y OF, que controlan cada decisión condicional.
El registro FLAGS y los bits de estado es una lección gratuita de Assembly Language & x86 Low-Level Systems Programming en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Assembly Language & x86 Low-Level Systems Programming, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Assembly Language & x86 Low-Level Systems Programming incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
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 == ebxThe 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 0xFFThe 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, 10TEST 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 == 0Flags Drive Conditional Jumps
Conditional jumps read flags:
JE/JZ: jump if ZF=1JNE/JNZ: jump if ZF=0JC: jump if CF=1JG: 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 chainQuick Check
Test your understanding of CPU flags.
Recap
You learned the FLAGS register:
- ZF zero, CF unsigned overflow, SF sign, OF signed overflow
CMPandTESTset flags without storing results- Conditional jumps branch on flag state
- Match signed/unsigned jumps to the comparison
Preguntas frecuentes
¿La lección «El registro FLAGS y los bits de estado» es gratis?
Sí — el texto completo de «El registro FLAGS y los bits de estado» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Assembly Language & x86 Low-Level Systems Programming, actualiza a CoddyKit PRO. El curso de Assembly Language & x86 Low-Level Systems Programming incluye 4 lecciones en total.
¿Qué aprenderé en «El registro FLAGS y los bits de estado»?
Explore el registro EFLAGS/RFLAGS: cómo las instrucciones aritméticas y de comparación establecen indicadores de estado como ZF, CF, SF y OF, que controlan cada decisión condicional. Practicas Assembly Language & x86 Low-Level Systems Programming con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Assembly Language & x86 Low-Level Systems Programming?
No se requiere experiencia previa. Assembly Language & x86 Low-Level Systems Programming en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.
¿Cuánto tiempo toma la lección «El registro FLAGS y los bits de estado»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Assembly Language & x86 Low-Level Systems Programming?
Sí. Cada lección de Assembly Language & x86 Low-Level Systems Programming incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Registros x86 sin misterios
- Modos de direccionamiento de memoria
- Representación y tipos de datos
- El registro FLAGS y los bits de estado