Closed oblende closed 11 months ago
This is obviously not a bug or an issue in the BIOS, and has nothing to do you the PC speaker compatibility :)
Anyhow, let me try to help you.
There is one document that you'd want to take a look at. It is the 8254 Programmable Interval Timer (PIT) datasheet. Particularly, check page number 6 there.
There are two components that are used for sound generation in the IBM PC:
A bit about 8254 PIT and its addressing in IBM PC:
How to program sound using PIT?
Why my code doesn't work?
I suspect it happens because of this: "For each Counter, the Control Word must be written before the initial count is written." Try moving your "tone:" label two lines up, before you write the "magic number". Also, it might be a good idea to disable speaker before you reprogram the PIT. Add something like:
in al,0x61 and al,0xFC out 0x61,al
Of course, you can take the sound.inc from this BIOS, and just modify it a bit.
I thank you for your patience in answering my question. In a strange turn of events we were both wrong. I tried out your suggested modifications and it was still not working. So I looked at what was happening in debug and noticed when I unassembled the program that or al,0x03 was assembled by msa2 as or al,[bp+di], which would have been fine if it had worked. Instead bits 0 and 1 on port 0x61 were never both set. Putting 0x03 into the dl register and ORing that with al suddenly made my code work.
Again thank you for your patience and now I think I need to submit a bug report to a different project.
I still don't understand what happened with your assembler ;) How come or al,0x03 got assembled as or al,[bp+di]? Either that assembler is trash or you're not doing something right ;)
As much as I'm willing to accept that I'm doing something wrong I really can't see how that can be. It seems to be a bug in the assembler, but only with OR reg,constant combinations. I'd submit a bug report to the author, but he doesn't seem to allow people to submit reports as the ability to do so has been disabled on his repositories. It's a shame as I appreciate a no nonsense assembler like this.
or al,0x03
or bl,0x02
or cl,0x05
or dl,0x04
or ah,0x03
or bh,0x08
or ch,0x07
or dh,0x03
or ax,0xAAAA
or bx,0xAAAA
or CX,0xAAAA
or dx,0xAAAA
int 0x20
Edit I assembled over the areas with debug of the OR al,0x03 instruction and the OR AX,0xAAAA instruction, and everything fell back in line. So everything is fine except those two instructions.
Seems like a silly thing to ask about, but I couldn't figure out where else to ask as it seems hardware and BIOS related.
So I had decided to learn assembly language in DOS using the Book 8088 with the help of the book "Assembly Language Primer for the IBM PC & XT." Things were going good until I got to the section involving sound using the PC speaker, then everything stopped working. I then tried as many examples from the internet on using the PC speaker, including the beep code from your BIOS and all failed. The frustrating part is that other applications including the beep command seem to work fine. In desperation I then figured out how to get Virtualbox to passthrough the PC speaker, and the programs I was having troubble with worked. It still does not explain how your bios and various applications is able to make sound. Could you explain how I'm screwing my code up, please? Also I'm using the msa2 assembler, so I commented out all the MASM specific parts of the code. I may still end up using MASM so I figure writing the MASM parts in the comments was the best way to learn even if I wasn't using that assembler. Sorry if it makes the code harder to read.
` ;SIREN--Uses Timer2 to run speaker ; features siren effect ; ;** ;prognam segment ;define code segment
`