在组件8086中产生声音

时间:2013-06-22 15:20:58

标签: audio assembly x86-16

我正在尝试使用8086程序集生成具有特定频率的声音。我搜索并搜索了很多关于连接扬声器(而不是PC扬声器)的代码。然而,它们似乎都不起作用。以下是我的代码:

    mov     al, 182         ; meaning that we're about to load
    out     43h, al         ; a new countdown value

    mov     ax, 2153        ; countdown value is stored in ax. It is calculated by 
                            ; dividing 1193180 by the desired frequency (with the
                            ; number being the frequency at which the main system
                            ; oscillator runs
    out     42h, al         ; Output low byte.
    mov     al, ah          ; Output high byte.
    out     42h, al               

    in      al, 61h         
                            ; to connect the speaker to timer 2
    or      al, 00000011b  
    out     61h, al         ; Send the new value

我认为这应该产生声音,直到我们以某种方式告诉说话者关闭。尽管如此,没有声音可以听到。你能告诉我代码有什么问题吗?

2 个答案:

答案 0 :(得分:2)

总结一下:你的代码看起来很好。问题是你在8086仿真器上运行它,而不是用于PC平台(因此没有连接到该I / O端口的扬声器)。

答案 1 :(得分:-1)

在过零点开始和结束时生成正弦波可能更容易,然后使用内置的OS功能重复播放文件。

相关问题