I just opened a file in IDA Pro and I found some code that looks completely useless. However, I thought it might have some use. Doesn’t the sub eax,0 just subtract 0 from eax?
The code:
hinstDLL= dword ptr 4
fdwReason= dword ptr 8
lpReserved= dword ptr 0Ch
mov eax, [esp+fdwReason]
sub eax, 0
jz short loc_10001038
The
subinstruction sets flags (OF,SF,ZF,AF,PF, andCF, according to the documentation) – themovinstruction does not. Thejzwill jump only if the zero flag (ZF) is set, so if you want to jump based on the value ineaxthat flag has to be set appropriately.