Instrucciones bit a bit y de desplazamiento
Domine la manipulación de bits en x86: AND, OR, XOR, NOT y las instrucciones de desplazamiento y rotación utilizadas para enmascarar, alternar indicadores y multiplicar rápidamente.
Instrucciones bit a bit y de desplazamiento 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.
Why Bit Operations?
Low-level code constantly manipulates individual bits: setting flags, packing fields, masking, and fast math. x86 provides dedicated bitwise and shift instructions.
AND for Masking
AND keeps only the bits set in both operands, the standard way to mask out unwanted bits.
and eax, 0x0F ; keep low nibbleOR for Setting Bits
OR forces specific bits to 1 while leaving others unchanged.
or eax, 0x80 ; set bit 7XOR for Toggling
XOR flips bits where the mask is 1. A famous idiom zeroes a register quickly:
xor eax, eax ; eax = 0NOT for Inversion
NOT flips every bit (ones complement).
not eaxLogical Shift Left (SHL)
SHL shifts bits left, filling with zeros. Each shift left multiplies an unsigned value by two.
shl eax, 1 ; eax = eax * 2Logical Shift Right (SHR)
SHR shifts right with zero fill, dividing an unsigned value by powers of two.
shr eax, 2 ; unsigned eax / 4Arithmetic Shift (SAR)
SAR shifts right but preserves the sign bit, so it divides signed values correctly.
sar eax, 1 ; signed eax / 2Rotate Instructions
ROL and ROR rotate bits around, wrapping the bit that falls off back in on the other side, used in hashing and crypto.
rol eax, 4Bit Test Instructions
BT copies a chosen bit into CF so you can test it, while BTS/BTR test and set/reset it.
bt eax, 3 ; CF = bit 3 of eaxCommon Idioms
Handy patterns:
xor reg, regto zeroshl/shrfor power-of-two mathand reg, maskto extract fields
Quick Check
Test your understanding of bit operations.
Recap
You learned bitwise and shift instructions:
- AND mask, OR set, XOR toggle, NOT invert
- SHL/SHR for unsigned power-of-two math
- SAR preserves sign for signed division
- ROL/ROR rotate; BT tests a bit into CF
Preguntas frecuentes
¿La lección «Instrucciones bit a bit y de desplazamiento» es gratis?
Sí — el texto completo de «Instrucciones bit a bit y de desplazamiento» 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 «Instrucciones bit a bit y de desplazamiento»?
Domine la manipulación de bits en x86: AND, OR, XOR, NOT y las instrucciones de desplazamiento y rotación utilizadas para enmascarar, alternar indicadores y multiplicar rápidamente. 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 «Instrucciones bit a bit y de desplazamiento»?
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
- Instrucciones de movimiento de datos (MOV, PUSH, POP)
- Operaciones aritméticas y lógicas
- Saltos condicionales y bucles
- Instrucciones bit a bit y de desplazamiento