compare successive locations in 2 arrays with repe compare until a mismatch with repne compare until they match
There are 4 varieties of cmps instructions: cmpsb, cmpsw, cmpsd and cmpsq which are for byte, word, doubleword and quadword arrays. They all operate using rcx to define the maximum number of iterations to use with repe or repne. The source array address is stored in rsi and the destination in rdi. The direction flag determines whether the addresses are incremented (DF=0) or decremented (DF=1). You use repe to repeat comparisons as long as they are equal; i.e. repeat until there is a mismatch. Of less common utility is to use repne which compares as long as the corresponding array elements are not equal; i.e. repeat until there is a match.
lea rdi, [dest] ; get the address of the destination array lea rsi, [source] ; get the address of the source array cld ; clear the direction flag to increment mov ecx, 1000 ; count = 1000 repe cmpsb ; compare up to 1000 bytes ; rdi and rsi increment by 1 each time ; At the end 1000 - ecx - 1 is the count of matching bytes. ; Likewise [rdi-1] and [rsi-1] are the locations of the mismatched ; bytes. ; If ecx == 0 at the end, the arrays matched for 1000 bytes. lea rsi, [source] ; get the address of the source array cld ; clear the direction flag to increment mov ecx, 100 ; count = 100 repne cmpsd ; compare 100 array elements ; stop on first match. ; rsi increments by 4 each time ; I can't guess why you would do this.