; 1~7音阶
assume cs:codeseg
data segment
dw 262,294,330,349,392,440,494,524 ;1~7频率
data ends
codeseg segment
start:
mov ax, data
mov ds, ax
mov si, 0
mov bl, 8
play:
mov al,0b6h ;8253芯片初始化
out 43h,al ;43H是8253芯片控制口的端口地址
mov dx,12h
mov ax,34dch
div word ptr [si] ;设置声音的频率
out 42h, al
mov al, ah
out 42h, al
in al, 61h ;读设备控制器端口原值
mov ah, al ;保存原值
or al, 3 ;打开扬声器和定时器
out 61h, al ;接通扬声器,发声
mov dx, 10 ;延时
delay0:
mov cx, 60000
delay1:
nop
loop delay1
dec dx
jne delay0
mov al, ah ;恢复端口原值
out 61h, al
add si, 2
dec bl
jne play
mov ax, 4c00h
int 21h
codeseg ends
end start
汇编语言(1~7音阶)
最新推荐文章于 2024-06-20 16:06:23 发布