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

王朝other·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

;使用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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航