-3

I want to write a procedure that creates a beep sound on Windows, using assembly language.

How can I do that? Do you have any starting point idea?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
userh
  • 1
  • 6
  • 3
    Telling us what CPU, hardware, OS, etc you're intending to use might be a good start. – Paul R May 13 '16 at 18:16
  • This might help you = http://stackoverflow.com/questions/29168974/how-to-play-chords-in-asm-8086/29170599#29170599 – Jose Manuel Abarca Rodríguez May 13 '16 at 18:24
  • 1
    I remember displaying ASCII char 7 did sound like a beep, but I was booting my computer with MS-DOS, not Windows. Not sure if it would work in a command shell window or virtual box. Make the try : in data segment= `beep db 7,'$'` , in code segment= `mov ah,9` , `mov dx,offset beep` , `int 21h` . – Jose Manuel Abarca Rodríguez May 13 '16 at 18:45

1 Answers1

1

In MS-DOS, which is what many assembly novices are targeting without even knowing it, outputting character ASCII 7 (BEL) via interrupt 21h, function AH=2 will do it:

mov ah, 2
mov dl, 7
int 21h

In Windows, call the MessageBeep() API function, passing 0xffffffff as the parameter. The function resides in User[32].dll; depending on your assembler, the sequence for importing an API function might vary.

If by "Windows" you mean "DOS executable running under Windows", which some people occasionally do, then back to int21h.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281