Comparing Strings

来源:互联网 发布:网络套路是什么意思 编辑:程序博客网 时间:2024/06/11 07:56
The CMPS family of instructions is used to compare string values.

❑ CMPSB: Compares a byte value
❑ CMPSW: Compares a word (2 bytes) value
❑ CMPSL: Compares a doubleword (4 bytes) value

Each time the CMPS instruction is executed, the ESI and EDI registers are incremented or decrementedby the amount of the data size compared, depending on the DF flag setting.

The CMPS instruction subtracts the destination string from the source string, and sets the carry, sign, overflow, zero, parity, and adjust flags in the EFLAGS register appropriately. 

After the CMPS instruction,you can use the normal conditional jump instructions to branch, depending on the values of the strings.

.section .datavalue1:.ascii “Test”value2:.ascii “Test”.section .text.globl _start_start:nopmovl $1, %eaxleal value1, %esileal value2, %edicldcmpslje equalmovl $1, %ebxint $0x80equal:movl $0, %ebxint $0x80


原创粉丝点击