;------------------------------ ; PC Speaker Sounds from MITCH AMES The speaker is controlled by bits 0 and 1 of the 8255A Programmable Peripheral Interface, and channel 2 of the 8253 timer. The PPI port (61h) settings are: bit 0: 0 Direct speaker control through bit 1 1 Speaker connected to 8253 timer channel 2 (Gated via bit 1) bit 1: 0 Speaker off 1 Speaker on The 8253 timer frequency is 1,193,180 Hz / 16_bit_divisor, giving a range of 18.2 Hz - 1.193 MHz. The timer is programmed by sending a control byte (10110110b for channel 2) to port 43h, followed by the divisor LSB and MSB to port 42h. .radix 16 ; Program 8253 timer, channel 2 cli ;no interrupts mov al,10110110b ;control byte out 43,al mov al,LSB ;frequency divisor LSB out 42,al mov al,MSB ;frequncy divisor MSB out 42,al ; Switch speaker on in al,61 ;get 8255 port contents or al,00000011b ;enable speaker, using 8253 out 61,al ; Wait CX clock ticks sti ;must allow clock interrupt push ds mov ax,40 ;point DS to BIOS mov ds,ax wait: mov ax,ds:[6C] ;get low word of tick counter wait1: cmp ax,ds:[6C] ;wait for it to change je wait1 loop wait ;count CX changes pop ds ; Switch speaker off in al,61 ;get 8255 port contents and al,11111100b ;disable speaker out 61,al