8000 Improve/clean-up dissambled output format · insighio/micropython-esp32-ulp@b51677d · GitHub
[go: up one dir, main page]

Skip to content

Commit b51677d

Browse files
committed
Improve/clean-up dissambled output format
Now the instruction (hex) and disassembled code will appear on one line next to each other and the bytes are no longer printed with Python specific formatting (not wrapped in b''). This results in a much cleaner looking output. Example output: 40008072 MOVE r0, 4 010000d0 LD r1, r0, 0
1 parent a4867e8 commit b51677d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tools/disassemble.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,24 @@ def chunk_into_words(code, bytes_per_word, byteorder):
162162
return words
163163

164164

165-
def decode_instruction_and_print(i, verbose=False):
166-
print(ubinascii.hexlify(i.to_bytes(4, 'little')))
165+
def print_code_line(i, asm):
166+
lineformat = '{0} {1}'
167+
hex = ubinascii.hexlify(i.to_bytes(4, 'little'))
168+
print(lineformat.format(hex.decode('utf-8'), asm))
169+
167170

171+
def decode_instruction_and_print(i, verbose=False):
168172
try:
169173
ins, name = decode_instruction(i)
170174
except Exception as e:
171-
print(e)
175+
print_code_line(i, e)
172176
return
173177

174-
print(name)
178+
print_code_line(i, name)
175179

176180
if verbose:
177181
for field, val, extra in get_instruction_fields(ins):
178-
print(" {:10} = {:3}{}".format(field, val, extra))
182+
print(" {:10} = {:3}{}".format(field, val, extra))
179183

180184

181185
def disassemble_manually(byte_sequence_string, verbose=False):

0 commit comments

Comments
 (0)
0