'Playing music notes through speaker in TASM assembly

I'm trying to write a program in TASM that plays music notes. I couldn't find any documentation online and the closest thing I found was this stackoverflow question, which is able to produce a "beep" sound.
What I don't know is:

  1. How this code works

  2. What the sound mapping is

  3. How I can play specific notes (do re mi...)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source