This guide demonstrates how to load and use assembly files and binary blobs in the Assembly REPL.
demo.asm- Assembly source code filedemo.bin- Pre-compiled binary machine codecreate_demo_binary.py- Script to generate the binary
python3 opasm.pyasm-repl:x64> load_asm demo.asmExpected Output:
Loading assembly file: demo.asm
1: mov rax, 0x1234567890abcdef -> 48b8efcdab9078563412
2: mov rbx, 0x1111 -> 48c7c311110000
3: mov rcx, 0x2222 -> 48c7c122220000
4: add rax, rbx -> 4801d8
5: sub rcx, rbx -> 4829d9
...
Loaded 25 instructions (xxx bytes) at 0x400000
Set instruction pointer to 0x400000
# Execute first instruction and see registers change
asm-repl:x64> step
Stepping: 0x00400000 mov rax, 0x1234567890abcdef
# Registers will show with RAX and RIP in bold (changed)
# Continue stepping
asm-repl:x64> step
asm-repl:x64> step
# Or run multiple instructions
asm-repl:x64> run 5# Show all registers
asm-repl:x64> registers
# Show memory at current instruction pointer
asm-repl:x64> memory $rip 64
# Show disassembly
asm-repl:x64> disasm $rip 10asm-repl:x64> resetasm-repl:x64> load_bin demo.binExpected Output:
Loaded binary file: demo.bin
Loaded 45 bytes at 0x400000
Set instruction pointer to 0x400000
Disassembly preview:
┌─────────────┬──────────────────────────────────────┐
│ Address │ Instruction │
├─────────────┼──────────────────────────────────────┤
│ 0x00400000: │ movabs rax, 0x4142434445464748 │
│ 0x0040000a: │ mov rbx, 0x1000 │
│ 0x00400011: │ add rax, rbx │
│ 0x00400014: │ push rax │
│ 0x00400015: │ mov rcx, 0x200 │
└─────────────┴──────────────────────────────────────┘
# Step through each instruction
asm-repl:x64> step
# Watch RAX become 0x4142434445464748 (ASCII "ABCDEFGH")
asm-repl:x64> step
# Watch RBX become 0x1000
asm-repl:x64> step
# Watch RAX become 0x4142434445465748 (original + 0x1000)
# Continue stepping to see all operations
asm-repl:x64> step
asm-repl:x64> step# Set breakpoint at specific address
asm-repl:x64> bp 0x400014
# Run until breakpoint
asm-repl:x64> run 10
Hit breakpoint at 0x400014# Show memory at current instruction pointer
asm-repl:x64> memory $rip 32
# Set memory at stack pointer
asm-repl:x64> set_mem $rsp 0xdeadbeef
# Show stack
asm-repl:x64> memory $rsp 64# Save current state
asm-repl:x64> save my_session.json
# Reset and reload
asm-repl:x64> reset
asm-repl:x64> load my_session.json# Load assembly file
asm-repl:x64> load_asm demo.asm
# Execute some instructions
asm-repl:x64> run 5
# Add your own instructions
asm-repl:x64> mov r15, 0xcafebabe
asm-repl:x64> xor rax, r15
asm-repl:x64> push r15- Assembly File Loading: Complete programs can be written in files and loaded
- Binary Blob Loading: Pre-compiled machine code can be analyzed
- Real-time Execution: Step through code with immediate visual feedback
- State Change Highlighting: Changed registers/memory appear in bold
- Responsive Display: Registers and stack auto-display based on terminal size
- Register Dereferencing: Use
$registersyntax for dynamic addressing - Mixed Execution: Combine loaded code with interactive assembly
- Large Terminal: You'll see automatic register and stack display with changes highlighted
- Small Terminal: Use manual commands like
registersandmemory $rsp - Tab Completion: Press Tab while typing for instruction/register suggestions
- Multiple Exits: Use
quit,exit, Ctrl+C, or Ctrl+D to exit - Help: Type
helpfor complete command reference
The demo.asm file includes examples of:
- Register initialization and manipulation
- Arithmetic operations (add, sub, multiply)
- Stack operations (push/pop)
- Logical operations (and, or, xor)
- Memory operations with addressing
- Bit manipulation (shift, rotate)