我与一些AT & T汇编语法问题所困扰。不区分大小写字符串匹配
进出口使用在Linux x86 “视” 的编译器。
林做一个密码程序,但它必须是不区分大小写。澄清一下,无论任何特定角色的情况如何,它都应评估真实。
我有正常的评估程序正常工作,我有它设置为通过字符串进行迭代。
#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
这是部分IM着,我无法弄清楚如何真正转换的情况下的字符挣扎。我知道我需要添加或减去32,但有些不对。任何意见或建议都会非常有帮助。谢谢。
andb $32, %al #
xorb (%edx), %al
这是coverting的情况下的部分,我已经试过add
,sub
,and
和or
,我只是无法得到它的工作。这并不是必然的,我意识到jz SkipCase
。
的比较例程在很大程度上是基于对关在这里另外一个问题,我会如果nessessary链接。
道歉布局和过度的哈希值,坏的评论风格,我知道。
你的问题的标题是有点误导,因为你的问题显然不是语法 – hirschhornsalz
的问题是,我不知道什么语法使用。我认为程序的逻辑很好,我只需要澄清哪些代码在哪里使用。 – TheoVate
嗯,我会建议使用_cmp_代替_sub_甚至_xor_。它具有不改变操作数的优点(像sub一样)。对于从小写到大写的转换,我建议'sub $ 20h'而不是'xor $ 20h',除非你想混淆你的代码。但是,这一切与AT&T语法无关。 – hirschhornsalz