使用8253实现使用1到8弹奏歌曲

;使用8253实现使用1到8弹奏歌曲

;其他键退出

data segment
 message  db 'Use 1 ... 8 to play the music','$'
 frequ dw 262, 294, 330, 347, 392, 440, 494, 524
data ends
code segment
 assume cs:code, ds:data
start:
 mov ax, data
 mov ds, ax
 
 lea dx, message
 mov ah, 09h
 int 21h
 
 mov al, 10110110b
 out 43h, al  ;set the control
 
next: mov ah, 7
 int 21h
 
 cmp al, '1'
 jb  exit
 cmp al, '8'
 ja  exit
 ;get the frequency of the number
 sub al, 30h
 mov ah, 0
 mov bx, ax
 sub bx, 1
 shl bx, 1
 mov cx, frequ[bx]
 ;get the counter
 mov ax, 34dch
        mov dx, 12h  ;DX:AX=1234DCH=1193180D
        div cx
 mov bx, ax   ;set the counter
 
 mov ax, bx
        out 42h, al  ;send the lower
        mov al, ah
        out 42h, al  ;send th  higner       
 
 in  al, 61h  ;set the 0 and 1 as '1'
 or  al, 03h
 out 61h, al
 
 mov cx, 0ffffh
delay:  mov dx, 100h
dec_dx: dec dx
        jnz dec_dx
        loop delay
       
        in  al, 61h
        and al, 11111100b
        out 61h, al  ;open the voice     
 jmp next
exit:
 mov ah, 4ch
 int 21h 
code ends
end start

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值