
#include <8051.h>

static inline void delay(void)
{
  unsigned char i = 0xbe;       // 0x00 -> 256
  unsigned char k = 0xaf;       // 0x00 -> 256

  do
  { 
    do
    { 
      __asm NOP __endasm;
    } while ( --i );
  } while( --k );
}


void main(void)
{
  while( 2 )
  {
    unsigned char sanddrop;     // highest bit on top
    unsigned char sandbottom;   // lowest bit at bottom
    for( sandbottom = 0x00; !(sandbottom & 0x80); sandbottom <<= 1, sandbottom |= 0x01 ) // C is ugly too!
    {
      for( sanddrop = 0x80; sanddrop; sanddrop >>= 1 )
      {
        P1 = sanddrop | sandbottom;
        delay();
      }
    }  
  }  
}