Category : C Source Code
Archive   : MIKES40C.ZIP
Filename : SOUND.ASM

 
Output of file : SOUND.ASM contained in archive : MIKES40C.ZIP
page,132
title SOUND.ASM - SOUND PROCEDURES for MICROSOFT 'C' (4.0)
; sound Control PC Speaker
; by Mike Elkins
;
; sound(len,freq)
; int len length of sound
; int freq frequency of sound
;
_text segment byte public 'code'
assume cs:_text

public _sound,SOUND

arg struc
oldbp dw ?
retn dw ?
len dw ?
freq dw ?
arg ends

SOUND:
_sound proc near

push bp
mov bp,sp
push ds
xor ax,ax ;set up for low memory stuff
mov ds,ax

mov di,[bp].freq ;put frequency in di
mov al,0B6h ;set up timer for sound
out 43h,al
mov dx,14h ;divide frequency by 1331000
div di
out 42h,al ;send frequency to timer
mov al,ah
out 42h,al
in al,61h ;get current timer port value
push ax ;save it
or al,3 ;turn on speaker
out 61h,al
mov bx,[bp].len ;wait loop
loop: mov cx,280 ;wait 1 ms
deloop: loop deloop
dec bx
jnz loop
jmp off

off: pop ax ;recover speaker port value
out 61h,al ;turn speaker off

pop ds ;put things back and return
pop bp
ret


_sound endp
_text ends
end


  3 Responses to “Category : C Source Code
Archive   : MIKES40C.ZIP
Filename : SOUND.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/