How to disable the interruption of the sound of the PC speaker that occurs during the cycle?

During the loop, my 8086 build programs have a threshold for pressing the keyboard key if you press the key too many times when the PC speaker starts to sound. This is unpleasant, and it slows down my programs to crawl, since the processor must bounce off my program and spend half a second driving the speaker.

I didn’t even know that this problem exists until a few months ago I started testing my programs on real hardware. This problem is not a problem in DosBox or even in Dos 6.22 installed inside DosBox. So it must be some kind of low-level hardware interrupt built into the BIOS for the PC, I don’t know too much about it.

This happens on my 286 machine and my Pentium mmx laptop, regardless of operating system.

Even if it’s just a dead loop, and I haven’t even tried to enter from the keyboard, the beep will still happen if I press too many keys

I tried to wrap only my input code inside cli and sti, in order to hope for masking keyboard input, but this does not work. I collect scancode only at a specific point in my program, so the rest of the interrupt time is allowed. Thus, an audio signal can still occur in the vast majority of cases.

There must be some kind of hardware register that I can disable or something like that. I scanned the Boch ports list ( http://bochs.sourceforge.net/techspec/PORTS.LST ) well, looking for something like this, but didn't see anything.

Maybe I can just disable the interrupt? I guess many build programmers must have encountered this problem, but Google really doesn't help me at all here.

+7
assembly interrupt x86-16 pc
source share
1 answer

The BIOS beeps to alert you that the type keyboard keyboard buffer is full. In DOS, this usually happens with programs that (permanently or temporarily) do not read keyboard input.

In your case, you are reading keyboard input, but not appropriately. You are reading directly from the hardware (I / O port 60h), but apparently you will not catch the keyboard interrupt ( INT 09h ). This means that in the background, the BIOS also processes keyboard input. This has two unpleasant side effects.

  • The BIOS keyboard keyboard buffer is populated. This not only causes the machine to beep, and unprocessed keystrokes also accumulate, like garbage waiting to be dropped as soon as your program exits and returns to the command line.
  • You can skip keystrokes because the BIOS will beat you.

Basically, there are three ways to solve this problem.

  • Use BIOS calls or DOS calls to read keyboard input.
  • Create a suitable keyboard interrupt handler in which you use ports 60h, 61h and 20h to receive keyboard events ("make" and "break").
  • (Not sure about this anymore :) Directly pull a keystroke from a keyboard buffer like BIOS.

The first option is highly recommended. The second option is preferable if your application should be able to detect several keys at the same time (usually video games). This is not a trivial task, so you need help.

+9
source share

All Articles