I am a beginner in RE. I compiled some code (x86 32bit), and opened it up in Ghidra. I come across the following instruction block:

CALL _strcmp
MOV dword ptr [EBP + local_1c], EAX
MOV EAX, dword ptr [EBP + local_1c]
ADD EAX, 0x4
CMP EAX, 0x8
JA LAB_xxxx

I understand this takes the return value of _strcmp and decides whether to jump or not. But why does the compiler decide to add the ADD EAX, 0x4 instruction right before the CMP? Shouldn't it simply CMP to 0x4 in the first place? (Which is also what I have in my code: if x<=4...)


  • Do you use the result in one of the branches and add 4?
    – sudhackar
    Apr 24 at 14:47
  • 2
    It'd be easier to answer definitively if you included the source code you compiled to produce this Apr 24 at 23:33


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.