November 4, 2026

MOD_EMUP - vim and program analysis

Whenever I spend a lot of time using vim to dig around in a disassembly (which is how I do things), I end up thinking about ways to customize vim for things I find myself doing over and over.

The current desire is to jump to a function definition when I have the cursor on the line that calls it. So, if I have my cursor on the following line, I want to do a search for "/^ *0x38e6"

0x2bcd  0x16f:0x14dd   E8160D            call 0x38e6
I accompished this by mapping the "comma" key as follows:
function Jumper()
    let word = expand('<cword>')
    call search ( "^ *" . word )
endfun

noremap , :call Jumper()<cr>
This works fine, and I am itching for more.

Using much the same method, I also set up "-d" to chase references to things in the data segment, so if you see a line like this:

0xed59  0xdb8:0x11d9   803EE21500        cmp byte [0x15e2],0x0
You can put your cursor on 0x1532 and you will be taken to where that is defined in. Note that initialized data ends at 0x3056, so don't try using this on values beyond this.

Currently I have 4 vim mappings to help this project:

, -- go to address under cursor (handy for calls)
-d -- go to data item under cursor
-s -- fetch string at address referenced in this line
-t -- swap bytes
The idea with swapping bytes is that we have items like this:
Data    000111c2 15e2: 0020
Data    000111c2 15e2: 0020 ; 0x2000  (8192)
Typing "-t" with the cursor on the first line will turn it into the second.

Here the two byte value is little endian and is really 0x2000 = 8192 decimal

Both -s and -t use external python programs as helpers.


Have any comments? Questions? Drop me a line!

Tom's Electronics pages / tom@mmto.org