Files
vt1200/lat/notes/dd.py
T

32 lines
843 B
Python

#!/usr/bin/env python3
"""Dump dis34 lines for a BYTE-offset range.
The cached disassembly (reference/dis34-a-v22.txt.gz) prints *bit* addresses:
displayed = byte_offset * 8. We accept byte offsets and convert.
Usage: dd.py START_OFF END_OFF [--hex]
START_OFF/END_OFF may be decimal or 0x-prefixed.
"""
import gzip, re, sys
PATH = "reference/dis34-a-v22.txt.gz"
def main():
start = int(sys.argv[1], 0)
end = int(sys.argv[2], 0)
with gzip.open(PATH, "rt", errors="replace") as f:
out = []
for line in f:
m = re.match(r"^([0-9a-fA-F]{6,8}):", line)
if m:
a = int(m.group(1), 16)
byte = a >> 3
if start <= byte < end:
out.append(line.rstrip("\n"))
print("\n".join(out))
if __name__ == "__main__":
main()