汇编乐曲编程
来源:互联网 发布:换手机壁纸的软件 编辑:程序博客网 时间:2024/04/28 16:13
;***************************************************************************
;新年好乐曲
;author:野渡无人
;create date:2007-12-22
;***************************************************************************
stack segment para stack 'stack'
db 64 dup('stack...')
stack ends
;*******************************************************************
dseg segment para 'data'
mus_freq dw 262,262,262,196,330,330,330,262
dw 262,330,392,392,349,330,294
dw 294,330,349,349,330,294,330,262
dw 262,330,294,392,494,294,262,-1
mus_time dw 16,16,33,33,16,16,33,33
dw 16,16,33,33,16,16,67
dw 16,16,33,33,16,16,33,33
dw 16,16,33,33,16,16,67
message1 db 'Merry Christmas and Happy New Year!',13,10,'$'
message2 db 'Play again?(Y/N):$'
play_flag db ?
crlf db 13,10,'$'
dseg ends
;*******************************************************************
cseg segment para 'code'
assume cs:cseg,ss:stack,ds:dseg
;-------------------------------------------------------------------
music proc far
mov ax,dseg
mov ds,ax
lea dx,message1
mov ah,09
int 21h
start:
lea si,mus_freq
lea bp,ds:mus_time
freq:
mov di,[si]
cmp di,-1
je end_mus
mov bx,ds:[bp]
call soundf
add si,2
add bp,2
jmp freq
end_mus:
lea dx,message2
mov ah,09
int 21h
call judge
cmp play_flag,1
je start
mov ax,4c00h
int 21h
music endp
;--------------------------------------------------------------------------
soundf proc near
push ax
push bx
push cx
push dx
push di
mov al,0b6h
out 43h,al
mov dx,12h
mov ax,348ch
div di
out 42h,al
mov al,ah
out 42h,al
in al,61h
mov ah,al
or al,3
out 61h,al
wait1:
mov cx,16630
call waitf
dec bx
jnz wait1
mov al,ah
out 61h,al
pop di
pop dx
pop cx
pop bx
pop ax
ret
soundf endp
;--------------------------------------------------------------------------
waitf proc near
push ax
waitf1:
in al,61h
and al,10h
cmp al,ah
je waitf1
mov ah,al
loop waitf1
pop ax
ret
waitf endp
;--------------------------------------------------------------------------
judge proc near
mov ah,01
int 21h
cmp al,'Y'
je judge_continue1
cmp al,'y'
je judge_continue1
cmp al,'N'
je judge_continue2
cmp al,'n'
je judge_continue2
mov ah,09
lea dx,crlf
int 21h
jmp judge_exit
judge_continue1:
mov play_flag,1
jmp judge_exit
judge_continue2:
mov play_flag,0
judge_exit:
mov ah,09
lea dx,crlf
int 21h
ret
judge endp
;----------------------------------------------------------
cseg ends
;***************************************************************************
end music
;***************************************************************************
;新年好乐曲
;author:野渡无人
;create date:2007-12-22
;***************************************************************************
stack segment para stack 'stack'
db 64 dup('stack...')
stack ends
;*******************************************************************
dseg segment para 'data'
mus_freq dw 262,262,262,196,330,330,330,262
dw 262,330,392,392,349,330,294
dw 294,330,349,349,330,294,330,262
dw 262,330,294,392,494,294,262,-1
mus_time dw 16,16,33,33,16,16,33,33
dw 16,16,33,33,16,16,67
dw 16,16,33,33,16,16,33,33
dw 16,16,33,33,16,16,67
message1 db 'Merry Christmas and Happy New Year!',13,10,'$'
message2 db 'Play again?(Y/N):$'
play_flag db ?
crlf db 13,10,'$'
dseg ends
;*******************************************************************
cseg segment para 'code'
assume cs:cseg,ss:stack,ds:dseg
;-------------------------------------------------------------------
music proc far
mov ax,dseg
mov ds,ax
lea dx,message1
mov ah,09
int 21h
start:
lea si,mus_freq
lea bp,ds:mus_time
freq:
mov di,[si]
cmp di,-1
je end_mus
mov bx,ds:[bp]
call soundf
add si,2
add bp,2
jmp freq
end_mus:
lea dx,message2
mov ah,09
int 21h
call judge
cmp play_flag,1
je start
mov ax,4c00h
int 21h
music endp
;--------------------------------------------------------------------------
soundf proc near
push ax
push bx
push cx
push dx
push di
mov al,0b6h
out 43h,al
mov dx,12h
mov ax,348ch
div di
out 42h,al
mov al,ah
out 42h,al
in al,61h
mov ah,al
or al,3
out 61h,al
wait1:
mov cx,16630
call waitf
dec bx
jnz wait1
mov al,ah
out 61h,al
pop di
pop dx
pop cx
pop bx
pop ax
ret
soundf endp
;--------------------------------------------------------------------------
waitf proc near
push ax
waitf1:
in al,61h
and al,10h
cmp al,ah
je waitf1
mov ah,al
loop waitf1
pop ax
ret
waitf endp
;--------------------------------------------------------------------------
judge proc near
mov ah,01
int 21h
cmp al,'Y'
je judge_continue1
cmp al,'y'
je judge_continue1
cmp al,'N'
je judge_continue2
cmp al,'n'
je judge_continue2
mov ah,09
lea dx,crlf
int 21h
jmp judge_exit
judge_continue1:
mov play_flag,1
jmp judge_exit
judge_continue2:
mov play_flag,0
judge_exit:
mov ah,09
lea dx,crlf
int 21h
ret
judge endp
;----------------------------------------------------------
cseg ends
;***************************************************************************
end music
;***************************************************************************
- 汇编乐曲编程
- 汇编乐曲编程 两只老虎
- 汇编实验——乐曲程序(两只老虎)
- 乐曲创作
- 乐曲创作
- 乐曲创作
- 汇编编程
- 乐曲速度标记
- [COGS902]乐曲主题
- 【JZOJ 3873】 乐曲创作
- Matlab编写乐曲
- C 汇编混合编程
- java 编程原则汇编
- 编程思想汇编
- 汇编编程简介
- 汇编颜色编程
- arm汇编编程(示例)
- teaklite DSP汇编编程
- 2007最牛的50个站
- 四六级是这样的
- Struts中Tilts标记的使用
- D2D网络数据存储器开发全过程(2)
- SQL Server 2008和T-SQL新功能
- 汇编乐曲编程
- SQL Server中的新数据类型:HierarchyId
- 红黑树的实现和代码
- SQL Server 2008中的数据类型
- kxmlParser-xml解析工具的使用
- 网站终于开通了
- 常见的搜索优化策略
- 微软预先展示"Server 2008"五大版本
- 汇编乐曲编程 两只老虎