Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x86 cmpl and jne

Tags:

x86

assembly

att

I'm tracing some x86 code for an assignment, and I was wondering what exactly "cmpl" does and how to predict whether or not the "jne" will be met.

80484bf:    83 7d f0 07             cmpl   $0x7,-0x10(%ebp)
80484c3:    75 16                   jne    80484db
like image 854
Richarizard Avatar asked Mar 08 '13 07:03

Richarizard


1 Answers

cmpl subtracts -0x10(%ebp) from $0x7 and modifies flags: AF CF OF PF SF ZF.

  1. If memory at -0x10(%ebp) equals immediate 0x7 then the flag ZF is set. This is below EBP so it's probably a local variable, if this is an un-optimized build using EBP as a frame pointer.
  2. jne 80484db means that if the two compared numbers are different (ZF=0), jump to 80484db

To summarize, your code is equivalent to :

compare A to 7
jump to 0x80484db if they are different.
like image 120
Omar MEBARKI Avatar answered Sep 24 '22 06:09

Omar MEBARKI