]> wirehaze git hosting - BOS.git/blob - kernel/sound/speaker.asm

wirehaze git hosting

Update shell.asm
[BOS.git] / kernel / sound / speaker.asm
1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2004-2005. ;
3 ;----------------------------------------------------------;
4 ; ;
5 ; Internal PCspeaker functions. ;
6 ; ;
7 ;----------------------------------------------------------;
8
9 ;-----------------------;
10 ; turn on PC speaker ;
11 ; bx = frequency ;
12 ;-----------------------;
13 speaker_on:
14 mov dx, 0x12
15 mov ax, 0x34DC
16 div bx
17 mov bl, al
18 mov al, 0xB6
19 out 0x43, al
20 mov al, bl
21 out 0x42, al
22 mov al, ah
23 out 0x42, al
24 in al, 0x61
25 or al, 3
26 out 0x61, al
27 ret
28
29
30 ;----------------------;
31 ; turn speaker off ;
32 ;----------------------;
33 speaker_off:
34 push ax
35 in al, 0x61
36 and al, 0xFC ; some do 0xFD, some 0xFC... :/
37 out 0x61, al
38 pop ax
39 ret
40
41
42 ;----------------------------------;
43 ; PC-speaker; beep ;
44 ;----------------------------------;
45 beep:
46 push eax
47 push ecx
48 in al, 0x61 ; turn the speaker on.
49 or al, 3
50 out 0x61, al
51 mov ecx, 50
52 call delay ; timer.inc
53 call speaker_off
54 pop ecx
55 pop eax
56 ret