从而在组件8086中产生声音



我正在尝试使用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

我认为这应该会产生声音,直到我们设法告诉扬声器关闭。尽管如此,还是听不到声音。你能告诉我代码出了什么问题吗?

总结一下:您的代码看起来不错。问题是,您在一个不适用于PC平台的8086模拟器上运行它(因此该I/O端口上没有连接扬声器)。

生成一个以过零点开始和结束的正弦波,然后使用内置的操作系统功能重复播放文件可能会更容易。

最新更新