问题描述
我正在尝试使用8086组件产生特定频率的声音.我已搜索并找到许多有关连接扬声器(而不是PC扬声器)的代码.但是,它们似乎都不起作用.以下是我的代码:
I'm trying to generate a sound with a specific frequency using 8086 assembly. I have searched and searched and found lots of codes regarding connecting to the speaker (not the PC speaker). Yet, none of them seem to work. The following is my code:
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
我认为这应该会产生声音,直到我们设法使扬声器关闭为止.但是,没有声音可以听到.您能告诉我代码有什么问题吗?
I think this is supposed to produce a sound until we somehow manage to tell the speaker to turn off. Nonetheless, there's no sound to be heard. Can you please tell me what is wrong with the code?
推荐答案
总结一下:您的代码看起来不错.问题是您在非PC平台的8086仿真器上运行了该仿真器(因此没有在该I/O端口上连接扬声器).
To sum this one up: Your code looks fine. The problem was that you were running it on an 8086 emulator that was not for the PC platform (and hence didn't have a speaker attached to that I/O port).
这篇关于在装配8086中产生声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!