Skip to content

Instantly share code, notes, and snippets.

@taiyoslime
Created December 10, 2020 07:53
Show Gist options
  • Save taiyoslime/8b5849dddb4074e0fce8f1bad022435c to your computer and use it in GitHub Desktop.
Save taiyoslime/8b5849dddb4074e0fce8f1bad022435c to your computer and use it in GitHub Desktop.
# $ ruby reg.rb < CoreMark_RV32I.trace
reg = [""] * 32
reg[0] = "0x00000000"
while inst = gets
lv, rv = inst.split("#")
pc = lv.split(" ")[0][..-2]
# break if pc == "0xXXXX"
unless rv.include?("no destination")
rd, _, val, *_ = rv.split(" ")
val = val[..-2] if val[-1] == ";"
reg[rd[1..].to_i] = val
end
end
reg.each_with_index{ |reg, i|
puts "x#{0 if i < 10}#{i} = #{reg}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment