;this code assumes that both DS and ES point to the correct segments. cld mov si,offset foo mov di,offset bar mov cx,4 ;length of the shorter of the two. repz cmpsb ; this will continue until the strings are different or CX = 0, ; whichever occurs first. If, after this, the zero flag is set and CX=0, ; the strings were the same ret foo byte "test" bar byte "test"