Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!gatech!lll-lcc!lll-crg!hoptoad!farren From: farren@hoptoad.UUCP Newsgroups: comp.sys.ibm.pc Subject: Re: Turning on sound and keyboard info. Message-ID: <1872@hoptoad.uucp> Date: Thu, 26-Feb-87 20:24:14 EST Article-I.D.: hoptoad.1872 Posted: Thu Feb 26 20:24:14 1987 Date-Received: Sat, 28-Feb-87 08:12:09 EST References: <262@crys.WISC.EDU> <2617@jade.BERKELEY.EDU> Reply-To: farren@hoptoad.UUCP (Mike Farren) Distribution: comp Organization: Nebula Consultants in San Francisco Lines: 37 Keywords: sound, keyboard The question was asked: how to put out a sound which will then run without processor intervention. On a standard IBM PC, this is done by placing a divisor value into one of the timer registers, and then enabling the speaker. Once you do this, the speaker will be toggled every time the timer overflows, and the timer will be reset to do the whole process over again. This continues until you explicitly turn off the speaker. Sample assembly code (not tested) for this operation is as follows: ;This routine turns on the speaker with a tone whose frequency is ((1/1193180) * divisor) hertz onspeaker: mov al, 0B6h ;select timer 2 out 043h, al ;Send to mode register in timer mov ax, divisor ;Select frequency out 042h, al ;Send LSB of divisor to timer mov al, ah out 042h, al ;Send MSB of divisor to timer in al, 061h ;Get current contents of control port mov byte ptr save_mode, al ; Save current contents somewhere or al, 03h ;Set bits to turn on speaker out 061h, al ;And do it ; This routine turns off the speaker offspeaker: mov al, byte ptr save_mode ;Get the old contents out 061h, al ;Turn the speaker off Hope this helps some. -- ---------------- "... if the church put in half the time on covetousness Mike Farren that it does on lust, this would be a better world ..." hoptoad!farren Garrison Keillor, "Lake Wobegon Days"