#!/usr/bin/python import re import os fd = os.popen("avr-objdump -d firmware.bin") regcount = [0]*32 s="foo" while s: s=fd.readline() m=re.findall(r"[ \n\t,;]r(\d\d?)[ \n\t,;]",s) if m: for i in m: regcount[int(i)] += 1; for i in range(16): print "r%2d: %4d"%(i,regcount[i]), print "\tr%2d: %4d"%(i+16,regcount[i+16])