ESIL(7)
π¦ ESIL(7) β Evaluable Strings Intermediate Language π¦
πΈ NAME πΈ
ESIL β Evaluable Strings Intermediate Language
β¨ SYNOPSIS β¨
Okay so ESIL β that's Evaluable Strings Intermediate Language β gives you an abstract, stack-based format for representing CPU instruction semantics across all kinds of architectures. It makes instruction emulation for analysis and debugging inside the radare2 framework happen. Iconic behavior, honestly. π
π DESCRIPTION π
Evaluable Strings Intermediate Language (ESIL) uses a Forth-like syntax, and it gives you a way to describe and emulate what machine instructions do in a platform-agnostic manner. It is especially useful in reverse engineering, letting you do cross-architecture binary analysis and exploitation through radare2. Obsessed. π¦
At its core, ESIL is a stack-based language where operations manipulate values on a stack. Each CPU instruction gets translated into an ESIL expression that models its behavior. This abstraction layer lets radare2 emulate code execution without actually running it, which is invaluable for analyzing untrusted binaries or understanding complex code flows. No cap, that's the whole vibe. π₯
π SYNTAX π
ESIL expressions use a series of operands and operations, manipulating values on an internal stack. These expressions are executed inside an ESIL virtual machine (VM), which enables simulation of CPU instructions' effects on registers and memory. β¨
The basic components of ESIL syntax are:
- Uppercase words are special keywords that operate on the ESIL VM (e.g.,
POP,DUP,TRAP) - Lowercase words are register names that can be used for reading or writing through operations
- Words starting with
$represent internal variables of the VM that are readonly (e.g.,$zfor zero flag) - Numbers can be in base 10 or hexadecimal (with
0xprefix) - Operations are separated by commas
- Results are pushed onto the stack or written to registers/memory
The rest of keywords can be added or removed via ESIL or architecture plugins, but this document describes the common and standard ESIL commands. π«Ά
π¦ USING ESIL IN RADARE2 π¦
radare2 provides several ways to work with ESIL:
- The
e asm.esil=trueoption displays ESIL expressions alongside assembly instructions - The
e emu.str=trueoption enables string emulation during analysis - The
aecommand family provides ways to evaluate and debug ESIL expressions - Visual mode offers ESIL debugging capabilities through the
VdEcommand
These features allow users to inspect register states, memory modifications, and operation flow without actually executing the binary code on the CPU. Literally the whole point. π
π ESIL COMMANDS π
radare2 leverages ESIL for detailed emulation of instruction execution, enabling users to step through instructions, inspect changes to registers and memory, and evaluate conditional logic in a controlled environment. It's giving microscope for code. π¬
Here are the most commonly used ESIL-related commands:
ae [expr]β evaluate an ESIL expression. Note that some expressions contain special characters that can be evaluated by theradare2shell, so it's better to prefix the command with a single quote'to skip that parsing.aeiβ initialize the ESIL VM state (required before emulation)aeimβ initialize ESIL VM stack memoryaeipβ initialize ESIL program counter to current offsetaerβ show or modify ESIL registersaesβ ESIL Step: execute a single step in ESIL emulationaesoβ ESIL Step Over: perform a step over call instructions in ESIL emulationaesu [addr]β ESIL Step Until: continue ESIL execution until a specified address is reachedaev [expr]β enter the interactive visual debugger to debug and emulate an ESIL expression
Typical workflow for ESIL emulation:
aei # Initialize ESIL VM state
aeim # Initialize memory for ESIL VM
aeip # Set program counter to current address
aes # Start stepping through instructions
π₯ ESIL OPERATION CATEGORIES π₯
The comma-separated words in an ESIL expression can be grouped into different categories:
Internal flags
Prefixed with $, they represent internal states of the ESIL VM and are used to perform conditional operations:
$zβ Zero flag: set when result is zero$cβ Carry flag: set when operation produces a carry$bβ Borrow flag: set when operation requires a borrow$pβ Parity flag: set when result has even parity$sβ Sign flag: set when result is negative$oβ Overflow flag: set when result overflows$$β current address being executed$ds,$jt,$jsβ used for delay slots and jump targeting
Assignment operations
Pop value and destination from stack and perform assignment:
=β strong assignment (updates flags):=β weak assignment (no flag updates)
Arithmetic and binary operations
Basic math operations:
+β addition-β subtraction*β multiplicationL*β long multiplication (128-bit result)/β division~/β signed division%β modulo~%β signed modulo~β sign extension&β bitwise AND|β bitwise OR^β bitwise XOR!β logical NOT<<β left shift>>β right shiftROLβ rotate leftRORβ rotate rightASRβ arithmetic shift right, signed at the width of the value's registerCLZβ count leading zeros of a value within an explicit widthPOPCNTβ count the set bits of a value
An operation takes an explicit leading width operand only when its result depends on that width: CLZ does (the count for 1 is 31 at width 32 and 63 at width 64), POPCNT does not.
The shifts are total: <<, >> and ASR by a count of 64 or more push 0, 0 and the sign fill respectively, and ASR of a register by its width or more pushes the sign fill.
Comparison operations
Compare values and set flags:
==β equality comparison<β less than<=β less than or equal>β greater than>=β greater than or equal
Control flow
Conditional expressions and flow control:
?{β if condition, execute next block if top of stack is non-zero}β end of conditional block}{β else statementGOTOβ jump to specified locationBREAKβ stop execution
Memory access
Read from or write to memory:
- Reading:
[1],[2],[4],[8],[16]β read1,2,4,8, or16bytes - Writing:
=[1],=[2],=[4],=[8],=[16]β write1,2,4,8, or16bytes - Combined:
|=[2],+=[4],&=[4],--=[2]β read-modify-write operations - Special:
[*],=[*]β variable size operations
Stack manipulation
Special operations to manage the ESIL stack:
STACKβ display stack contentsPOPβ remove top valueDUPβ duplicate top valueNUMβ push number or register valueSWAPβ swap top two valuesROTβ rotate the third stack element to the top:[x,y,z]becomes[y,z,x]CLEARβ empty the stack
Special operations
()β syscall$β hardware interrupt#!β executeradare2commandTRAPβ CPU trapBITSβ change bits mode
Floating point operations
NANβ check if value is Not-a-NumberI2D,U2Dβ convert integer to double (signed, unsigned)D2Iβ convert double to integerD2F,F2Dβ convert between double and floatF==,F!=,F<,F<=β floating point comparisonsF+,F-,F*,F/β floating point arithmetic-Fβ negate floating point valueCEIL,FLOOR,ROUNDβ rounding operationsSQRTβ square root
π UNDERSTANDING ESIL EXPRESSIONS π
ESIL expressions are evaluated from left to right, with values being pushed onto or popped from a stack. The following examples demonstrate how common CPU instructions translate to ESIL:
mov eax, 0x3
Simply assigns the value 3 to register eax:
3,eax,=
add ebx, eax
Adds the value in eax to ebx and stores the result in ebx:
eax,ebx,+=
This is equivalent to the longer form:
eax,ebx,+,ebx,=
xor eax, eax
Performs XOR on eax with itself (effectively zeroing it):
eax,eax,^=
mov byte [ebx], 0x3
Writes the value 3 to the memory address in ebx:
3,ebx,=[1]
test eax, eax
Sets flags based on eax value (primarily the zero flag):
eax,eax,&,zf,=
jz 0x123456
Jumps to address if zero flag is set:
zf,?{,0x123456,eip,=,}
π VISUAL ESIL DEBUGGER π
radare2 provides a visual ESIL debugger that allows stepping through ESIL expressions to understand exactly how they work. This is accessed through the aev command or in visual mode with VdE. π§
The visual ESIL debugger offers several advantages:
- Step-by-step execution of ESIL expressions
- Visualization of the stack after each operation
- Inspection of register and flag changes
- Memory access monitoring
- Finer-grained control than regular ESIL emulation
When using the visual ESIL debugger, you can use the following controls:
- s β step forward one ESIL operation
- r β reset the ESIL VM state
- q β quit the debugger
This tool is particularly useful for understanding complex instructions or when debugging emulation issues.
πΈ PRACTICAL USAGE EXAMPLES πΈ
okay bestie, this is the part where it stops being theory and starts being hands on keyboard π here's how you actually use ESIL in radare2 for analysis and debugging, fr fr:
β¨ Basic ESIL evaluation β¨
so to evaluate a simple ESIL expression, you just hit it with:
[0x00000000]> ae 1,1,+
2
and boom, it gives you 2 back β math is mathing π₯
π Step-by-step emulation π
to emulate a function and actually see the register changes happen, do this little ritual in order:
[0x00000000]> aei # Initialize ESIL VM
[0x00000000]> aeim # Initialize memory
[0x00000000]> aeip # Set PC to current address
[0x00000000]> aes # Step one instruction
[0x00000000]> aer # View registers
like, aei wakes the VM up, aeim gives it a memory to live in, aeip points the PC at the current address, aes steps one (1) single instruction, and aer is your vibe check for the registers π«Ά so iconic honestly
π¦ ESIL debugging of an expression π¦
wanna debug a complex ESIL expression with the visual debugger? just:
[0x00000000]> aev 1,5,+,eax,=
the visual debugger ate that assignment expression up, no cap β¨
π Conditional emulation π
to emulate until a condition is met:
[0x00000000]> aecu 0x4000 # Continue until address 0x4000
it just keeps going until it reaches 0x4000, periodt π
π R2WARS π
okay so this is literally the fun one β a code-wars-like game built on top of ESIL, used at the r2con conference π₯ players write small programs that compete in a virtual arena, and the ESIL VM is the one executing and evaluating their behavior. main character energy for the VM honestly π
more info: https://github.com/radareorg/r2wars
β SEE ALSO β
π WWW π
π AUTHORS π
- pancake <pancake@nopcode.org>
k that's the whole page bestie, you're officially ESIL-pilled π§π« and just so you have the receipts: this was ESIL(7) from August 26, 2026 β go forth and emulate, love u ππΈ
π¦ where this page comes from
- arch rolling: radare2 6.2.2-1 Β· GPL-3.0-only AND LGPL-3.0-only
- nixpkgs unstable: radare2 6.2.4
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 Β· GPL-3.0-only AND LGPL-3.0-only
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 Β· GPL-3.0-only AND LGPL-3.0-only
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 Β· GPL-3.0-only AND LGPL-3.0-only
- opensuse-leap 16.0: radare2 6.2.2-bp160.1.1 Β· GPL-3.0-only AND LGPL-3.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms