注册 登录
编程论坛 汇编论坛

汇编用dos能直接发出声音么?

吴丽华 发布于 2013-06-24 17:39, 1017 次点击
   用位触发方式(也即程序直接控制输出控制寄存器(I/O端口为61h)的第一位,使该位按所需要的频率进行1和0的交替变化,从而控制开关电路产生一串脉冲波形,这些脉冲经放大后驱动扬声器发声音)模拟枪响程序。

code segment
main proc far
assume cs:code
start:
      mov cx,50d  
new_short:
      push cx
      call shoot
      mov cx,0f000h
silent:
      loop silent
      pop cx
      loop new_short
      mov al,48h
      out 61h,al
      mov ax,4c00h
      int 21h
main endp
        
shoot proc near
      mov dx,140h
      mov bx,20h
      in  al,61h
      and al,11111100b
sound:
      xor al,2
      out 61h,al
      add dx,9248h
      mov cl,3
      ror dx,cl
      mov cx,dx
      and cx,1ffh
      or cx,1000h
delay:  push cx
wait:
     loop wait
     pop cx
    loop delay
    dec bx
    jnz sound
    and al,11111100b
    out 61h,al
    ret
shoot endp
code ends
  end start
5 回复
#2
hu9jj2013-06-25 07:36
DOS下通过机箱的喇叭发声比较容易实现,但音量无法控制。DOS下通过声卡发声没有用过,不清楚具体过程。
#3
吴丽华2013-06-25 13:37
回复 2楼 hu9jj
嗯,谢谢!
#4
zklhp2013-06-25 14:15
以下是引用hu9jj在2013-6-25 07:36:30的发言:

DOS下通过机箱的喇叭发声比较容易实现,但音量无法控制。DOS下通过声卡发声没有用过,不清楚具体过程。
用AC97神马的可以 可能对搞底层开发的有点意义罢
#5
Alar302013-06-27 12:07
只试过搞响机箱声音。。。
#6
xkwy00002013-06-29 21:45
想知道发声卡如何发声??
1