Speaker boot frequency for 8088/386 boot

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Speaker boot frequency for 8088/386 boot

Post by ~ »

What are the speaker frequencies used for booting sounds in 8088/386 machines?

I want to implement them in my kernel functions.

Code: Select all

;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

Octocontrabass
Member
Member
Posts: 5584
Joined: Mon Mar 25, 2013 7:01 pm

Re: Speaker boot frequency for 8088/386 boot

Post by Octocontrabass »

~ 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.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Speaker boot frequency for 8088/386 boot

Post by bzt »

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
nullplan
Member
Member
Posts: 1801
Joined: Wed Aug 30, 2017 8:24 am

Re: Speaker boot frequency for 8088/386 boot

Post by nullplan »

I generally use 1000 Hz, which is also the censorship sound on TV, so people already know it is bad news.
Carpe diem!
User avatar
eekee
Member
Member
Posts: 892
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Speaker boot frequency for 8088/386 boot

Post by eekee »

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.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: Speaker boot frequency for 8088/386 boot

Post by ~ »

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: Select all

;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: Select all

;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: Select all

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: Select all

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: Select all

mov edi,0xf
mov ecx,0xFFFF
mov ah,7
call OPCODE__speaker_bootbeep

nullplan
Member
Member
Posts: 1801
Joined: Wed Aug 30, 2017 8:24 am

Re: Speaker boot frequency for 8088/386 boot

Post by nullplan »

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).
Carpe diem!
User avatar
drunkenfox
Member
Member
Posts: 46
Joined: Tue Mar 13, 2012 10:46 pm

Re: Speaker boot frequency for 8088/386 boot

Post by drunkenfox »

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
Post Reply