0 Replies - 350 Views - Last Post: 06 September 2013 - 03:15 PM Rate Topic: -----

#1 worriednacho  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-September 13

PROBLEM WITH REPE CMPSB

Posted 06 September 2013 - 03:15 PM

the repe cmpsb is confusing me a bit. i know very well that repe cmpsb will compare string bytewise until equal or cx=0 .. BUT when i try to confirm this with a simple program, no matter whether the strings are equal or not, i always get a mismatch.
can anyone please guide me and explain what i am doing wrong.. would be a great help :)

"i am comparing two strings v1 & v2 both having the string 'apple', the answer however results in mismatch" Here is the code
    .model small
    .data
       mese    db "match!","$"
       mesne   db "mismatch!","$"
       v1 db "apple","$"
       v2 db "apple","$"
    .code
    main proc
    mov ax,@data
    mov ds,ax   
    
    mov si,offset v1
    mov di,offset v2
    
    mov cx,5
    
    repe cmpsb
    je equal
    
    mov dx,offset mesne
    jmp print
    equal:
    mov dx,offset mese
    print:
    mov ah,09h
    int 21h 
    
    mov ah,4ch
    int 21h
    
    main endp
    end main



Is This A Good Question/Topic? 0
  • +

Page 1 of 1