Saturday, January 20, 2007

i write a assembly program tonight

i have forgot that i have to make a program as the schoolwork about assembly language ,after some day's happiness.the program title is a portamento work.
you can enter the low frequency and the high frequency to get a portamento.
i make it successful now,paste it here to make sure i will find it in furture.

data segment
mess1 db 13,10,'*********** sound program ****************'
db 13,10,' choose the operation '
db 13,10,' c : continue '
db 13,10,' q : quit to dos '
db 13,10,'************copyright@chengning***********$'
mess11 db 'input the choose:$'
mess2 db 'please enter the start frequency:$'
mess3 db 'please enter the end frequency:$'


frestart label byte
max db 5
act db ?
freq1 db 5 dup(?)


choose label byte
hui db 5
haa db ?
chos db 2 dup(?)


data ends
;************************************
node segment
assume cs:node,ds:data,es:data
main proc far
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov es,ax

start:
call huanhang
lea dx,mess1
mov ah,09h
int 21h
call huanhang
lea dx,mess11
mov ah,09h
int 21h
lea dx,choose
mov ah,0ah
int 21h
mov si,2
cmp choose[si],'q'
jz exit
call huanhang
lea dx,mess2
mov ah,09h
int 21h
lea dx,frestart
mov ah,0ah
int 21h
call change
mov bx,ax
call huanhang
lea dx,mess3
mov ah,09h
int 21h
lea dx,frestart
mov ah,0ah
int 21h
call change
mov di,bx
huayin:
call sound
inc di
cmp di,ax
jnz huayin
jz start
;jz exit
exit:
mov ax,4c00h
int 21h
main endp
;***************************
change proc near
push bx
xor bh,bh
mov dh,10
mov cl,act
sub cl,1
xor ch,ch
mov si,2
zh: mov bl,frestart[si]
sub bl,30h
add ax,bx
mul dh
inc si
loop zh
pop bx
ret
change endp
;***************************
sound proc near
push ax
push bx
push dx
push cx
mov al,10110110b
out 43h,al
mov dx,12h
mov ax,34dch
div di
out 42h,al
mov al,ah
out 42h,al

in al,61h
mov ah,al
or al,3
out 61h,al
mov bx,100
leng:mov cx,2801
delay:loop delay
dec bx
jnz leng
mov al,ah
out 61h,al
goout: pop cx
pop dx
pop bx
pop ax
ret
sound endp
;****************************
huanhang proc near
push ax
push dx
mov ah,02h
mov dl,0dh
int 21h
mov dl,0ah
int 21h
pop dx
pop ax
ret
huanhang endp
;****************************
node ends
end main

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home