PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux
No Result
View All Result
PikoPong
No Result
View All Result
Home Web Dev

Binary Tools

May 25, 2020
in Web Dev
286 6
Binary Tools


I’ve been tinkering on a 6502 project during the evenings spread over the last 3 months (via the excellent Ben Eater series) and in doing so I’ve started to build up a series of tools I use with binary.

(This post is probably only useful for future Remy)

READER DISCOUNTSave $50 on terminal.training

I’ve published 38 videos for new developers, designers, UX, UI, product owners and anyone who needs to conquer the command line today.

$49 – only from this link

I should add that I’m not sure how much of this will work on different systems and availability of tools, but I’ll link where possible.

hexdump

hexdump – usually with hexdump -C file.bin to view hex and ascii output. Also compresses repeating patterns seen below where the line is simply *.

Really simple to use tool for viewing source hex on the command line.

hexdump -C rom.bin
00000000  a9 ff 8d 02 60 a9 55 8d  00 60 a9 aa 8d 00 60 4c  |....`.U..`....`L|
00000010  05 80 ea ea ea ea ea ea  ea ea ea ea ea ea ea ea  |................|
00000020  ea ea ea ea ea ea ea ea  ea ea ea ea ea ea ea ea  |................|
*
00007ff0  ea ea ea ea ea ea ea ea  ea ea ea ea 00 80 ea ea  |................|
00008000

xxd

xxd can dump hex from binary, but also convert hex to binary.

This is used for dumping the entire hex content out. It also has a revert feature that lets me generate binary files from strings of hex. I’ve been doing a bit of work around unpacking old file formats, and generating snippet of binary data is useful.

Below you can see my generating a binary snippet for a ZX Spectrum+ .bas file header. The first column needs to be the offset (0 in this case).

echo "0 504c 5553 3344 4f53 1a01 00e7 0000 00" | xxd -r | hexdump -C
00000000  50 4c 55 53 33 44 4f 53  1a 01 00 e7 00 00 00     |PLUS3DOS.......|
0000000f

I could capture this output using … | xxd -r > out.bin and then process the binary elsewhere.

diffing binary / diffing hex

Using xxd above, I can combine diff tools to identify changes between binary (typically where I’ve got a typo and generated a slightly different file).

$ diff -u <(xxd -c 32 a.bin) <(xxd -c 32 b.bin) | diff-so-fancy

I’m adding diff-so-fancy into the mix to clearly highlight the changes in the file (the diff -u flag is needed to make this work properly).

Visual hex diff

In the diff above I can clearly see that the first block starts to match, but the does not.

Honourable mentions



Source link

Share219Tweet137Share55Pin49

Related Posts

You want minmax(10px, 1fr) not 1fr
Web Dev

You want minmax(10px, 1fr) not 1fr

There are a lot of grids on the web like this: .grid { display: grid; grid-template-columns: repeat(3, 1fr); }...

January 22, 2021
Servers: Cool Once Again | CSS-Tricks
Web Dev

Servers: Cool Once Again | CSS-Tricks

There were jokes coming back from the holiday break that JavaScript decided to go all server-side. I think it...

January 22, 2021
When To Say No To Freelance Projects — Smashing Magazine
Web Dev

When To Say No To Freelance Projects — Smashing Magazine

About The AuthorBecca is a UX Researcher with a PhD in Human Factors Psychology. She runs the UX consulting...

January 22, 2021
useStateInCustomProperties | CSS-Tricks
Web Dev

useStateInCustomProperties | CSS-Tricks

In my recent “Custom Properties as State” post, one of the things I mentioned was that theoretically, UI libraries, like...

January 21, 2021
Next Post
prefers-color-scheme: Hello darkness, my old friend

prefers-color-scheme: Hello darkness, my old friend

Using CopyQ Clipboard Manager on Linux

Using CopyQ Clipboard Manager on Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

How to Connect to WiFi from the Terminal in Ubuntu Linux

How to Connect to WiFi from the Terminal in Ubuntu Linux

September 8, 2020
Core Web Vitals | CSS-Tricks

Core Web Vitals | CSS-Tricks

May 29, 2020
Using GitHub Actions for MLOps & Data Science

Using GitHub Actions for MLOps & Data Science

June 17, 2020
How to Add Text in Borders Using Basic HTML Elements

How to Add Text in Borders Using Basic HTML Elements

December 1, 2020

Categories

  • AWS
  • Big Data
  • Database
  • DevOps
  • IoT
  • Linux
  • Web Dev
No Result
View All Result
  • Web Dev
  • Hack
  • Database
  • Big Data
  • AWS
  • Linux

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In