Table of Contents

Bit Manipulation

When programming in assembly language, it is often helpful to manipulate individual bits.

Shift and Rotate

Bit Manipulation

      sbi  PORTB, 7
      in  r16, PORTB
      ori r16, 0b10000000
      out PORTB, r16
      cbr  r16, 0x0f      ; Clears the four least significant bits
      clr r0
      com r0  ; Perform 2's complement on R0
poll:
      sbic PIND, 7  ; skips next instruction if bit 7 is cleared
      rjmp poll