String inequality

来源:互联网 发布:如何看待网络暴力 编辑:程序博客网 时间:2024/05/17 12:20
When comparing two strings of different lengths, the comparison is based on the number of characters in the shorter string.

1:If the shorter string would be greater than the same number of characters in the longer string, then the shorter string is greater than the longer string. 


2:If the shorter string would be less than the same number of characters in the longer string, then the shorter string would be less than the longer string.


:3:If the shorter string is equal to the same number of characters in the longer string, the longer string is greater than the shorter string.


Using this rule, the following examples would be true:
❑ “test” is greater than “boomerang”
❑ “test” is less than “velocity”

❑ “test” is less than “test1”

.section .datastring1:.ascii “test”length1:.int 4string2:.ascii “test1”length2:.int 5.section .text.globl _start_start:noplea string1, %esilea string2, %edimovl length1, %ecxmovl length2, %eaxcmpl %eax, %ecxja longerxchg %ecx, %eaxlonger:cldrepe cmpsbje equaljg greaterless:movl $1, %eaxmovl $255, %ebxint $0x80greater:movl $1, %eaxmovl $1, %ebxint $0x80equal:movl length1, %ecxmovl length2, %eaxcmpl %ecx, %eaxjg greaterjl lessmovl $1, %eaxmovl $0, %ebxint $0x80


原创粉丝点击