Istruzioni bitwise e di shift
Padroneggi la manipolazione dei bit in x86: AND, OR, XOR, NOT e le istruzioni di shift e rotazione usate per mascherare, commutare i flag e moltiplicare rapidamente.
Istruzioni bitwise e di shift è una lezione Assembly Language & x86 Low-Level Systems Programming gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Assembly Language & x86 Low-Level Systems Programming, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Assembly Language & x86 Low-Level Systems Programming include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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
Impara Assembly con un tutor IA — gratis
Scrivi ed esegui vero codice nel tuo browser, ricevi aiuto istantaneo da un tutor IA disponibile 24/7, e riprendi da dove hai lasciato sul web o nell'app.
- Corsi
- 12
- Lezioni
- 48
Domande Frequenti
La lezione «Istruzioni bitwise e di shift» è gratuita?
Sì — il testo completo di «Istruzioni bitwise e di shift» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Assembly Language & x86 Low-Level Systems Programming, passa a CoddyKit PRO. Il corso Assembly Language & x86 Low-Level Systems Programming include 4 lezioni in totale.
Cosa imparerò in «Istruzioni bitwise e di shift»?
Padroneggi la manipolazione dei bit in x86: AND, OR, XOR, NOT e le istruzioni di shift e rotazione usate per mascherare, commutare i flag e moltiplicare rapidamente. Eserciti Assembly Language & x86 Low-Level Systems Programming con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Assembly Language & x86 Low-Level Systems Programming?
Non è richiesta alcuna esperienza precedente. Assembly Language & x86 Low-Level Systems Programming su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Istruzioni bitwise e di shift»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Assembly Language & x86 Low-Level Systems Programming?
Sì. Ogni lezione Assembly Language & x86 Low-Level Systems Programming include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Istruzioni per il movimento dei dati (MOV, PUSH, POP)
- Operazioni aritmetiche e logiche
- Salti condizionali e cicli
- Istruzioni bitwise e di shift