how to drive a speaker from a r2r ladder

 digitalWrite(pin0, /*what should go here*/);
  digitalWrite(pin1, /*and here*/);
  ...
  digitalWrite(pin7, /*and here?*/);

If you use digitalWrite, your output sample rate will be quite low - all the mapping of the pins slows the function down.
Have a look around the forum for direct port manipulation