|
发表于 2009-7-9 17:40:46
|
显示全部楼层
;sound
;*****************************************************************
data SEGMENT
;界面
mess1 DB ' **********************************************************' , 13, , 10 ,'$'
mess2 DB ' WELLLCOME TO THE CUB OF MUSIC ' , 13 , 10 ,'$'
mess3 DB ' 1 . Song 1 2. Song 2 ' , 13 , 10 ,
mess4 DB ' 3 . Song 4 4. Song 4 ' , 13 , 10 , '$'
mess5 DB ' ________Please Chose The Song You Want To Hear !!!_______' , 13 , 10 , '$'
mess6 DB ' 5. OUT of the program ' , 13 , 10 , '$'
;歌曲1
f1 DW 330,349,392,440,440,392,349,330,330,262,330,349,392,440,440,392,294,330,30000
DW 330,349,392,440,440,392,349,330,330,262,262,247,220,330,294,247,262,30000
DW 4 DUP(523),494,494,4 DUP(440),392,392,262,247,220,330,294,247,262,0
t1 DW 3 DUP(5000),7500,2500,5000,5000,7500,2500,5000,3 DUP(5000),7500,2500,7500,2500,5000,5000
DW 3 DUP(5000),7500,2500,5000,5000,7500,2500,5000,3 DUP(5000),7500,2500,5000,5000,5000
DW 3 DUP(5000),7500,2500,5000,3 DUP(5000),7500,2500,5000,3 DUP(5000),7500,2500,5000,5000
; 歌曲2
f2 DW 330 , 294 , 262 , 294 , 3 DUP (330)
DW 294 , 294 , 294 , 330 , 392 , 392
DW 330 , 294 , 262 , 294 , 4 DUP (330)
DW 294 , 294 , 330 , 294 , 262 , 0
t2 DW 6 DUP (5000) , 10000
DW 2 DUP (5000 , 5000 , 5000 , 10000)
DW 12 DUP (5000) , 20000
; 歌曲3
f3 DW 330,330,349,392,392,349,330,294,262,262,294,330,330,294,294,30000
DW 330,330,349,392,392,349,330,294,262,262,294,330,294,262,262,30000
DW 294,294,330,262,294,330,349,330,262,294,330,349,330,294,262,294,196,30000
DW 330,330,349,392,392,349,330,294,262,262,294,330,294,262,262,30000
t3 DW 12 DUP(10000),15000,5000,10000,10000
DW 12 DUP(10000),15000,5000,10000,10000
DW 5 DUP(10000),5000,5000,3 DUP(10000),5000,5000,6 DUP(10000)
DW 12 DUP(10000),15000,5000,10000,10000
; 歌曲4
f4 DW 4 DUP (392) , 330 , 349 , 392 , 494
DW 4 DUP (440) , 394 , 440 , 392
DW 4 DUP (392) , 494 , 440 , 392 , 349
DW 4 DUP (349) , 330 , 294 , 262
DW 4 DUP (532) , 392 , 440 , 2 DUP(523) ,572
DW 4 DUP (551) , 532 , 494 , 440
DW 5 DUP (494) , 532 , 551 , 392
DW 2 DUP (494) , 532 , 551 , 532 , 494 , 532
t4 DW 6 DUP (5000) , 2 DUP ( 10000)
DW 6 DUP (5000) , 20000
DW 6 DUP (5000) , 5000 , 15000
DW 6 DUP (5000) , 20000
DW 6 DUP (5000) , 10000 , 5000 , 10000
DW 6 DUP (5000) , 20000
DW 6 DUP (5000) , 10000 , 10000
DW 6 DUP (5000) , 20000 , 0
data ENDS
;*****************************************************************
program SEGMENT
ASSUME CS :program , DS : data
;-----------------------------------------------------------------
main PROC NEAR
;界面
start: PUSH DS
SUB AX , AX
PUSH AX
MOV AX , data
MOV DS , AX
MOV SI , 0
MOV BP , 0
CALL enter
CALL enter
LEA DX , mess1
MOV AH , 09h
INT 21h
CALL enter
CALL enter
LEA DX , mess2
MOV AH , 09h
INT 21h
CALL enter
CALL enter
LEA DX , mess3
MOV AH , 09h
INT 21h
CALL enter
LEA DX , mess4
MOV AH , 09h
INT 21h
CALL enter
LEA DX , mess6
MOV AH , 09h
INT 21h
CALL enter
LEA DX , mess1
MOV AH , 09h
INT 21h
LEA DX , mess5
MOV AH , 09h
INT 21h
;接收字符
keyword: SUB AX , AX
MOV AH , 01h
INT 21h
CMP AL , 31h
JZ song1
CMP AL , 32h
JZ song2
CMP AL , 33h
JZ song3
CMP AL , 34h
JZ song4
CMP AL , 35h
JZ exit
song1: CALL sing1
JMP continue
song2: CALL sing2
JMP continue
song3: CALL sing3
JMP continue
song4: CALL sing4
continue: JMP keyword
exit: MOV AH , 4ch
INT 21h
main ENDP
;-----------------------------------------------------------------
sing1 PROC NEAR
LEA SI , f1
LEA BX , t1
CALL music
RET
sing1 ENDP
;----------------------------------------------------------------
sing2 PROC NEAR
LEA SI , f2
LEA BX , t2
CALL music
RET
sing2 ENDP
;----------------------------------------------------------------
sing3 PROC NEAR
LEA SI , f3
LEA BX , t3
CALL music
RET
sing3 ENDP
;----------------------------------------------------------------
sing4 PROC NEAR
LEA SI , f4
LEA BX , t4
CALL music
RET
sing4 ENDP
;----------------------------------------------------------------
music PROC NEAR
LOOP1: MOV DI , [SI]
CMP DI , 0
JE exit1
MOV BX , [BP]
JMP sound
LOOP3: ADD SI , 2
ADD BP , 2
JMP LOOP1
sound: MOV AL , 0b6h
OUT 43h , AL
MOV DX , 12h
MOV AX , 533h*896
DIV DI
OUT 42h , AL
MOV AL , AH
OUT 42h , AL
IN AL , 61h
MOV AH , AL
OR AL , 3
OUT 61h , AL
MOV CX , BX
LOOP2: PUSH CX
MOV CX , 2801
delay: LOOP delay
POP CX
LOOP LOOP2
MOV AL, AH
OUT 61h , AL
JMP LOOP3
exit1: RET
music ENDP
;------------------------------------------------
enter PROC NEAR
MOV DL , 10
MOV AH , 02h
INT 21h
MOV DL , 13
INT 21h
RET
enter ENDP
;-----------------------------------------------
program ENDS
;***********************************************
END start |
|