Skip to content

Instantly share code, notes, and snippets.

@zonque
Created July 9, 2018 11:17
Show Gist options
  • Save zonque/83ee303fe434e3da7df935261d09b1b2 to your computer and use it in GitHub Desktop.
Save zonque/83ee303fe434e3da7df935261d09b1b2 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
#
# Reads lines from STDIN such as
#
# 00000001 01234578
#
# and assumes that the first column is a register offset and the 2nd is a value.
#
# Will then output the all registers ever accessed with the value they were set to last.
#
regs = {}
STDIN.read.split("\n").each do |line|
a = line.split(' ')
regs[a[0]] = a[1]
end
regs.sort.to_h.each do |reg, val|
print "#{reg}: #{val}\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment