回 帖 发 新 帖 刷新版面

主题:没语法错误,有一条执行路径不执行,请大家帮忙改一下

data segment
 a db 100,0,100 dup('$')
 b db 100,0,100 dup('$')
 Msg db 0ah,0dh,'$'
 Msg1 db "input first character string:$"
 Msg2 db "Input second character string:$"
 Result1 db "-1$"
 Result2 db "1$"
 Result3 db "0$"
data ends

stack segment para stack
 db 20h dup(0)
stack ends

code segment
Assume ds:data,cs:code,ss:stack
  start:mov Ax,data
    mov ds,Ax
    mov es,Ax
    lea dx,Msg1
    mov ah,09h
    int 21h
    lea dx,Msg
    mov ah,09h
    int 21h
    lea dx,a
    mov ah,0ah
    int 21h
    lea dx,Msg
    mov ah,09h
    int 21h
    lea dx,Msg2
    mov ah,09h
    int 21h
    lea dx,Msg
    mov ah,09h
    int 21h
    lea dx,b
    mov ah,0ah
    int 21h
    lea dx,Msg
    mov ah,09h
    int 21h
    call Match
    mov ah,4ch
    int 21h
 Match proc far
    push ax
    push bx
    push dx  ;50
    ;add a[1],1
    ;add b[1],1
    xor si,si
    xor di,di
   lop1:lea bx,a[2]
    mov al,[bx+di]
    sub al,30h
    lea bx,b[2]
    mov dl,[bx+si]
    sub dl,30h
    cmp al,dl
    jne lop2
    inc di
    inc si
    lea bx,a
    cmp di,word ptr [bx+1]
    jz lop3
    lea bx,b
    cmp si,word ptr [bx+1]
    jz lop4
    jmp lop1
           ;70
   lop2:lea bx,b
    cmp al,dl
    jb lop21  ;a<b
    jmp lop22 ;a>b
   lop3:lea bx,b
    cmp si,word ptr [bx+1]
    jz lop5         ;a equal b
    jmp lop22     ;a'length<b'length,that,a>b
   lop4:lea bx,a
    cmp di,word ptr [bx+1]
    jz lop5       ;a equal b
    jmp lop21  ;a'length<b'length,that,a<b
  lop21:lea dx,result1
    mov ah,09h
    int 21h
    pop dx
    pop bx
    pop ax
    ret
  lop22:lea dx,result2
    mov ah,09h
    int 21h
    pop dx
    pop bx
    pop ax
    ret
  lop5: lea dx,result3
    mov ah,09h
    int 21h
    pop dx
    pop  bx
    pop ax
    ret
   Match endp

code ends
  end start

回复列表 (共1个回复)

沙发

程序的功能是比较两个字符串的大小,但是当两个字符串相等的时候,并不能的相应的输出,调试以后发现,在字符串到达末尾的时候,并不退出比较,而是继续比较下去,是不是我的判断条件有错误呢?

我来回复

您尚未登录,请登录后再回复。点此登录或注册