You can become crazy with this problem.
Lets see this other quick solution to compare strings.
Remember that strings are a sequence of bytes.
home : h(first byte),o(second byte),...,e(last byte),0 a tag to identify the end of the string.
Suppose you have a string inside a register : %esi and you want to compare only the first character with another one :
zero: .ascii "0"
cmpsb #this command compares the first byte(the first character) of the strings inside the registers ESI,EDI.
#Some examples of what you can do now :
je label1 #jump to label 1 if the first characters of the strings inside ESI,EDI are equal
jne label2 #jump to label 2 if the first characters of the strings inside ESI,EDI are not equal
jl label3 #jump to label 3 if the first character of the string inside ESI is lower (ASCII) than the first character of the string inside EDI.
#Now if you want to compare the second character of each string you can simply add 1 to the registers and they will point to the their second character, example:
#Its nice if you want to make a loop...
Edited 6 Years Ago by magicsign: n/a