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, :label
Checks if register
vX
is equal to zeroif (vX == 0)
if-nez vX, :label
Checks if register
vX
is not equal to zeroif (vX != 0)
if-lt vX, vY, :label
Checks if register
vX
is less than registervY
if (vX < vY)
if-le vX, vY, :label
Checks if register
vX
is less than or equal to registervY
if (vX <= vY)
if-gt vX, vY, :label
Checks if register
vX
is greater than registervY
if (vX > vY)
if-ge vX, vY, :label
Checks if register
vX
is greater than or equal to registervY
if (vX >= vY)
:label
represents 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,target
if vx == vy
if-ne vx,vy,target
if (vX != vy)
if-lt vx,vy,target
if (vX < vY)
if-le vx,vy,target
if (vx =< vy)
if-gt vx,vy,target
if (vx > vy)
if-ge vx, vy,target
if (vx >= vy)
target
represents 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