I am reversing some malware and I came across this in my disassembly:
│ 0x0040f5ec 8bd8 mov ebx, eax
│ 0x0040f5ee 85db test ebx, ebx
│ ┌─< 0x0040f5f0 7507 jne 0x40f5f9
│ │ 0x0040f5f2 8bc6 mov eax, esi
│ ┌──< 0x0040f5f4 e9b3000000 jmp 0x40f6ac
│ │└─> 0x0040f5f9 57 push edi
As I understand it, testing a register with itself will always set the zero flag. JNE will then check the zero flag and jump if it's not set. If this is the case, why do we have the JNE jump right after testing a register against itself? Under what circumstances would it be executed?
Am I misunderstanding the TEST or JNE ops, or is there something else that I'm missing?
Thanks for any help and sorry if this is a stupid question.