diff options
Diffstat (limited to 'bindiff')
-rwxr-xr-x | bindiff | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -6,4 +6,19 @@ if [[ $# != 2 ]]; then fi #sdiff -w 150 -Hs <(xxd -b "$1") <(xxd -b "$2") -cmp -l "$1" "$2" | awk '{printf "%08X %02X %02X\n", $1, strtonum(0$2), strtonum(0$3)}' + +cmp -l "$1" "$2" | awk 'function bits2str(bits, data, mask) +{ + if (bits == 0) + return "0" + + mask = 1 + for (; bits != 0; bits = rshift(bits, 1)) + data = (and(bits, mask) ? "1" : "0") data + + while ((length(data) % 8) != 0) + data = "0" data + + return data +} +{printf "%08X %s %s\n", $1, bits2str(strtonum(0$2)), bits2str(strtonum(0$3))}' |