คำสั่งดำเนินการระดับบิตและเลื่อนบิต
เรียนรู้การจัดการบิตใน x86 อย่างเชี่ยวชาญด้วย AND, OR, XOR, NOT รวมถึงคำสั่งเลื่อนและหมุนบิตที่ใช้ทำมาสก์ สลับค่าแฟล็ก และคูณอย่างรวดเร็ว
คำสั่งดำเนินการระดับบิตและเลื่อนบิต เป็นบทเรียน Assembly Language & x86 Low-Level Systems Programming ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Assembly Language & x86 Low-Level Systems Programming และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Assembly Language & x86 Low-Level Systems Programming มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
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
เรียนรู้ Assembly ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “คำสั่งดำเนินการระดับบิตและเลื่อนบิต” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “คำสั่งดำเนินการระดับบิตและเลื่อนบิต” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Assembly Language & x86 Low-Level Systems Programming ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Assembly Language & x86 Low-Level Systems Programming มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “คำสั่งดำเนินการระดับบิตและเลื่อนบิต”
เรียนรู้การจัดการบิตใน x86 อย่างเชี่ยวชาญด้วย AND, OR, XOR, NOT รวมถึงคำสั่งเลื่อนและหมุนบิตที่ใช้ทำมาสก์ สลับค่าแฟล็ก และคูณอย่างรวดเร็ว คุณปฏิบัติ Assembly Language & x86 Low-Level Systems Programming ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Assembly Language & x86 Low-Level Systems Programming หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Assembly Language & x86 Low-Level Systems Programming บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “คำสั่งดำเนินการระดับบิตและเลื่อนบิต” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Assembly Language & x86 Low-Level Systems Programming นี้ได้ไหม
ได้ บทเรียน Assembly Language & x86 Low-Level Systems Programming ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- คำสั่งย้ายข้อมูล (MOV, PUSH, POP)
- การดำเนินการทางคณิตศาสตร์และตรรกะ
- การกระโดดตามเงื่อนไขและลูป
- คำสั่งดำเนินการระดับบิตและเลื่อนบิต