两首歌曲的汇编演示(发声代码)...
2004-12-22 21:18
751 查看
第一次作发声代码:
title music -- a music of 'Mary had a little lamb'
extrn soundf :far ;link music+soundf
stack segment para stack 'stack'
db 64 dup('stack...')
stack ends
dseg segment para'data'
mus_freg dw 330,294,262,294,3 dup(330)
dw 3 dup(294),330,392,392
dw 330,294,262,294,4 dup(330)
dw 294,294,330,294,262,-1
mus_time dw 6 dup(25),50
dw 2 dup(25,25,50)
dw 12 dup(25),100
dseg ends
cseg segment para 'code'
assume cs:cseg,ss:stack,ds:dseg
music proc far
mov ax,dseg
mov ds,ax
lea si,mus_freg
lea bp,ds:mus_time
freq:
mov di,[si]
cmp di,-1
je music
; je end_mus
mov bx,ds:[bp]
call soundf
add si,2
add bp,2
jmp freq
end_mus:
mov ax,4c00h
int 21h
music endp
cseg ends
end music
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
title music -- a music of 'Mary had a little lamb'
extrn soundf :far
stack segment para stack 'stack'
db 64 dup('stack...')
stack ends
dseg segment para'data'
mus_freg dw 330,392,330,294,330,392,330,294,330
dw 330,392,330,294,262,294,330,392,294
dw 262,262,220,196,196,220,262,294,330,262
dw -1
mus_time dw 3 dup(500),250,250,500,250,250,1000
dw 2 dup(500,500,250,250),1000
dw 3 dup(500,250,250),1000
dseg ends
cseg segment para 'code'
assume cs:cseg,ss:stack,ds:dseg
music proc far
mov ax,dseg
mov ds,ax
lea si,mus_freg
lea bp,ds:mus_time
freq:
mov di,[si]
cmp di,-1
je music
; je end_mus
mov bx,ds:[bp]
call soundf
add si,2
add bp,2
jmp freq
end_mus:
mov ax,4c00h
int 21h
music endp
cseg ends
end music
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
title soundf -- the speaker beeper
public soundf
cseg segment para 'code'
assume cs:cseg
soundf proc far
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
waitl:
mov cx,6630
call waitf
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
cseg ends
;---------------------------------------------------
end
下载代码:http://blogfile0.tom.com/file/0/9/3/f_85909_7938.rar
title music -- a music of 'Mary had a little lamb'
extrn soundf :far ;link music+soundf
stack segment para stack 'stack'
db 64 dup('stack...')
stack ends
dseg segment para'data'
mus_freg dw 330,294,262,294,3 dup(330)
dw 3 dup(294),330,392,392
dw 330,294,262,294,4 dup(330)
dw 294,294,330,294,262,-1
mus_time dw 6 dup(25),50
dw 2 dup(25,25,50)
dw 12 dup(25),100
dseg ends
cseg segment para 'code'
assume cs:cseg,ss:stack,ds:dseg
music proc far
mov ax,dseg
mov ds,ax
lea si,mus_freg
lea bp,ds:mus_time
freq:
mov di,[si]
cmp di,-1
je music
; je end_mus
mov bx,ds:[bp]
call soundf
add si,2
add bp,2
jmp freq
end_mus:
mov ax,4c00h
int 21h
music endp
cseg ends
end music
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
title music -- a music of 'Mary had a little lamb'
extrn soundf :far
stack segment para stack 'stack'
db 64 dup('stack...')
stack ends
dseg segment para'data'
mus_freg dw 330,392,330,294,330,392,330,294,330
dw 330,392,330,294,262,294,330,392,294
dw 262,262,220,196,196,220,262,294,330,262
dw -1
mus_time dw 3 dup(500),250,250,500,250,250,1000
dw 2 dup(500,500,250,250),1000
dw 3 dup(500,250,250),1000
dseg ends
cseg segment para 'code'
assume cs:cseg,ss:stack,ds:dseg
music proc far
mov ax,dseg
mov ds,ax
lea si,mus_freg
lea bp,ds:mus_time
freq:
mov di,[si]
cmp di,-1
je music
; je end_mus
mov bx,ds:[bp]
call soundf
add si,2
add bp,2
jmp freq
end_mus:
mov ax,4c00h
int 21h
music endp
cseg ends
end music
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
title soundf -- the speaker beeper
public soundf
cseg segment para 'code'
assume cs:cseg
soundf proc far
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
waitl:
mov cx,6630
call waitf
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
cseg ends
;---------------------------------------------------
end
下载代码:http://blogfile0.tom.com/file/0/9/3/f_85909_7938.rar
相关文章推荐
- 【原创】DOS下TSR程序的汇编演示代码1--自动按键程序
- 【原创】DOS下TSR程序的汇编演示代码2--黑屏保护程序
- CSS选项卡效果代码演示
- 获取页表项和页目录项VA的汇编代码的解析(整理)
- 汇编语言直接定指标的应用实验16代码
- 通过汇编代码理解成员函数指针并不是指针
- 使用WinDbg获得托管方法的汇编代码
- Android退出多个Activity的Java代码演示
- C语言中if 语句的汇编代码
- mysql 存储过程 演示样例代码
- CXF全接触(十) --- 异步调用代码演示
- 粒子滤波 演示与opencv代码
- 火车票演示示例及返回示例代码
- 核中汇编写的字符串函数代码分析
- JDBC增删改查 代码演示
- 汇编内核的MD5算法编写谈代码优化
- 1000个经常使用的Python库和演示样例代码
- 【ACM】P2011、P2012、P2013(*)、P2014代码演示
- 超酷创意HTML5动画演示及代码
- 你不知道的JavaScript演示代码Github地址