Was this what you were looking for?
Generate square wave tones on P3.4 (or any pin) using a simple timer interrupt. Connect the pin via a resistor ladder (R-2R) or directly to an audio jack with a capacitor. at89c2051 projects
This project is the best starting point to understand Port 1 and Port 3 manipulation. Was this what you were looking for
unsigned char segment[] = 0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90; // Common anode // For common cathode, invert the bits: ~segment[i] & 0x7F invert the bits: ~segment[i] & 0x7F