I guess what you're trying to build is an SPI interface.
have you looked at the example for the Qt401? http://www.arduino.cc/en/Tutorial/Qt401
there is an SPI routine written in the arduino language that has been working quite well.
otherwise you need to look into "Hardware SPI"
here is some c code from Peter Fleury that uses the SPI master built-in the atmega8
#define SPI_CHIP_SELECT PB2 // SS pin is used here, but any pin can be used
#define SPI_MOSI PB3 // SPI MOSI pin
#define SPI_SCK PB5 // SPI SCK pin
#define SPI_DDR DDRB // port used by SPI
uint8_t led = 2;
/* SPI port initialization (/SS, MOSI, SCK output, MISO input) */
SPI_DDR = _BV(SPI_CHIP_SELECT) + _BV(SPI_MOSI) + _BV(SPI_SCK);
/* SPI interrupt disabled, SPI port enabled, master mode, MSB first, SPI mode 3, SPI Clock = XTAL/4 */
SPCR = _BV(SPE) +_BV(MSTR) + _BV(CPOL) + _BV(CPHA);
PORTB &= ~_BV(SPI_CHIP_SELECT); // enable SPI device
SPDR = led; // send data to SPI device (turn LED on/off)
while (!(SPSR & _BV(SPIF))); // wait until write complets
PORTB |= _BV(SPI_CHIP_SELECT); // disable SPI device
led ^= 2; // toggle LED
delay(65535); // delay 0.1 seconds
consider that the clock used by this code will be in the region of 4 MHZ (the code mentions clock/4...)
let me know if this works for you