汇编 生日快乐(可能有点刺耳)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_36424540/article/details/78941504
data segment 
     mus_freg dw 212,212,190,212,159;频率表
	      dw 169,212,212,190,212
	      dw 142,159,212,212,106
  	      dw 126,159,169,190,119	
	      dw 119,126,159,142,159,0  
              
     mus_time dw 19,13,22,22,22;持续时间表
	      dw 34,19,13,22,22
  	      dw 22,34,19,13,22
	      dw 22,22,22,22,19
	      dw 13,22,22,22,34,0
data ends

code segment	
     assume cs:code,ds:data
start:
	mov ax,data
	mov ds,ax
	
	mov cx,5;总共播放5遍
again:
	push cx  

        lea si,mus_freg 
	lea di,mus_time
        mov cx,25
contin:
	mov dx,[si]
	mov bx,[di]	
       call voice
	add si,2
	add di,2
       loop contin
        
	pop cx 
       loop again
	
        mov ax,4c00h
        int 21h

voice   proc;子程序
	push ax
	push cx
	 mov al,10110110b
	 out 43h,al
	 
	 mov al,dl
	 out 42h,al
	 mov al,dh
	 out 42h,al
	
 	  in al,61h
	  or al,00000011b
	 out 61h,al
trig:
	mov cx,0
       loop $
	dec bx
	jnz trig
	
	 in al,61h
	and al,11111100b
	out 61h,al
	pop cx
	pop ax
	ret
voice  endp  

code ends
     end start
  

展开阅读全文

没有更多推荐了,返回首页