CMP ESI, -20. This part of code makes no sense to me. How does this magic work?

69 Views Asked by At
76EB750D   83FE E0          CMP ESI,-20
76EB7510   0F87 AD000000    JA msvcrt.76EB75C3

I don't understand this part of code at all.

  1. Why is dword ESI compared to byte?!
  2. If ESI equals to FFFFFFF0 then the jump is performed. If ESI equals to FFFFF0F0 then the jump is not performed. If ESI equals to 000000F0 then the jump is not performed. How does this magic machine work?!

P.S. No, it's not a duplicate. No one who encounters this kind of problem will start searching for "how can I add 8 bits to 32 bits", it's ridiculous. "Jumps after CMP" have also no business in this, this was not the essence of the question at all. You, guys, have too much free time and too much desire to impose your power on people who ask questions.

1

There are 1 best solutions below

0
Jaroslav Tavgen On

Peter Cordes answered in the comments:

"Like most instructions with an immediate, cmp supports both a full-width and a sign-extended-imm8 encoding. felixcloutier.com/x86/cmp . That cmp/ja jumps if ESI is unsigned above 0xFFFFFFE0 = 32-bit -20".