汇编用dos能直接发出声音么?
用位触发方式(也即程序直接控制输出控制寄存器(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