Bit Manipulation

A Dr. Taylor Tutorial

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

Tutorials for Other Courses

Additional Links

Site Mirror

This is a mirror to be used when http://myweb.msoe.edu/taylor/, (EDU instead of US) is not available.