beta.blog

FASM: Beep

by on Oct.21, 2011, under Programming

Short example code snippet of how to generate a ‘beep’ with flat assembler. The sample code makes use of the Windows API to create it.

format PE console
entry start

include 'win32a.inc'

;=======================================
section '.code' code readable executable
;=======================================

start:
        invoke  Beep,750, 300               ; Will make your computer beep. 750=frequency and 300=duration

        ccall   [getchar]                   ; I added this line to exit the application AFTER the user pressed any key.
        stdcall [ExitProcess],0             ; Exit the application

;====================================
section '.idata' import data readable
;====================================

library kernel,'kernel32.dll',\
        msvcrt,'msvcrt.dll'

import  kernel,\
        Beep,'Beep',\
        ExitProcess,'ExitProcess'

import  msvcrt,\
        getchar,'_fgetchar'

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!