IF statement
These blocks are super important because you can change most application behavior by switching a state from “
true" to “false" and vice versa.
📍The most common if conditions available in Smali:
if conditions available in Smali:Comparison against 0.
Smali Instruction
Description
Java Equivalent
if-eqz vX, :labelChecks if register
vXis equal to zeroif (vX == 0)if-nez vX, :labelChecks if register
vXis not equal to zeroif (vX != 0)if-lt vX, vY, :labelChecks if register
vXis less than registervYif (vX < vY)if-le vX, vY, :labelChecks if register
vXis less than or equal to registervYif (vX <= vY)if-gt vX, vY, :labelChecks if register
vXis greater than registervYif (vX > vY)if-ge vX, vY, :labelChecks if register
vXis greater than or equal to registervYif (vX >= vY):labelrepresents a location in the code to jump to if the condition is true.To read this:

Comparison against a register
Smali Instruction
Java Equivalent
if-eq vx,vy,targetif vx == vyif-ne vx,vy,targetif (vX != vy)if-lt vx,vy,targetif (vX < vY)if-le vx,vy,targetif (vx =< vy)if-gt vx,vy,targetif (vx > vy)if-ge vx, vy,targetif (vx >= vy)targetrepresents a location in the code to jump to if the condition is true.To read this:

An Example

Notes
Lines starting with a colon (e.g.,
:goto_0) are jump references and can be ignored.Lines with instructions before the colon (e.g.,
if-lez v0 :cond_0) must not be ignored and require attention.
Last updated