Make a speaker beep in Assembly

heymrdj

Diamond Member
May 28, 2007
3,999
63
91
Need to write a small program, that I've got almost done. Just need to add a section so that when I jump to it because the preceding value was false, it make a BEEP (via board speaker or attached speakers doesn't really matter). My book just says to echo a beep character (ASCII 7). But if I do this:

Code:
mov AX, 7
_PutCh

I've also tried int 21h with no luck either. Also int 07h.
I get no beeps. I'm sure I'm missing something really silly, any enlightenment?
 

KIAman

Diamond Member
Mar 7, 2001
3,342
23
81
Have you tried the following?

Code:
mov AX, 7
_PutCh AX

or even
Code:
_PutCH 7
 

heymrdj

Diamond Member
May 28, 2007
3,999
63
91
Nope didn't work. Problem is, I have sound setup in VMWare, but I dunno if it will pass audio through. I have to use and XP Pro VM because I have Vista Ultimate 64 bit which obviously does not support 16bit. Any ideas?
 

heymrdj

Diamond Member
May 28, 2007
3,999
63
91
Alright it was indeed just _PutCh 7, which is a BIOS beep. apparently XP in VMWare can't pass that command along, it worked fine when I put it on a real XP computer (one of our in apartment computer labs).

Thanks for the help though!
 

exdeath

Lifer
Jan 29, 2004
13,679
10
81
What kind of computer? Many main boards have built in piezo buzzers now and don't actually have the DOS style PC speaker connected. If you are running a modern OS, and then running in other emulators or layers of abstraction, it's not going to work quite the same. The audio system like a sound card and the legacy PC speaker "beep" are two totally different things.

Do you get a POST beep or beeping in the BIOS when you run out of menu or anything like that?

The speaker itself doesn't actually beep, you have to set up an oscillating square wave with the also legacy 8253 hardware timer to get a tone. This is what DOS/BIOS does for you when you print the "beep" ASCII.
 
Last edited by a moderator:

Cogman

Lifer
Sep 19, 2000
10,284
138
106
If you are using windows, I would use something like
Code:
push Frequency
push Duration
call Beep
 

TomGriffinII

Junior Member
Aug 14, 2009
9
0
0
It's the problem with the HAL in Windows (Hardware Abstraction Layer) and also with VMware why the following will NOT toggle the numlock key in DOS, Windows 95/98/SE/Bloat Code edition.

C:>debug
-a100
xxxx:0100 pop DS ;pop the data segment on from the stack (remember CP/M?)
xxxx:0103 xor byte ptr[0417],20 ;xor the bios data segment with toggle bit
xxxx:0108 int 20 ;exit program
^c
-rcx0108
-nx.com
-w
bland but true you cant talk directly to it (hardware) unless calling the windows system beep function