汇编语言钢琴
Posted 隅子酱的blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了汇编语言钢琴相关的知识,希望对你有一定的参考价值。
1 DATA SEGMENT 2 msg DB 0DH,0AH,‘[ 1 2 3 4 5 6 7 ]‘ 3 DB 0DH,0AH,‘ [ q w e r t y u ]‘ 4 DB 0DH,0AH,‘_________________‘ 5 DB 0DH,0AH,‘9: EXIT‘ 6 DB 0DH,0AH,‘_________________‘,‘$‘ 7 ;********音调******后面用到-1判断音乐播是否放完 8 sound_0 DW -1 9 sound_11 DW 441,-1 10 sound_12 DW 495,-1 11 sound_13 DW 556,-1 12 sound_14 DW 589,-1 13 sound_15 DW 661,-1 14 sound_16 DW 742,-1 15 sound_17 DW 833,-1 16 sound_1 DW 882,-1 17 sound_2 DW 990,-1 18 sound_3 DW 1112,-1 19 sound_4 DW 1178,-1 20 sound_5 DW 1322,-1 21 sound_6 DW 1484,-1 22 sound_7 DW 1655,-1 23 time DW 25 24 DATA ENDS 25 ;************************ 26 STACK SEGMENT 27 Db 200 DUP (‘STACK‘) 28 STACK ENDS 29 ;*********************** 30 CODE SEGMENT 31 ASSUME DS:DATA,SS:STACK,CS:CODE 32 START: 33 MOV AX,DATA 34 MOV DS,AX 35 36 MOV aH,0 37 MOV AL,00 38 INT 10H 39 40 ;*****定义一个宏***** 41 SHOW MACRO b 42 LEA DX,b 43 MOV AH,9 44 INT 21H 45 ENDM 46 47 ;********一个声音宏******** 48 onesound macro soundis,jumpis,letteris 49 CMP AL,letteris 50 JNZ jumpis 51 LEA SI,soundis 52 LEA BP,DS:time 53 CALL MUSIC 54 JMP input 55 ENDM 56 57 show msg 58 59 INPUT: MOV AH,01H 60 INT 21H 61 CMP AL,‘9‘ 62 jnz go 63 64 mov ah,4ch 65 int 21h 66 67 go: onesound sound_11,a0,‘q‘ 68 a0: onesound sound_12,b0,‘w‘ 69 b0: onesound sound_13,c0,‘e‘ 70 c0: onesound sound_14,d0,‘r‘ 71 d0: onesound sound_15,e0,‘t‘ 72 e0: onesound sound_16,f0,‘y‘ 73 f0: onesound sound_17,g0,‘u‘ 74 g0: onesound sound_1,h0,‘1‘ 75 h0: onesound sound_2,i0,‘2‘ 76 i0: onesound sound_3,j0,‘3‘ 77 j0: onesound sound_4,k0,‘4‘ 78 k0: onesound sound_5,l0,‘5‘ 79 l0: onesound sound_6,m0,‘6‘ 80 m0: onesound sound_7,n0,‘7‘ 81 n0: onesound sound_0,o0,al 82 o0: jmp input 83 ;********************发声 84 85 GENSOUND PROC NEAR 86 ;------------- 87 PUSH AX 88 PUSH BX 89 PUSH CX 90 PUSH DX 91 PUSH DI 92 ;-------------- 93 MOV AL,0B6H 94 OUT 43H,AL 95 MOV DX,12H 96 MOV AX,348ch 97 DIV DI 98 OUT 42H,AL 99 MOV AL,AH 100 OUT 42H,AL 101 IN AL,61H 102 MOV AH,AL 103 OR AL,3 104 OUT 61H,AL 105 106 WAIT1: MOV CX,3314 107 call waitf 108 DELAY1: DEC BX 109 JNZ WAIT1 110 MOV AL,AH 111 OUT 61H,AL 112 113 ;---------------- 114 POP DI 115 POP DX 116 POP CX 117 POP BX 118 POP AX 119 ;------------------- 120 RET 121 GENSOUND ENDP 122 123 ;************************** 124 waitf proc near 125 push ax 126 waitf1: 127 in al,61h 128 and al,10h 129 cmp al,ah 130 je waitf1 131 mov ah,al 132 loop waitf1 133 pop ax 134 ret 135 waitf endp 136 137 ;************************ 138 MUSIC PROC NEAR 139 PUSH DS 140 SUB AX,AX 141 PUSH AX 142 FREG: MOV DI,[SI] 143 144 CMP DI,-1;音乐是否放完? 145 JE END_MUS 146 147 MOV BX,DS:[BP] 148 CALL GENSOUND 149 ADD SI,2 150 ADD BP,2 151 JMP FREG 152 END_MUS: 153 RET 154 MUSIC ENDP 155 CODE ENDS 156 ;********************** 157 END START
以上是关于汇编语言钢琴的主要内容,如果未能解决你的问题,请参考以下文章