Hello,
I didnt realise that PCs still had an internal speaker but anyway...
*Basic steps
Initialise to make sound by sending 182 to port 43h.
Set frequency value (0h to FFFFh) to port 42h (lo byte first, hi byte second)
Start speaker make 2 lowest bits high in port 61h (must not affect other bits)
Note will play for as long as 2 lowest bits are high
*Sample Code
mov al,182 ;initialise 8253 for sound
out 43h,al
mov al,0FFh ;set frequency value lo byte
out 42h,al
mov al,0Fh ;set frequency value hi byte
out 42h,al
in al,61h ;enable sound (8255 chip)
or al,011b
out 61h,al
{wait for required duration of note}
in al,61h ;disable sound (8255 chip)
and al,11111100b
out 61h,al
*Now get out your calculator!
The 8284 oscilator chip oscillates at 1,193,180Hz (pulses per second)
the frequency value is the number of pulses that the 8253 timer chip waits before pulsing the speaker and this is how the note is produced.
to play an 'A' (440Hz) use the following value
1,193,180 / 440 = 2711
You can find out the frequencies for the rest of the notes at any good musitian store and then use the above formula to calculate their frequency value.
I hope this helps!
Straiph
0000:0000:0000:0000h
The people who have nothing to say and say it too loud have little knowledge, It's the quiet ones you need to worry about!