![]() |
#2
tottibuffon2010-04-24 22:45
|

这个事整段 代码,谁能帮我解释解释rotate和print2段的代码,越详细越好谢谢
;********************************************************************
datasg segment para 'data'
mess1 db 'Enter keyword:','$'
mess2 db 'Enter sentence:','$'
;
stoknkeyword db 10
act1 db ?
stokn1 db 10 dup(?)
;
stoknsenten db 50
act2 db ?
stokn2 db 50 dup(?)
;
mess3 db 'Match at location:','$'
mess4 db 'No match!',0dh,0ah,'$'
mess5 db 'H of the sentence.',0dh,0ah,'$'
mess7 db 0dh,0ah,'$'
flag dw 0
datasg ends
;********************************************************************
codesg segment para 'code'
main proc far
assume cs:codesg,ds:datasg,es:datasg
start:
mov ax,datasg
mov ds,ax
mov es,ax
;
lea dx,mess1
mov ah,09
int 21h
lea dx,stoknkeyword
mov ah,0ah
int 21h
lea dx,mess7
mov ah,09
int 21h
loop1:
lea dx,mess2
mov ah,09
int 21h
lea dx,stoknsenten
mov ah,0ah
int 21h
lea dx,mess7
mov ah,09
int 21h
;
mov al,act1
cmp al,act2
jg print
lea si,stokn1
lea bx,stokn2
loop2:
mov di,bx
mov cl,act1
lea si,stokn1
cld
repz cmpsb
jz next
inc bx
dec act2
jnz loop2
test flag,0ffffh
jz print
jmp loop1
print:
lea dx,mess4
mov ah,09
int 21h
jmp loop1
next:
lea dx,mess3
mov ah,09h
int 21h
mov flag,bx
push bx
lea dx,stokn2
sub bx,dx
inc bx
push cx
mov ch,4
rotate:
mov cl,4
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl print2
add al,7h
print2:
mov dl,al
mov ah,2
int 21h
inc bx
dec ch
jnz rotate
pop cx
pop bx
lea dx,mess5
mov ah,09h
int 21h
inc bx
dec act2
jnz loop2
jmp loop1
main endp
;--------------------------------------------------------------------
codesg ends
;********************************************************************
end start
;********************************************************************
datasg segment para 'data'
mess1 db 'Enter keyword:','$'
mess2 db 'Enter sentence:','$'
;
stoknkeyword db 10
act1 db ?
stokn1 db 10 dup(?)
;
stoknsenten db 50
act2 db ?
stokn2 db 50 dup(?)
;
mess3 db 'Match at location:','$'
mess4 db 'No match!',0dh,0ah,'$'
mess5 db 'H of the sentence.',0dh,0ah,'$'
mess7 db 0dh,0ah,'$'
flag dw 0
datasg ends
;********************************************************************
codesg segment para 'code'
main proc far
assume cs:codesg,ds:datasg,es:datasg
start:
mov ax,datasg
mov ds,ax
mov es,ax
;
lea dx,mess1
mov ah,09
int 21h
lea dx,stoknkeyword
mov ah,0ah
int 21h
lea dx,mess7
mov ah,09
int 21h
loop1:
lea dx,mess2
mov ah,09
int 21h
lea dx,stoknsenten
mov ah,0ah
int 21h
lea dx,mess7
mov ah,09
int 21h
;
mov al,act1
cmp al,act2
jg print
lea si,stokn1
lea bx,stokn2
loop2:
mov di,bx
mov cl,act1
lea si,stokn1
cld
repz cmpsb
jz next
inc bx
dec act2
jnz loop2
test flag,0ffffh
jz print
jmp loop1
print:
lea dx,mess4
mov ah,09
int 21h
jmp loop1
next:
lea dx,mess3
mov ah,09h
int 21h
mov flag,bx
push bx
lea dx,stokn2
sub bx,dx
inc bx
push cx
mov ch,4
rotate:
mov cl,4
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl print2
add al,7h
print2:
mov dl,al
mov ah,2
int 21h
inc bx
dec ch
jnz rotate
pop cx
pop bx
lea dx,mess5
mov ah,09h
int 21h
inc bx
dec act2
jnz loop2
jmp loop1
main endp
;--------------------------------------------------------------------
codesg ends
;********************************************************************
end start