急!!关于汇编程序方面的问题!
程序如下:stacksegmentstackdb100dup(?)stackendsdatasegmentBufferdb0f5h,46h,78h,4fh,0bch,0d...
程序如下:
stack segment stack
db 100 dup(?)
stack ends
data segment
Buffer db 0f5h,46h,78h,4fh,0bch,0dah,0abh,02h
db 12h,56h,0d5h,0ach,34h,89h,45h,0c3h
db 00,14h,45h,58h,64h,0d4h,0c3h,0a5h
db 0b3h,0ffh,0d9h,64h,0d3h,90h,80h,7fh
count equ $-buffer
plus db count dup(?)
minus db count dup(?)
data ends
code segment para 'code'
assume cs:code,ss:stack,ds:data,es:data
start proc far
push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
mov es,ax
mov si,offset buffer
lea di,plus
lea bx,minus
mov cx,count
l1: lodsb
test al,80
jnz l2
jmp again
stosb
l2: xchg bx,di
stosb
xchg bx,di
again: loop l1
pop ax
pop ds
ret
start endp
code ends
end start
这个程序老是不能运行,请各位高手帮帮忙,帮我看一下那里有问题,谢谢了! 展开
stack segment stack
db 100 dup(?)
stack ends
data segment
Buffer db 0f5h,46h,78h,4fh,0bch,0dah,0abh,02h
db 12h,56h,0d5h,0ach,34h,89h,45h,0c3h
db 00,14h,45h,58h,64h,0d4h,0c3h,0a5h
db 0b3h,0ffh,0d9h,64h,0d3h,90h,80h,7fh
count equ $-buffer
plus db count dup(?)
minus db count dup(?)
data ends
code segment para 'code'
assume cs:code,ss:stack,ds:data,es:data
start proc far
push ds
xor ax,ax
push ax
mov ax,data
mov ds,ax
mov es,ax
mov si,offset buffer
lea di,plus
lea bx,minus
mov cx,count
l1: lodsb
test al,80
jnz l2
jmp again
stosb
l2: xchg bx,di
stosb
xchg bx,di
again: loop l1
pop ax
pop ds
ret
start endp
code ends
end start
这个程序老是不能运行,请各位高手帮帮忙,帮我看一下那里有问题,谢谢了! 展开
1个回答
展开全部
; 本程序通过编译,运行正确
Code Segment
Assume CS:Code,DS:Code
; -------------------------------------
; Subroutine 延时指定的时钟嘀嗒数
; 入口:
; Didas=时钟嘀嗒数(1秒钟约嘀嗒18.2次,10秒钟嘀嗒182次。若延时不是秒的10数次倍,误差稍微大点)
Delay Proc Near
push dx
push cx
xor ax,ax
int 1ah
mov Times,dx
mov Times[2],cx
Read_Time: xor ax,ax
int 1ah
sub dx,Times
sbb cx,Times[2]
cmp dx,Didas
jb Read_Time
pop cx
pop dx
ret
Times dw 0,0
Delay EndP
; -------------------------------------
; 入口参数
; SI=声音频率地址
; CX=时间
Music Proc Near
in al,61h
push ax
or al,3
out 61h,al ;接通扬声器
push cx
push dx
push si
mov al,0b6h
out 43h,al
mov dx,12h
mov ax,348ch
div word ptr [si]
out 42h,al
mov al,ah
out 42h,al
in al,61h
mov ah,al
or al,3
out 61h,al
mov cx,3314
push ax
@@Waitf1: in al,61h
and al,10h
cmp al,ah
jz @@Waitf1
mov ah,al
loop @@Waitf1
pop ax
call Delay ;延时
mov al,ah
out 61h,al ;关闭扬声器
pop si
pop dx
pop cx
pop ax
out 61h,al
ret
Music EndP
; -------------------------------------
Didas equ 18 ;延时(时钟嘀嗒次数)
D1 dw 138,147,165,175,196,220,247,262,294,330,349
dw 392,440,494,524,587,659,698,784,880,988
N equ ($-D1)/2
Start: push cs
pop ds
push cs
pop es ;使数据段、附加段与代码段同段
xor bx,bx
mov cx,N
@@Music: lea si,D1[bx] ;对应的频率值地址
call Music ;激活扬声器,使之发出指定频率、指定时长的声音
inc bx
inc bx
loop @@Music
Exit_Proc: mov ah,4ch ;结束程序
int 21h
Code ENDS
END Start ;编译到此结束
请参考
Code Segment
Assume CS:Code,DS:Code
; -------------------------------------
; Subroutine 延时指定的时钟嘀嗒数
; 入口:
; Didas=时钟嘀嗒数(1秒钟约嘀嗒18.2次,10秒钟嘀嗒182次。若延时不是秒的10数次倍,误差稍微大点)
Delay Proc Near
push dx
push cx
xor ax,ax
int 1ah
mov Times,dx
mov Times[2],cx
Read_Time: xor ax,ax
int 1ah
sub dx,Times
sbb cx,Times[2]
cmp dx,Didas
jb Read_Time
pop cx
pop dx
ret
Times dw 0,0
Delay EndP
; -------------------------------------
; 入口参数
; SI=声音频率地址
; CX=时间
Music Proc Near
in al,61h
push ax
or al,3
out 61h,al ;接通扬声器
push cx
push dx
push si
mov al,0b6h
out 43h,al
mov dx,12h
mov ax,348ch
div word ptr [si]
out 42h,al
mov al,ah
out 42h,al
in al,61h
mov ah,al
or al,3
out 61h,al
mov cx,3314
push ax
@@Waitf1: in al,61h
and al,10h
cmp al,ah
jz @@Waitf1
mov ah,al
loop @@Waitf1
pop ax
call Delay ;延时
mov al,ah
out 61h,al ;关闭扬声器
pop si
pop dx
pop cx
pop ax
out 61h,al
ret
Music EndP
; -------------------------------------
Didas equ 18 ;延时(时钟嘀嗒次数)
D1 dw 138,147,165,175,196,220,247,262,294,330,349
dw 392,440,494,524,587,659,698,784,880,988
N equ ($-D1)/2
Start: push cs
pop ds
push cs
pop es ;使数据段、附加段与代码段同段
xor bx,bx
mov cx,N
@@Music: lea si,D1[bx] ;对应的频率值地址
call Music ;激活扬声器,使之发出指定频率、指定时长的声音
inc bx
inc bx
loop @@Music
Exit_Proc: mov ah,4ch ;结束程序
int 21h
Code ENDS
END Start ;编译到此结束
请参考
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询