I’m struggling with a problem with some AT&T assembly syntax.
Im using the “as” compiler on linux x86.
Im making a password program but it needs to be case insensitive. To clarify, it should evaluate true regardless of the case of any given character.
I have the normal evaluation process working correctly and i have it set up to iterate through a string.
#Comparison Routine
movl $Password, %ebx #Move the entire hardcoded password into ebx
movl $buffer_data, %edx #Move the entire input password into edx
movl $Password_len, %ecx #Move the length of the input password into ecx
0:
movb (%ebx), %al #Move one byte of the hardcoded password into al
xorb (%edx), %al #Compare one byte of the input password to one byte of the hardedcoded
jz SkipCase #If they match, jump to SkipCase
#####
andb $32, %al #
xorb (%edx), %al
jz SkipCase
jnz IncorrectOutput #
SkipCase:
inc %ebx #Iterate through the
inc %edx #strings and decrease
dec %ecx #the length variable
jnz 0b #if we're not finished, continue
jmp CorrectOutput #If all is good, goto CorrectOutput
This is the section im struggling with, i can’t figure out how to actually convert the character between cases. I’m aware i need to add or subtract 32 from it but something is amiss. Any comments or suggestions would be very helpful. Thanks.
andb $32, %al #
xorb (%edx), %al
This is the section for coverting the case, i have tried add, sub, and and or and i just cant get it to work. i realise the jz SkipCase after this is not nessessary.
The comparison routine is largely based off another question on here that i’ll link if nessessary.
Apologies for layout and excessive hashes, bad commenting style i know.
I see that you first try to match the characters ‘strictly’ and when that fails you proceed with a case insensitive match.
What you instead need to do is something like this:
Hope that helps, I find it really difficult to explain bit operations in a short post like this. 🙂
Also, I presume this is either homework or some sort of excercise because a real password routine would have to be more clever – e.g. only perform the case insensitive check for letters, never digits or other characters.