OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Jun 26, 2019 4:10 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Speaker boot frequency for 8088/386 boot
PostPosted: Sat Jun 01, 2019 5:36 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1117
What are the speaker frequencies used for booting sounds in 8088/386 machines?

I want to implement them in my kernel functions.
Code:
;http://www.edaboard.com/showthread.php?182595-how-to-produce-beep-using-assembly-in-8086
;;

sound:
STARTSOUND:   ;CX=FREQUENCY IN HERTZ. DESTROYS AX & DX
pushfwide
pushawide

CMP CX, 014H
JB STARTSOUND_DONE
;CALL STOPSOUND
IN AL, 061H
;AND AL, 0FEH
;OR AL, 002H
OR AL, 003H
DEC AX
OUT 061H, AL   ;TURN AND GATE ON; TURN TIMER OFF
MOV DX, 00012H   ;HIGH WORD OF 1193180
MOV AX, 034DCH   ;LOW WORD OF 1193180
DIV CX
MOV DX, AX
MOV AL, 0B6H
PUSHF
CLI   ;!!!
OUT 043H, AL
MOV AL, DL
OUT 042H, AL
MOV AL, DH
OUT 042H, AL
POPF
IN AL, 061H
OR AL, 003H
OUT 061H, AL
   STARTSOUND_DONE:
popawide
popfwide
RET

   STOPSOUND:   ;DESTROYS AL
IN AL, 061H
AND AL, 0FCH
OUT 061H, AL
popawide
popfwide
RET






nosound:
pushfwide
push wideax

IN AL, 061H
AND AL, 0FCH
OUT 061H, AL



pop wideax
popfwide
retwide


_________________
http://api.archefire.org (My OS compatible with DOS)

IP for hosts file (all domains):
190.53.101.69 archefire.org (udocproject@yahoo.com)


Top
 Profile  
 
 Post subject: Re: Speaker boot frequency for 8088/386 boot
PostPosted: Sun Jun 02, 2019 9:51 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1548
~ wrote:
What are the speaker frequencies used for booting sounds in 8088/386 machines?

Whatever the BIOS developer felt like using. There's no standard.


Top
 Profile  
 
 Post subject: Re: Speaker boot frequency for 8088/386 boot
PostPosted: Wed Jun 05, 2019 10:37 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 305
Octocontrabass wrote:
Whatever the BIOS developer felt like using. There's no standard.
That's right. Only the durations were somewhat standardized (1 long 2 short = video card error for example).
http://www.bioscentral.com/beepcodes/amibeep.htm
http://www.bioscentral.com/beepcodes/astbeep.htm
http://www.bioscentral.com/beepcodes/awardbeep.htm
...etc.

I haven't heard any beeps for some time, but I believe it was a high C note (but correct me).

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: Speaker boot frequency for 8088/386 boot
PostPosted: Wed Jun 05, 2019 12:35 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 206
I generally use 1000 Hz, which is also the censorship sound on TV, so people already know it is bad news.


Top
 Profile  
 
 Post subject: Re: Speaker boot frequency for 8088/386 boot
PostPosted: Tue Jun 11, 2019 10:08 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 72
nullplan wrote:
I generally use 1000 Hz, which is also the censorship sound on TV, so people already know it is bad news.

