Page 1 of 1

[SOLVED] PC speaker does not work

Posted: Mon Apr 02, 2018 9:33 am
by Klakap
Good day!
I tried to play sound from the PC speaker code:
BITS 16

Code: Select all

start:
mov ax, 07C0h ; Set 4K stack space after this bootloader
add ax,, 288 ; (4096 + 512) / 16 apartments under paragraph
mov ss, ax
mov sp, 4096

mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax

mov ax, 1000
call os_speaker_tone

jmp $

os_speaker_tone:
pusha

mov cx, ax ; Store note value now

mov al, 182
out 43h, al
mov ax, cx ; Set the frequency
out 42h, al
mov al, ah
out 42h, al

in al, 61 h ; Switch PC speaker
or al, 03h
of the 61 h, al

popa
ret
(This is a function of MikeOS.) But the sound does not work. When I run MikeOS, so sound worked. Please what do I do?

Re: PC speaker does not work

Posted: Mon Apr 02, 2018 10:35 am
by iansjack
Silly question, but - does your computer actually have a speaker (connected)?

Re: PC speaker does not work

Posted: Tue Apr 03, 2018 9:50 am
by Klakap
As far as I know, in the MikeOS PC speaker does not connect and the sound works. But when I copied the method from MikeOS that plays sound(os_speaker_tone) so after call his, I didn't get result!

Re: PC speaker does not work

Posted: Tue Apr 03, 2018 10:12 am
by iansjack
You didn't answer my silly question.

Never mind.

Re: PC speaker does not work

Posted: Tue Apr 03, 2018 10:21 am
by Klakap
MikeOS and my OS I run through qemu. I don't know whether it is in qemu a Pc speaker connected or not.

Re: PC speaker does not work

Posted: Sat Apr 14, 2018 8:23 am
by Klakap
I already found the problem, it was sufficient to run the kernel:
qemu-system-i386 -soundhw pcspk -kernel kernel
PC speaker works!