summaryrefslogtreecommitdiff
path: root/v4.0/src/MAPPER/BEEP.ASM
diff options
context:
space:
mode:
authorGravatar Mark Zbikowski2024-04-25 21:24:10 +0100
committerGravatar Microsoft Open Source2024-04-25 22:32:27 +0000
commit2d04cacc5322951f187bb17e017c12920ac8ebe2 (patch)
tree80ee017efa878dfd5344b44249e6a241f2a7f6e2 /v4.0/src/MAPPER/BEEP.ASM
parentMerge pull request #430 from jpbaltazar/typoptbr (diff)
downloadms-dos-main.tar.gz
ms-dos-main.tar.xz
ms-dos-main.zip
MZ is back!HEADmain
Diffstat (limited to 'v4.0/src/MAPPER/BEEP.ASM')
-rw-r--r--v4.0/src/MAPPER/BEEP.ASM97
1 files changed, 97 insertions, 0 deletions
diff --git a/v4.0/src/MAPPER/BEEP.ASM b/v4.0/src/MAPPER/BEEP.ASM
new file mode 100644
index 0000000..27f8893
--- /dev/null
+++ b/v4.0/src/MAPPER/BEEP.ASM
@@ -0,0 +1,97 @@
1page 80,132
2
3title CP/DOS DosBeep mapper
4
5dosxxx segment byte public 'dos'
6 assume cs:dosxxx,ds:nothing,es:nothing,ss:nothing
7
8;**********************************************************************
9;*
10;* MODULE: dosbeep
11;*
12;* FUNCTION: generate a tone with desired frequency and duration
13;*
14;* CALLING SEQUENCE:
15;*
16;* push word frequency
17;* push word duration (in milliseconds)
18;* call dosbeep
19;*
20;* MODULES CALLED: none
21;*
22;*********************************************************************
23
24 public dosbeep
25 .sall
26 include macros.inc
27
28inv_parm equ 0002h ;invalid parameter return code
29
30str struc
31old_bp dw ?
32return dd ?
33duratn dw ? ; duration
34frqncy dw ? ; frequency
35str ends
36
37dosbeep proc far
38 Enter DosBeep
39
40 mov al,10110110b ; Set 8253 chip channel 2
41 out 43h,al ; to proper mode for tone
42
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
47; into 1,190,000.
48
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
55
56 mov bx,7fffh
57 cmp cx,bx
58 jg error
59 div cx ; then divide
60
61 out 42h,al ; and output
62 mov al,ah ; directly to
63 out 42h,al ; the 8253 port.
64
65; Turn on speaker
66
67 in al,61h ; Save original value
68 mov ah,al ; in ah
69 or al,3 ; Turn on control bit
70 out 61h,al ; in 8255 chip
71
72; Now loop for DURATN milliseconds
73
74 mov cx,[bp].duratn ; load value
75delay: mov bx,196 ; inner loop count
76del2: dec bx ; a millisecond
77 jne del2 ; for each
78 loop delay ; iteration
79
80; Turn speaker off
81
82 mov al,ah ; replace
83 out 61h,al ; original value
84
85 sub ax,ax ; set no error code
86 jmp exit ; return
87
88error: mov ax,inv_parm
89
90exit: MExit ; pop registers
91 ret size str - 6 ; return
92
93dosbeep endp
94
95dosxxx ends
96
97 end