32位平台的汇编 AT&T
# strcmp.s -Am example of comparing strings
.section .data
string1:
.ascii "test"
length1:
.int 4
string2:
.ascii "test1"
length2:
.int 5
.section .text
.global main
main:
lea string1, %esi
lea string2, %edi
movl length1, %ecx
movl length2, %eax
cmpl %eax, %ecx
jb longer
xchg %ecx, %eax
longer:
cld
repe cmpsb
je equal
jg greater
less:
movl $1, %eax
movl $255, %ebx
int $0x80
greater:
movl $1, %eax
movl $1, %ebx
int $0x80
equal:
movl length1, %ecx
movl length2, %eax
cmpl %eax, %ecx
jg greater
jl less
movl $1, %eax
movl $0, %ebx
int $0x80
字符串比较--汇编
猜你喜欢
转载自blog.csdn.net/li740207611/article/details/54312141
今日推荐
周排行