Commit da4ee7c9 authored by Jan Pospisil's avatar Jan Pospisil

added non-zero word highlight in memory printing function hexDump

parent 058fb484
......@@ -62,36 +62,46 @@ def hexDump( dataArray, bitsPerWord = 32, binary = False, columns = 8 ):
if i != 0:
sys.stdout.write("\n")
sys.stdout.write( "%4x: "%(i*(bitsPerWord/8)) )
if word != 0:
sys.stdout.write(ConColors.BOLD)
if binary:
sys.stdout.write( toBin(word, bitsPerWord) + " " ) # binary format
else:
sys.stdout.write( ("%%0%dx "%(bitsPerWord/4))%word ) # hex format
sys.stdout.write(ConColors.NONE)
i += 1
sys.stdout.write("\n")
def PrintBit(value, bit, label, ifSet, ifNotSet):
def PrintBit(value, bit, label, ifSet = "", ifNotSet = ""):
print(" "+"["+str(bit)+"] "+label+":")
if value & (1<<bit):
print(ConColors.GREEN+" 1: "+ifSet+ConColors.NONE)
else:
print(ConColors.RED+" 0: "+ifNotSet+ConColors.NONE)
def PrintBits(value, bitFrom, bitTo, label, descriptions):
def PrintBits(value, bitFrom, bitTo, label, descriptions=()):
print(" "+"["+str(bitTo)+":"+str(bitFrom)+"] "+label+":")
value &= (1<<bitTo+1)-1
value >>= bitFrom
color = ConColors.YELLOW
description = descriptions[value]
if value > len(descriptions)-1:
color = ConColors.RED
description = "<unknown>"
else:
description = descriptions[value]
print(color+" "+str(value)+": "+description+ConColors.NONE)
def ErrorMsg(Text):
print(ConColors.RED+ConColors.BOLD+"!!! Error: "+ConColors.NONE+ConColors.RED+Text+ConColors.NONE)
def WarningMsg(Text):
print(ConColors.YELLOW+ConColors.BOLD+"Warning: "+ConColors.NONE+ConColors.YELLOW+Text+ConColors.NONE)
def InfoMsg(Text):
print(ConColors.CYAN+ConColors.BOLD+"Info: "+ConColors.NONE+Text)
def OkMsg(Text):
print(ConColors.GREEN+ConColors.BOLD+"OK: "+ConColors.NONE+Text)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment