0Pricing
Assembly Language & x86 Low-Level Systems Programming · レッスン

ビット演算とシフト命令

x86のビット操作を習得します。マスク処理、フラグの切り替え、高速な乗算に使われるAND、OR、XOR、NOT、シフト命令、ローテート命令を学びます。

「ビット演算とシフト命令」はCoddyKit上の無料Assembly Language & x86 Low-Level Systems Programmingレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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 nibble

OR for Setting Bits

OR forces specific bits to 1 while leaving others unchanged.

or eax, 0x80    ; set bit 7

XOR for Toggling

XOR flips bits where the mask is 1. A famous idiom zeroes a register quickly:

xor eax, eax    ; eax = 0

NOT for Inversion

NOT flips every bit (ones complement).

not eax

Logical Shift Left (SHL)

SHL shifts bits left, filling with zeros. Each shift left multiplies an unsigned value by two.

shl eax, 1      ; eax = eax * 2

Logical Shift Right (SHR)

SHR shifts right with zero fill, dividing an unsigned value by powers of two.

shr eax, 2      ; unsigned eax / 4

Arithmetic Shift (SAR)

SAR shifts right but preserves the sign bit, so it divides signed values correctly.

sar eax, 1      ; signed eax / 2

Rotate 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, 4

Bit 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 eax

Common Idioms

Handy patterns:

  • xor reg, reg to zero
  • shl/shr for power-of-two math
  • and reg, mask to 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

よくある質問

「ビット演算とシフト命令」レッスンは無料ですか?

はい。「ビット演算とシフト命令」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、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を演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Assembly Language & x86 Low-Level Systems Programmingを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのAssembly Language & x86 Low-Level Systems Programmingは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「ビット演算とシフト命令」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このAssembly Language & x86 Low-Level Systems Programmingレッスンでコードを書いて実行できますか?

はい。すべてのAssembly Language & x86 Low-Level Systems Programmingレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. データ移動命令(MOV、PUSH、POP)
  2. 算術演算と論理演算
  3. 条件分岐とループ
  4. ビット演算とシフト命令
← Assembly Language & x86 Low-Level Systems Programmingに戻る