Created
March 9, 2014 05:42
-
-
Save NorimasaNabeta/9443352 to your computer and use it in GitHub Desktop.
binary dump for the register hexdump output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: tcl; coding: utf-8 -*- | |
# | |
# | |
# | |
# binary dump | |
# | |
proc binDump { dump } { | |
if { [regexp {0x([0-9a-fA-F]+)} $dump result longhex] > 0 } { | |
set sz [string length $longhex] | |
set startpos [expr $sz - 4] | |
for { set x $startpos } { $x > -4 } { incr x -4 } { | |
set y $x | |
incr y 3 | |
if { $x < 0 } { | |
set x 0 | |
} | |
set tmp [string range $longhex $x $y] | |
binary scan [binary format H* $tmp] B* bits | |
puts [format "%02d-%02d: %-4s %s" [expr $sz - $x -1] [expr $sz -$y -1] $tmp $bits] | |
} | |
} | |
} | |
# | |
# | |
# | |
if { $argc > 0 } { | |
foreach fwork $argv { | |
set fl [open $fwork] | |
set data [read $fl] | |
foreach tmp [split $data \n] { | |
puts $tmp | |
binDump $tmp | |
} | |
if {[catch {close $fl} err]} { | |
puts "open failed: $err" | |
} | |
} | |
} else { | |
puts "Usage: tclsh binDump.tcl regdump.txt" | |
} | |
# Local Variables: | |
# mode:tcl | |
# End: | |
# | |
# EOF | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment