BM

4.3 Bit Manipulation

Understanding binary shifts and bitwise operations for monitoring and control systems

Learning Objectives

By the end of this lesson, you will be able to:

  • Show understanding of and perform binary shifts: logical, arithmetic & cyclic
  • Understand left shift and right shift operations
  • Apply bitwise operations (AND, OR, XOR) for checking, setting, and clearing bits
  • Use bit masking to control devices in monitoring and control systems
  • Write assembly language instructions for bit manipulation (LSL, LSR)
  • Trace bitwise operations and predict results
  • Understand how each bit in a register can be used as a flag in control systems

Key Terms

Bit Manipulation

Operations that work on individual bits within binary values

Binary Shift

Moving bits stored in a register a given number of places within the register

Logical Shift

Bits shifted out of register are replaced with zeros

Arithmetic Shift

Sign of number is preserved during shift operations

Cyclic Shift

No bits are lost during a shift; bits shifted out are introduced at the other end

Bit Masking

Using a mask with logical operators to identify, remove or set a single bit or group of bits

AND Operation

Bitwise operation used to check if a bit has been set

OR Operation

Bitwise operation used to set a bit to 1

XOR Operation

Bitwise operation used to clear a bit that has been set

LSL (Logical Shift Left)

Assembly instruction to shift bits logically n places to the left

LSR (Logical Shift Right)

Assembly instruction to shift bits logically n places to the right

Flag

Individual bit in a register used to represent status or condition

Bit Manipulation Fundamentals

Bit manipulation involves working with individual bits within binary values. These operations are fast, simple, and essential for low-level programming and hardware control.

Assembly Language Bit Operations

Label Instruction Explanation
AND #n / Bn / £n Bitwise AND operation of the contents of ACC with the operand
AND <address> Bitwise AND operation of the contents of ACC with the contents of <address>
XOR #n / Bn / £n Bitwise XOR operation of the contents of ACC with the operand
XOR <address> Bitwise XOR operation of the contents of ACC with the contents of <address>
OR #n / Bn / £n Bitwise OR operation of the contents of ACC with the operand
OR <address> Bitwise OR operation of the contents of ACC with the contents of <address>
LSL #n Bits in ACC are shifted logically n places to the left. Zeros are introduced on the right hand end
LSR #n Bits in ACC are shifted logically n places to the right. Zeros are introduced on the left hand end
<Label>: <opcode> <operand> Labels an instruction
<Label>: <data> Gives a symbolic address <label> to the memory location with contents <data>

Notation Explained

ACC denotes Accumulator, IX denotes Index Register, # denotes a denary number (e.g. #123), B denotes a binary number (e.g. B01001010), & denotes a hexadecimal number (e.g. &4)

Bit Manipulation to Control Devices

Bit Masking

  • Allows checking, setting and resetting individual bits within a binary value
  • Bitwise operations are fast and simple operations on binary data
  • Each binary digit is treated individually
  • Advantage: speeds up processing and requires reduced processing

Applications

  • Useful in simple control systems where individual bits are used as flags
  • Substantial processing efficiency can be gained
  • Widely used in networking when using subnet masks
  • A mask is a number used with logical operators to identify, remove or set bits

Real-Life Example: Home Security System

Think of an 8-bit register controlling a home security system:

Bit Assignments:
  • Bit 0: Front door sensor (1 = open, 0 = closed)
  • Bit 1: Back door sensor
  • Bit 2: Window sensor
  • Bit 3: Motion detector
  • Bit 4: Alarm armed status
  • Bit 5: System power
  • Bit 6: Notification enabled
  • Bit 7: Battery status
Operations:
// Check if front door is open
AND #B00000001
// Turn on alarm system
OR #B00010000
// Clear motion detector flag
XOR #B00001000

Activity 1: Understanding Bit Operations

For each scenario below, identify which bitwise operation (AND, OR, XOR) would be most appropriate:

  1. You need to check if Bit 3 (position 3) in an 8-bit register is set to 1
  2. You want to set Bit 5 (position 5) to 1 without affecting other bits
  3. You need to toggle Bit 0 (position 0) from 0 to 1 or 1 to 0
  4. You want to clear Bit 2 (position 2) that was previously set to 1
  5. You need to extract only the lower 4 bits of a byte (ignore the upper 4 bits)
Solution:
  1. AND operation - Use AND with a mask that has 1 only at Bit 3 (e.g., AND #B00001000). If result is non-zero, bit was set.
  2. OR operation - Use OR with a mask that has 1 at Bit 5 (e.g., OR #B00100000). Other bits remain unchanged.
  3. XOR operation - Use XOR with a mask that has 1 at Bit 0 (e.g., XOR #B00000001). Toggles 0→1 or 1→0.
  4. XOR operation - Use XOR with a mask that has 1 at Bit 2 (e.g., XOR #B00000100). Clears a set bit.
  5. AND operation - Use AND with mask #B00001111. Upper 4 bits become 0, lower 4 bits preserved.

Check Your Understanding: Bit Fundamentals

Answer
  • [1 mark] Speed up processing by performing operations directly on binary data
  • [1 mark] Requires reduced or less processing to perform tasks as it requires just few binary tricks
  • [Additional] Simple and efficient way to control individual bits without affecting others
Answer
  • [1 mark] Bits in the accumulator (ACC) are shifted logically n places to the left
  • [1 mark] Zeros are introduced on the right-hand end of the register
  • [Additional] The instruction format is LSL #n where n specifies how many places to shift
Answer
  • [1 mark] Useful in simple control systems where individual bits are used as flags
  • [1 mark] Widely used in networking when using subnet masks
  • [Additional] Also used in graphics programming, embedded systems, and device drivers
Answer
  • [1 mark] AND #n performs bitwise AND with an immediate value (the number n itself)
  • [1 mark] AND <address> performs bitwise AND with the contents of a memory location
  • [Additional] The first uses the value directly, the second fetches the value from memory first
Answer
  • [1 mark] They work directly on binary data at the hardware level
  • [1 mark] Each binary digit is treated individually, making operations predictable and efficient
  • [Additional] Processors have built-in circuitry for these operations, making them execute in a single clock cycle

Monitoring and Control Systems

In monitoring and control systems, each bit in a register can be used as a flag to represent the status of different sensors or devices. Bitwise operations allow us to efficiently manage these flags.

Bitwise Operations in Control Systems

Check Bits

Find the value of a bit (AND operation)

Set Bits

Set the bit/bits to 1 (OR operation)

Clear Bits

Set the bit/bits to 0 (XOR operation)

Toggle Bits

Set a bit/bits to the binary opposite (XOR operation)

Bitwise AND

Used to check if a bit has been set. If you AND a value with a mask containing 1 at the target bit position, the result will be non-zero if the bit was set.

Example:

Check if bit 2 is set: AND #B00000100

Bitwise OR

Used to set a bit to 1. If you OR a value with a mask containing 1 at the target position, that bit becomes 1 regardless of its previous value.

Example:

Set bit 3 to 1: OR #B00001000

Bitwise XOR

Used to clear a bit that has been set. If you XOR a value with a mask containing 1 at the target position, that bit toggles (0→1 or 1→0).

Example:

Clear bit 1: XOR #B00000010

Real-Life Example: Factory Control System

Imagine a factory with 8 machines. Each bit in an 8-bit register represents whether a machine needs maintenance:

Register: 01100101
0
1
1
0
0
1
0
1

Machines 1, 2, 5, 8 need maintenance (bits at positions 7, 6, 2, 0)

Operations:
Check Machine 3:

AND #B00100000 → Result 0 → No maintenance needed

Mark Machine 4 for maintenance:

OR #B00010000 → Bit 4 becomes 1

Clear Machine 2 maintenance:

XOR #B01000000 → Bit 6 toggles from 1 to 0

Assembly Language Examples

Setting All Bits To Zero

LDD 0034
AND #B00000000
STO 0034

Loads byte from address 0034, uses AND with all zeros to convert each bit to 0, stores back.

Toggling One Bit

LDD 0034
XOR #B00000001
STO 0034

Toggles value of bit in position 0 (LSB) using XOR with mask 00000001.

Setting One Bit to 1

LDD 0034
OR #B00000100
STO 0034

Sets flag represented by bit in position 2 to 1. All other bits remain unchanged.

Interactive Bit Manipulation Simulator

Experiment with bitwise operations on an 8-bit register. Try different masks and see the results:

Initial Register Value
1
0
0
1
0
0
1
1
Operation & Mask
Result

Perform an operation to see the result...

Activity 2: Control System Programming

A temperature monitoring system uses an 8-bit register where each bit represents a different sensor (bit 0 = sensor 1, bit 1 = sensor 2, etc.). Write assembly code to perform the following tasks:

  1. Check if sensor 3 (bit 2) has detected overheating (bit = 1)
  2. Set sensor 5 (bit 4) to indicate it needs calibration
  3. Toggle the alarm status (bit 7) to opposite of current state
  4. Clear the maintenance flag for sensor 2 (bit 1)
  5. Reset all sensors to 0 (normal state)
Solution:
1. Check sensor 3:
LDD SensorRegister
AND #B00000100 ; Mask with 1 at bit 2
; If result ≠ 0, sensor 3 is overheating
2. Set sensor 5 calibration flag:
LDD SensorRegister
OR #B00010000 ; Mask with 1 at bit 4
STO SensorRegister
3. Toggle alarm status:
LDD SensorRegister
XOR #B10000000 ; Mask with 1 at bit 7
STO SensorRegister
4. Clear sensor 2 maintenance flag:
LDD SensorRegister
XOR #B00000010 ; Mask with 1 at bit 1
STO SensorRegister
5. Reset all sensors:
LDD SensorRegister
AND #B00000000 ; Mask with all zeros
STO SensorRegister

Check Your Understanding: Monitoring & Control

Answer
  • [1 mark] Use an 8-bit register where each bit represents one sensor
  • [1 mark] When a sensor's data is processed, set its corresponding bit to 1
  • [1 mark] Use AND to check if a bit has been set, OR to set a bit, XOR to clear a bit
  • [Additional] This provides an efficient way to track multiple status flags in a single byte
Answer
LDD 0034
XOR #B00000001
STO 0034

Explanation: XOR with mask 00000001 toggles bit 0 (0→1 or 1→0) while leaving other bits unchanged.

Answer
LDD 0034
OR #B00000100
STO 0034

Explanation: OR with mask 00000100 sets bit 2 to 1 regardless of its previous value. Other bits remain unchanged because OR with 0 leaves them as they were.

Answer
  • [1 mark] To isolate and examine the value of a specific bit (bit 1 in this case)
  • [1 mark] This technique extracts a single bit's value by clearing all other bits to 0
  • [Additional] After this operation, the accumulator will be 0 if bit 1 was 0, or 2 (00000010) if bit 1 was 1
Answer
  • [1 mark] XOR toggles a bit: 0→1 or 1→0
  • [1 mark] If you know a bit is set (1), XOR with 1 will clear it (1→0)
  • [1 mark] AND could also clear a bit (AND with 0 at that position), but would require knowing the exact current state of other bits to preserve them
  • [Additional] XOR with mask 1 at target position is simpler when you want to toggle or clear a specific known bit

Binary Shifts

Binary shift involves moving bits stored in a register a given number of places within the register. Each bit within register may be used for a different purpose.

Types of Binary Shifts

Logical Shift

Bits shifted out of register are replaced with zeros. Used for unsigned numbers.

Left Logical Shift

Moves each bit to left by one. Vacant least significant bit (LSB) is filled with zero and most significant bit (MSB) is discarded.

MSB Left Logical Shift LSB
1 0 1 1 0 0 1 0
Shift left 1 position
0 1 1 0 0 1 0 0

MSB (1) discarded, LSB filled with 0. Effectively multiplies by 2 for each shift.

Right Logical Shift

Moves each bit to the right by one. Least significant bit is discarded and vacant MSB is filled with zero.

MSB Right Logical Shift LSB
1 0 1 1 0 0 1 0
Shift right 1 position
0 1 0 1 1 0 0 1

LSB (0) discarded, MSB filled with 0. Effectively divides by 2 for each shift (integer division).

Arithmetic Shift

Sign of number is preserved. Used for signed numbers (two's complement).

Right Arithmetic Shift

Moves each bit to right by one. Least significant bit is discarded and vacant MSB is filled with value of previous (now shifted one position to right) MSB.

MSB (Sign) Right Arithmetic Shift LSB
1 0 1 1 0 0 1 0
Shift right 1 position (preserve sign)
1 1 0 1 1 0 0 1

MSB (sign bit) is preserved and copied to the next position. Negative numbers remain negative after division.

Cyclic Shift

No bits are lost during a shift. Bits shifted out of one end of register are introduced at other end of register.

Cyclic Shift Example

An 8-bit register containing binary value 10101111 shifted left cyclically three places:

Original: 1 0 1 0 1 1 1 1
1 0 1 0 1 1 1 1
Shift left cyclically 3 places
0 1 1 1 1 1 0 1

Result: 01111101. Bits 1,0,1 shifted out from left end are introduced at right end.

Logical Shifts in Assembly Language Programming

Instruction Explanation
LSL n Bits in ACC are shifted logically n places to the left. Zeros are introduced on the right-hand end
LSR n Bits in ACC are shifted logically n places to the right. Zeros are introduced on the left-hand end

Important Note

Shifts are always performed on the ACC (Accumulator). The operand n specifies how many places to shift.

Real-Life Example: Fast Multiplication & Division

Binary shifts are used in calculators and processors for fast arithmetic:

Multiplication by 4
; Multiply number in ACC by 4
LSL #1 ; Multiply by 2
LSL #1 ; Multiply by 2 again
; Result: original × 4

Each left shift multiplies by 2. Two left shifts = multiply by 4.

Division by 8
; Divide number in ACC by 8
LSR #1 ; Divide by 2
LSR #1 ; Divide by 2 again
LSR #1 ; Divide by 2 again
; Result: original ÷ 8

Each right shift divides by 2 (integer division). Three right shifts = divide by 8.

Interactive Binary Shift Simulator

Experiment with different types of binary shifts. Enter a binary number and see how it changes:

Input & Shift Type
Visual Representation
1
1
0
1
1
0
1
0
Original: 11011010 (218 decimal)
Shift Result

Perform a shift to see the result...

Activity 3: Binary Shift Calculations

Perform the following binary shift operations and show the results:

  1. Logical left shift of B01101001 by 2 positions
  2. Logical right shift of B11001100 by 3 positions
  3. Arithmetic right shift of B10011001 (assuming two's complement) by 1 position
  4. Cyclic left shift of B10110011 by 4 positions
  5. What assembly instruction would perform logical right shift by 3 positions on the accumulator?
Solution:
  1. B01101001 left shift 2:
    Original: 01101001
    Shift 1: 11010010 (0 introduced at LSB)
    Shift 2: 10100100 (0 introduced at LSB)
    Result: 10100100
  2. B11001100 right shift 3:
    Original: 11001100
    Shift 1: 01100110 (0 introduced at MSB)
    Shift 2: 00110011 (0 introduced at MSB)
    Shift 3: 00011001 (0 introduced at MSB)
    Result: 00011001
  3. B10011001 arithmetic right shift 1:
    Original: 10011001 (MSB=1, negative number)
    MSB (1) preserved and copied: 11001100
    LSB (1) discarded
    Result: 11001100 (sign preserved)
  4. B10110011 cyclic left shift 4:
    Original: 10110011
    First 4 bits (1011) move to right end
    Result: 00111011
  5. Assembly instruction:
    LSR #3

Check Your Understanding: Binary Shifts

Answer
  • [1 mark] Logical right shift fills the vacant MSB with zero
  • [1 mark] Arithmetic right shift fills the vacant MSB with the value of the previous MSB (sign bit)
  • [1 mark] Arithmetic shift preserves the sign of the number (for signed/two's complement numbers)
  • [Additional] Logical shift is for unsigned numbers, arithmetic shift is for signed numbers
Answer
  • [1 mark] No bits are lost during a cyclic shift
  • [1 mark] Bits shifted out of one end of the register are introduced at the other end
  • [Additional] This creates a circular rotation of bits rather than discarding them
Answer
  • [1 mark] Multiplication by 2
  • [1 mark] Each left shift doubles the value (as long as no overflow occurs)
  • [Additional] For example, binary 00000101 (5) shifted left becomes 00001010 (10)
Answer
  • [1 mark] 4 positions
  • [1 mark] Each left shift multiplies by 2, so 2⁴ = 16 requires 4 shifts
  • [Additional] In assembly: LSL #4 would multiply by 16
Answer
  • [1 mark] LSR n (Logical Shift Right)
  • [1 mark] Bits in ACC are shifted logically n places to the right. Zeros are introduced on the left-hand end
  • [Additional] The LSB is discarded with each shift

Exam Practice

Practice exam-style questions to test your understanding of bit manipulation concepts.

Exam Style Question from PDF

(i) XOR Operation

Current contents of the ACC are:

1
0
0
1
0
0
1
1

Show result after execution of: XOR B00011111

(ii) AND Operation

Current contents of ACC are:

1
0
0
1
0
0
1
1

Show the result after the execution of: AND B11110000

Activity 4: Complete Exam Question

A temperature control system uses an 8-bit register to monitor 8 zones. Each bit represents whether a zone's temperature is above threshold (1) or normal (0). The current register value is B01101001.

  1. Which zones (bit positions) are currently above threshold?
  2. Write assembly code to set zone 4 (bit 3) to above threshold without affecting other zones
  3. Write assembly code to check if zone 7 (bit 6) is above threshold
  4. The register is logically shifted left by 2 positions. What is the new value and what does it represent?
  5. Explain why a cyclic shift might be used instead of a logical shift in some control systems
Solution:
  1. Zones above threshold: Bits at positions where value is 1:
    • Bit 0 (zone 1): 1
    • Bit 3 (zone 4): 1
    • Bit 5 (zone 6): 1
    • Bit 6 (zone 7): 1
    So zones 1, 4, 6, 7 are above threshold.
  2. Set zone 4:
    LDD TempRegister
    OR #B00001000 ; Mask with 1 at bit 3
    STO TempRegister
  3. Check zone 7:
    LDD TempRegister
    AND #B01000000 ; Mask with 1 at bit 6
    ; If result ≠ 0, zone 7 is above threshold
  4. Logical shift left by 2:
    Original: 01101001
    Shift 1: 11010010
    Shift 2: 10100100
    New value: 10100100
    This represents zones 2, 5, 7 above threshold (but note: original zones have shifted left by 2 positions)
  5. Cyclic vs Logical shift:
    • Cyclic shift preserves all information - no bits are lost
    • In control systems, cyclic shifts might be used for rotating through different monitoring modes or for circular buffer implementations
    • Logical shift loses information at the ends, which might not be desirable if all bits represent important status flags

Check Your Understanding: Exam Practice

Answer
Value 1 1 0 0 1 1 0 0
Mask 0 0 1 1 0 0 1 1
AND Result 0 0 0 0 0 0 0 0

Result: 00000000 (All bits become 0 because mask has 0 wherever value has 1, and vice versa)

Answer
ACC 0 1 0 1 0 1 0 1
XOR Mask 1 1 1 1 1 1 1 1
Result 1 0 1 0 1 0 1 0

Result: 10101010 (All bits are inverted/toggled because XOR with 1 flips the bit)

Answer
  • [1 mark] Original: B00010100 = 20 decimal
  • [1 mark] After 1 right shift: B00001010 = 10 decimal (20 ÷ 2)
  • [1 mark] After 2 right shifts: B00000101 = 5 decimal (20 ÷ 4)
  • [Additional] Each logical right shift divides by 2 (integer division)
Answer
  • [1 mark] AND #B00000000 clears ALL bits to 0
  • [1 mark] AND #B11110000 clears only the lower 4 bits (bits 0-3) to 0
  • [1 mark] AND #B11110000 preserves the upper 4 bits (bits 4-7) while clearing the lower 4 bits
  • [Additional] This is useful when you want to clear only specific bits while preserving others
Answer
  • [1 mark] OR #B00001111 sets bits 0-3 to 1 regardless of their previous state
  • [1 mark] XOR #B00001111 toggles bits 0-3 (0→1 or 1→0)
  • [1 mark] OR always results in 1s in positions where mask has 1, XOR flips bits where mask has 1
  • [Additional] OR is for setting bits, XOR is for toggling or clearing set bits

Key Takeaways

  • Bit manipulation involves working with individual bits within binary values using bitwise operations
  • Bit masking uses a mask with logical operators to identify, remove or set specific bits
  • AND operation is used to check if a bit has been set (1 AND 1 = 1, others = 0)
  • OR operation is used to set a bit to 1 (any OR 1 = 1)
  • XOR operation is used to clear a bit that has been set (1 XOR 1 = 0, 0 XOR 1 = 1)
  • Binary shifts move bits within a register: left shifts multiply by 2, right shifts divide by 2
  • Logical shifts fill vacant positions with zeros
  • Arithmetic shifts preserve the sign bit for signed numbers
  • Cyclic shifts rotate bits with no loss (bits shifted out reappear at the other end)
  • LSL #n shifts bits logically n places to the left (zeros introduced at LSB)
  • LSR #n shifts bits logically n places to the right (zeros introduced at MSB)
  • In monitoring and control systems, each bit in a register can be used as a flag for different sensors or devices
  • Bit operations are fast and efficient because they work directly on binary data at the hardware level
  • Applications include control systems, networking (subnet masks), graphics programming, and embedded systems

Question Bank

Marking Scheme & Answer
Logical Shift:
  • Bits shifted out of register are replaced with zeros
  • Used for unsigned numbers
  • Left shift multiplies by 2, right shift divides by 2
  • Example: LSL #2 shifts left 2 places, zeros at LSB
Arithmetic Shift:
  • Sign of number is preserved
  • Used for signed numbers (two's complement)
  • Right shift fills MSB with previous sign bit
  • Preserves negative/positive status
Cyclic Shift:
  • No bits are lost during shift
  • Bits shifted out are introduced at other end
  • Creates rotation of bits
  • Useful for circular buffers or rotating status
Marking Scheme & Answer
  • [1 mark] Each bit in a register can be used as a flag representing status of different sensors or devices
  • [1 mark] AND operation checks if a bit has been set (e.g., sensor triggered)
  • [1 mark] OR operation sets a bit to 1 (e.g., mark device as needing maintenance)
  • [1 mark] XOR operation clears a bit that has been set (e.g., reset alarm status)
  • [Additional] Example: 8-bit register for 8-zone temperature system, each bit = zone above threshold
Marking Scheme & Answer
a) Set bit 5 to 1:
LDD 0200
OR #B00100000
STO 0200
b) Clear bit 2 to 0 (assuming it might be 1):
LDD 0200
XOR #B00000100
STO 0200
c) Check if bit 7 is set (without changing value):
LDD 0200
AND #B10000000
; If result ≠ 0, bit 7 is set
Marking Scheme & Answer
  • [1 mark] Speed up processing - operations are fast and simple at hardware level
  • [1 mark] Reduced processing requirements - efficient use of processor resources
  • [1 mark] Efficient storage - multiple status flags can be stored in a single byte
  • [1 mark] Direct hardware control - essential for device drivers and embedded systems
  • [Additional] Fast arithmetic - shifts provide quick multiplication/division by powers of 2
Marking Scheme & Answer
a) B01101010 AND B11001100
01101010
11001100 AND
01001000 = B01001000
b) B10110011 OR B01100110
10110011
01100110 OR
11110111 = B11110111
c) B11001100 XOR B00110011
11001100
00110011 XOR
11111111 = B11111111
Marking Scheme & Answer
  • [1 mark] Left logical shift multiplies by 2 for each shift position
  • [1 mark] Example: B00000101 (5) LSL #1 = B00001010 (10) = 5 × 2
  • [1 mark] Right logical shift divides by 2 (integer division) for each shift position
  • [1 mark] Example: B00010100 (20) LSR #2 = B00000101 (5) = 20 ÷ 4
  • [Additional] Assembly: LSL #3 multiplies by 8 (2³), LSR #4 divides by 16 (2⁴)
Marking Scheme & Answer
LDD ControlRegister
AND #B00000111 ; Mask with 1s at bits 0-2
; Result contains only error code bits, all other bits = 0

Explanation: AND with 00000111 preserves bits 0-2 (error codes) and clears bits 3-7 to 0, isolating the error code.

Marking Scheme & Answer
  • [1 mark] Original: B10011001
  • [1 mark] Cyclic left shift 1: MSB (1) moves to LSB position
  • [Additional] Result: 00110011
Marking Scheme & Answer
  • [1 mark] MSB (most significant bit) is the sign bit in two's complement
  • [1 mark] During arithmetic right shift, the MSB (sign bit) is preserved and copied to the next position
  • [1 mark] This ensures negative numbers remain negative after division by 2
  • [Additional] Example: B10011001 (-103) arithmetic right shift = B11001100 (-52), sign preserved
Marking Scheme & Answer
  • [1 mark] Subnet masking uses AND operations to extract network addresses from IP addresses
  • [1 mark] Protocol headers use individual bits as flags for different options and settings
  • [1 mark] Efficient processing of network packets requires fast bit-level operations
  • [Additional] Example: IP address 192.168.1.100 AND subnet mask 255.255.255.0 gives network address 192.168.1.0