This is an assembly language program written by Myron Berg. It demonstrates the polling of the keyboard for more than one key at a time. It also demonstrates the use of the pc speaker to simulate harmony.
  • Organ.exe

    Each key that is pressed is added to the list of currently played keys. When a scan code contains a 1 in the 7th bit, then the key is being released so the key is removed from the currently played keys list. When more than 4 or 5 keys are pressed, the computer seems unable to handle this many keys at once. To achieve the harmony sound, since the pc speaker can play only one pitch at a time, the pitches are rapidly cycled. Too rapid cycling produces static sound. The vibrato rate can be increased by pressing the grey + key and decreased by pressing the grey - key on the keypad.

    To prevent this vibrato from changing too much from machine to machine, I created a procedure to count how many cycles are performed in 1 machine cycle (1/18th of a second). This number is stored in the variable counter and is used to determine how many cycles must be performed before a change in pitch is allowed. When more keys are pressed at the same time, a faster vibrato rate is needed to make the sound correct, so the number of cycles is decreased.

    Source Code:

  • Organ.asm

    E-Mail:  Myron Berg   (

    Floating Point input and output into Assembly Language

    Myron Berg's Home Page

    Computer Science Education Research