Error in Embedded C code for Motor Shield

In the absence of tools like logic analyzers, I'd put LEDs on the relevant signals and insert big delays in your code, so that you can more-or-less single-step through your logic.

void debug(char *s) {
  Serial.println(s);  // print info
  while (Serial.read() < 0)
    ;  // wait for next step
}

  :

  for(int i = 0;i<8;i++)  {
    PORTD &= ~0x10;//Clock, low
    debug("Clock Low");
    if( (!!(data & (1<<i))) == 0 ) {
      PORTB &= ~0x01;//Data, low
      debug("data Low");
    } else {
      PORTB |= 0x01;//Data, high
      debug("data high");
    }
    PORTD |= 0x10;//Clock, high
    debug("Clock high");
  }

So... You have the ancient and long-discontinued V1 Adafruit Motor Shield, right? Not the newer version that uses a completely different IO mechanism? The lack of "stackable headers" will make attaching LEDs more difficult, I guess.