Making the PC internal speaker beep...

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
K.J.

Making the PC internal speaker beep...

Post by K.J. »

Anyone know how to make the internal PC speaker beep?

Thanks in advance,
K.J.
Anonymous

Re:Making the PC internal speaker beep...

Post by Anonymous »

look at one of the early versions of Linux
version 0.11 I think -- search for "wonder-kernel" :)
unknown user

Re:Making the PC internal speaker beep...

Post by unknown user »

i geuss you can poke the speaker with the interrupts from the timer.
Tim

Re:Making the PC internal speaker beep...

Post by Tim »

This is sound.c from the DJGPP library source:

Code: Select all

/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
#include <pc.h>

void
sound(int freq)
{
  int scale;
  if (freq == 0)
  {
    outportb(0x61, inportb(0x61) & ~3);
    return;
  }
  scale = 1193046 / freq;
  outportb(0x43, 0xb6);
  outportb(0x42, scale & 0xff);
  outportb(0x42, scale >> 8);
  outportb(0x61, inportb(0x61) | 3);
}
crazybuddha

Re:Making the PC internal speaker beep...

Post by crazybuddha »

Sorry this isn't commented. I'd be happy to elaborate, if anyone cares. This COM program should generate a tone until you hit a key. It is assembled in NASM (see Refs. below).


;------------ CUT HERE ---------------
; nasmw beep.asm -o beep.com

org 0x0100

in al, 61h???
jmp $+2
or al, 03h
out 61h, al
???
mov al, 0b6h
out 43h, al
???
mov ax, 1193
out 42h, al
mov al, ah
out 42h, al
???
xor ah, ah
int 16h
???
in al, 61h
jmp $+2
and al, 0fdh
out 61h, al

mov ah,4Ch ???
int 21h ???

;Refs:
;nasm.2y.net
;www.ctyme.com/rbrown.htm

;------------ CUT HERE ---------------
K.J.

Re:Making the PC internal speaker beep...

Post by K.J. »

Thanks for the code Tim and crazybuddha.

K.J.
Post Reply