We all know that the bootsector often dump some text like "booting..."on the screen. I'm thinking about adding some sounds while booting. So I googled and found http://www.delphi3000.com/articles/article_3773.asp?SK= useful.Using 8253/8254 channel2 ,PPI and speaker can produce sounds .After compiling,I use bochs to test the codes. But there is no sound at all . I use bochs to trace every lines of codes and found that the codes themselves should be all right(no errors like write %ax to (%ax))
Anyone know the reason? Thanks!
Here are my codes:(at&t style)
#bootsect.s
Code: Select all
.text
.global start
.code16
Freq=100
start:
mov $0x0b6,%al
out %al,$0x43
mov $0x14,%dx
mov $0x4f38,%ax #dx:ax=0x144f38=1331000
mov $Freq,%bx
div %bx #ax=1331000/Freq
out %al,$0x42 #write low byte
mov %ah,%al
out %al,$0x42 #write high byte
mov $100,%dx #dx is the loop times
in $0x61,%al #read the PPI's state
and $0xfd,%al #do some bits operation
#set bit 0-->use the 8253/8254
#clear bit 1-->turn speaker off
sound:
xor $2,%al #converse bit 1
out %al,$0x61
mov $0x140,%cx #loop some time
wait:
loop wait
dec %dx
jne sound
end:jmp end
.org 0x1fe,0x90
.word 0xaa55