📄 sound4.asm
字号:
;汇编音乐程序2008-12-06 14:14程序1
data segment
dis db 'the bell is ring',0dh,0ah,'$'
n db 5
data ends
stack segment stack
db 100 dup(?)
stack ends
code segment
assume cs:code,ds:data,ss:stack
start: mov ax,data
mov ds,ax
mov al,0b6h
out 43h,al
mov ax,533h*896
mov dx,12h
mov di,330
div di
out 42h,al
mov al,ah
out 42h,al
mov si,5
disp: in al,61h
mov ah,al
or al,3
out 61h,al
mov bx,0ffffh
wait1: mov cx,3801
delay: loop delay
dec bx
jnz wait1
mov al,ah
out 61h,al
mov dx,offset dis
mov ah,09h
int 21h
dec si
jnz disp
mov ah,4ch
int 21h
code ends
end start
程序2
data segment
m1 dw 131,147,165,175,196,220,247
m2 dw 262,294,330,347,392,440,494
m3 dw 523,578,650,680,774,866,958
n dw 3000h
data ends
stack1 segment para stack 'stack'
dw 100 dup(?)
stack1 ends
code segment
assume cs:code,ds:data,ss:stack1
main proc far
start:
push ds
mov ax,0
push ax
mov ax,stack1
mov ss,ax
mov ax,data
mov ds,ax
readkey:
mov bx,n
mov ah,8
int 21h
cmp al,'a'
jge music
cmp al,39h
jle music
add al,20h
music:
cmp al,'1'
mov di,m3
jz soundd
cmp al,'2'
mov di,m3+2
jz soundd
cmp al,'3'
mov di,m3+4
jz soundd
cmp al,'4'
mov di,m3+6
jz soundd
cmp al,'5'
mov di,m3+8
jz soundd
cmp al,'6'
mov di,m3+10
jz soundd
cmp al,'7'
mov di,m3+12
jz soundd
cmp al,'q'
mov di,m2
jz soundd
jnz soundz
soundd:
jmp sound
soundz:
cmp al,'w'
mov di,m2+2
jz sound
cmp al,'e'
mov di,m2+4
jz sound
cmp al,'r'
mov di,m2+6
jz sound
cmp al,'t'
mov di,m2+8
jz sound
cmp al,'y'
mov di,m2+10
jz sound
cmp al,'u'
mov di,m2+12
jz sound
cmp al,'a'
mov di,m1
jz sound
cmp al,'s'
mov di,m1+2
jz sound
cmp al,'d'
mov di,m1+4
jz sound
cmp al,'f'
mov di,m1+6
jz sound
cmp al,'g'
mov di,m1+8
jz sound
cmp al,'h'
mov di,m1+10
jz sound
cmp al,'j'
mov di,m1+12
jz sound
cmp al,'0'
jz exit
cmp al,13
jnz readr
mov ah,02h
mov dl,13
int 21h
mov dl,10
int 21h
readr:
jmp readkey
sound:
call gensound
jmp readkey
exit:
ret
main endp
gensound proc near
push ax
push bx
push cx
push dx
push di
mov dl,al
mov ah,02h
int 21h
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
wait1:
mov cx,3801
delay:
loop delay
dec bx
jnz wait1
mov al,ah
out 61h,al
pop di
pop dx
pop cx
pop bx
pop ax
ret
gensound endp
code ends
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -