Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;-----------------------------------
- ; App: 64-bit System Beep (WIN) ;
- ; Language: MASM ;
- ; Version: 1.0 ;
- ;-----------------------------------;
- ; Date: 01 Aug 2017 ;
- ; Author: Jose Madureira ;
- ; License: CC0 Public Domain ;
- ;-----------------------------------;
- ; ## Global constants ##
- TAB EQU 09h ;Tab
- NL EQU 0Dh,0Ah ;New line
- ExitProcess PROTO ;quit program
- ;WINAPI PRINTF TO DISPLAY MESSAGE
- includelib msvcrt.lib
- EXTRN printf:PROC
- ;WINAPI SYSTEM BEEP
- includelib kernel32.lib
- EXTRN Beep:PROC
- .data
- strFmt byte "%s",0
- msgDing byte NL,TAB,TAB," Beep me up scotty! ",NL,0
- .code
- Main PROC
- sub rsp,32 ;reserve shadow space
- mov rax,1 ;1 argument
- mov rcx,offset strFmt ;printf format
- mov rdx,offset msgDing ;data to display
- call printf
- xor rax,rax
- add rsp,32 ;clean up
- ;beepedy bop
- call _Beep ;kernel32 call
- mov rcx,0
- call ExitProcess
- Main ENDP
- ;#### Beep(frequency,ms) ###
- ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms679277(v=vs.85).aspx
- _Beep PROC
- push rbp ;align stack
- mov rbp,rsp
- sub rsp,32 ;reserve shadow space for Beep(frequency,duration)
- ;Example with english flute
- ;http://www.contrabass.com/pages/frequency.html
- ;do
- mov rcx,523 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;re
- mov rcx,587 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;mi
- mov rcx,659 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;mi
- mov rcx,659 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;re
- mov rcx,587 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;re
- mov rcx,587 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;do
- mov rcx,523 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;do
- mov rcx,523 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;mi
- mov rcx,659 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;fa
- mov rcx,698 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;so
- mov rcx,783 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;so
- mov rcx,783 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;fa
- mov rcx,698 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;fa
- mov rcx,698 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;fa
- mov rcx,698 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;fa
- mov rcx,698 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;mi
- mov rcx,659 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;mi
- mov rcx,659 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;re
- mov rcx,587 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;re
- mov rcx,587 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;re
- mov rcx,587 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;re
- mov rcx,587 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;do
- mov rcx,523 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;do
- mov rcx,523 ;frequency
- mov rdx,250 ;duration(ms)
- call Beep ;kernel32 call
- ;clean up
- add rsp,32
- pop rbp
- xor rax,rax
- ret
- _Beep ENDP
- END
Advertisement
Add Comment
Please, Sign In to add comment