In this instance (combined with `repnz scas`) it's easier to think about the "arithmetic meaning" of `not eax` which is `eax = -eax - 1`. That is equivalent to saying that all bits are flipped, just a different way to think about it.
– haroldAug 31 '22 at 07:04
`ecx` is decremented for each character `repnz scas` handles, having a `not` after it [is a common idiom](https://stackoverflow.com/q/26783797/555045)
– haroldAug 31 '22 at 08:23
[It's a well-known pattern to implement `strlen`](https://stackoverflow.com/questions/26783797/repnz-scas-assembly-instruction-specifics), well one of many.
– Margaret BloomAug 31 '22 at 09:21
If you're not sure what an instruction does (e.g. whether `repns scasb` will decrement ECX), look it up in the manual: https://www.felixcloutier.com/x86/rep:repe:repz:repne:repnz
– Peter CordesAug 31 '22 at 11:21