Now you mention it, I think every post-90s PC I've had beeped around that frequency. Thinkpads do, and they're loud. :( Older machines could be the same or lower.

_________________
Laos or: How I learned to stop worrying and love imperative programming


Top
 Profile  
 
 Post subject: Re: Speaker boot frequency for 8088/386 boot
PostPosted: Tue Jun 18, 2019 5:04 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1117
These seem to be the standard sound frequencies, set for the high and low byte of the speaker counter:

8088, 7 for boot and 4 maybe for error (I also use 6 as it sound very similar in my machines)
386, 5 for boot

I've come to find this function for NASM:

Code:
;Inputs:
;       AH -- Uniform beep value
;       CX -- Low word wait counter
;       DI -- High word wait counter
;
;;
OPCODE__speaker_bootbeep:
pusha
pushf

;mov ah,5
mov al,0xB6
out 43h,al
mov al,ah
out 42h,al
out 42h,al
in al,61h
or al,3
out 61h,al
.wait:
push ecx
;mov cx,0xFF
loop $
pop ecx
dec di
jnz .wait
and al,-3
out 61h,al

popf
popa
ret


Code:
;Inputs:
;       AH -- Uniform beep value
;       CX -- Low word wait counter
;       DI -- High word wait counter
;
;;
OPCODE__speaker_bootbeep:
pushawide
pushfwide

;mov ah,5
mov al,0xB6
out 43h,al
mov al,ah
out 42h,al
out 42h,al
in al,61h
or al,3
out 61h,al
.wait:
push widecx
;mov cx,0xFF
loop $
pop widecx
dec di
jnz .wait
and al,-3
out 61h,al

popfwide
popawide
retwide





Wait 0x5FFFF in a loop for 8088 boot sound with 6:
Code:
mov widedi,0x5
mov widecx,0xFFFF
mov ah,6
call OPCODE__speaker_bootbeep




Wait 0x3FFFF in a loop for 386 boot sound with 5:
Code:
mov widedi,0x3
mov widecx,0xFFFF
mov ah,5
call OPCODE__speaker_bootbeep




Wait 0xFFFFF in a loop for 8088 slow turn on sound with 7:
Code:
mov edi,0xf
mov ecx,0xFFFF
mov ah,7
call OPCODE__speaker_bootbeep


_________________
http://api.archefire.org (My OS compatible with DOS)

IP for hosts file (all domains):
190.53.101.69 archefire.org (udocproject@yahoo.com)


Top
 Profile  
 
 Post subject: Re: Speaker boot frequency for 8088/386 boot
PostPosted: Tue Jun 18, 2019 10:34 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 206
Wow, this required a bit of deciphering.

So what ~ means by "frequency 5" and the other numbers, is that they load 257 times that number into the PIT as reset counter. This effectively divides the input frequency of ca. 1.2MHz by the reset counter, leading to the frequencies:
4 --> 1160 Hz
5 --> 928 Hz
6 --> 773 Hz
7 --> 663 Hz

Since the input is a divisor, the pitch actually gets lower the higher the input is. But your "tone 4" is pretty close to my 1000 Hz.

Also, the duration is set by how long it takes the CPU to count ECX down to zero. Wouldn't it be better/more consistent to use the PIT for that as well? I'm using an interrupt handler for interrupt 1C, which gets called with about 18 Hz. This way I don't need to meddle with PIT channel 0, since the BIOS will have already set it up. But do note that in my case, all error tones are fatal, so no program is running anymore.

Maybe I should elaborate. My MBR has two possible error tones: Continuous and intermittent, for the two possible errors ("no active partition" and "BIOS load error", respectively). In either case, I set up PIT channel 2 with a reset count of 1193 and enable tone generation in port 0x61. But, if I want the intermittent tone, I also register an int 1C handler, which counts a static variable down from 18. Once 0 is reached, the variable is reset to 18, and the LSB in port 0x61 is flipped. Also, I of course jump to the previous int 1C handler instead of returning. In the meantime, the main program is sitting in a HLT loop (with STI before it, of course).


Top
 Profile  
 
 Post subject: Re: Speaker boot frequency for 8088/386 boot
PostPosted: Sat Jun 22, 2019 7:09 am 
Offline
Member
Member
User avatar

Joined: Tue Mar 13, 2012 10:46 pm
Posts: 46
I've found it goes pretty low when it does the triple beep RAM death error. I don't know if that's an artifact of RAM not being present or they chose such a low frequency. But most normal single shot post success beeps sound like 1khz but post failures appear to have a slightly lower tone.

_________________
;goodbye OS, hello BIOS
mov eax, FFFFFFF0h
jmp eax


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group