]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MAPPER/BEEP.ASM
3 title CP
/DOS DosBeep mapper
5 dosxxx
segment byte public 'dos'
6 assume
cs:dosxxx
,ds:nothing
,es:nothing
,ss:nothing
8 ;**********************************************************************
12 ;* FUNCTION: generate a tone with desired frequency and duration
16 ;* push word frequency
17 ;* push word duration (in milliseconds)
20 ;* MODULES CALLED: none
22 ;*********************************************************************
28 inv_parm equ
0002h ;invalid parameter return code
33 duratn dw ?
; duration
34 frqncy dw ?
; frequency
40 mov al,10110110b ; Set 8253 chip channel 2
41 out 43h
,al ; to proper mode for tone
43 ; Channel 2 is now set up as a frequency divider. The sixteen bit
44 ; value sent to that port (in low-high format) is divided into
45 ; 1.19 MHz, the clock speed. In order to send the proper value
46 ; to the register, then, the frequency requested must be divided
49 mov dx,012h ; MSB of 1.19M
50 mov ax,2970h
; LSB of 1.19M
51 mov cx,[bp].frqncy
; divisor
52 mov bx,025h ; check frequency range
53 cmp cx,bx ; frequency ok ??
54 jl error
; branch if error
61 out 42h
,al ; and output
62 mov al,ah ; directly to
63 out 42h
,al ; the 8253 port.
67 in al,61h
; Save original value
69 or al,3 ; Turn on control bit
70 out 61h
,al ; in 8255 chip
72 ; Now loop for DURATN milliseconds
74 mov cx,[bp].duratn
; load value
75 delay: mov bx,196 ; inner loop count
76 del2: dec bx ; a millisecond
78 loop delay
; iteration
83 out 61h
,al ; original value
85 sub ax,ax ; set no error code
88 error: mov ax,inv_parm
90 exit: MExit
; pop registers
91 ret size
str - 6 ; return