Compare string using CMPSB : Assembly Code

include irvine32.inc

.data
source byte "i my name is usman",0
dest   byte "i am not a khan....",0

msg1 byte "1st String: ",0
msg2 byte "2nd string: ",0

msg3 byte "String name Dest is Large : ",0
msg4 byte "String name Dest is Small : ",0
msg5 byte "String :both sorce & Dest are Equal : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

mov esi,offset source
mov edi,offset dest
mov ecx,lengthof source
repe cmpsb
ja L1
jb L2
jmp L3

L1:
call crlf
mov edx,offset msg3
call writestring
call crlf
jmp e

L2:
call crlf
mov edx,offset msg4
call writestring
call crlf
jmp e

L3:
call crlf
mov edx,offset msg5
call writestring
call crlf
jmp e

e:
exit
main endp
end main


No comments

Powered by Blogger.