The file I'm working on contains a hexdump. I pulled it directly out of memory, so it starts from an arbitrary offset, like this:
0x1234: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1244: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1254: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1264: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
I want to "rebase" this hexdump so it looks like this:
0x0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
This means I need to subtract the value 0x1234 from each of those values. My current workflow looks like this:
- Fire up a python interpreter and convert 0x1234 to base-10 (it's 4660)
- Position the cursor over the first 0x1234 in my file
- Input
4660
Ctrl-x - Repeatedly input
j.
until I've hit all the lines
That first step is really annoying - since I'm working with hexadecimal numbers, it feels like I ought to be able to subtract a hexadecimal value directly, rather than converting via base-10.
Is there an easier way to do this?