Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site cantor.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!gargoyle!cantor!mjm From: mjm@cantor.UUCP (Michael Markowitz) Newsgroups: net.micro.pc Subject: Re: Speaker control on XTs Message-ID: <166@cantor.UUCP> Date: Thu, 21-Nov-85 02:57:52 EST Article-I.D.: cantor.166 Posted: Thu Nov 21 02:57:52 1985 Date-Received: Sat, 23-Nov-85 00:56:46 EST References: <1686@uwmacc.UUCP> <125@rruxo.UUCP> Organization: Loyola Univ. of Chicago Dept. of Math Lines: 59 > > >... I am trying to > >access the speaker of my XT via assmebly language routines, and > >I am having a devil of a time. Any magazine or journal references > >that you might recommend? > > The speaker is accessed by a port number - use the IN and OUT instructions > to access it. I don't know exactly what port it is, but it should be in the > IBM Technical Reference Manual. Peter Norton has a few sample assembler > programs in his book, Inside The IBM PC. Chapter 3, listing 3.2. Norton > also goes into a little detail as to how this works. Here it is, the > speaker port is number 61 (hex). > First of all, port 61H is port B of the 8255A-5 PPI (programmable peripheral interface). If you start OUT'ing indescriminant data to that port you are probably going to disable your keyboard and parity checking--although you might get the speaker to go on at the same time! Actually you enable the ouput of timer channel 2 (which is fed to the speaker) by writing a 1 to bit 0 of this port. Bit 1 may be used to turn the speaker on and off. To get a specific frequency to sound you must program counter 2 of the timer. Try the following as an example (there are other ways to do this): middle_C dw 262 ;261.6 Hz mov al,0B6H ;select channel 2, mode 3 (square wave) out 43H,al ; send to timer (order 16-bit read) mov ax,34dcH ;calculate initial count (1.193MHz/262Hz) mov dx,12H div middle_C out 42H,al ;send LSB to counter 2 mov al,ah out 42H,al ; then send MSB in al,61H ;read data latched in output port B of PPI or al,3 ;enable timer channel 2 output and speaker out 61H,al ;send back to PPI (don't mess with other bits) mov bx,???? ;you'll have to choose appropriate values again: mov cx,???? ; here to generate the desired delay play: loop play ;(off the top of my head I estimate 64K dec bx ;iterations will give you .2 seconds on a PC) jnz again ;(this is using a bx=1, cx=0) in al,61H ;(this is redundant, status is already in AL!) xor al,3 ;disable timer channel 2 output and speaker out 61H,al ;have PPI turn off that damn noise! Hope this helps. Michael Markowitz Dept. of Math. Sciences Loyola Univ. of Chicago Chicago, IL 60626 ihnp4!gargoyle!cantor!able!mjm