Table of Contents

Bit Manipulation

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

Shift and Rotate

Bit Manipulation

      sbi  PORTA, 7
      ldi  r16, PORTA
      
      out PORTA, 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