Skip to content

Instantly share code, notes, and snippets.

@ctslater
Created January 13, 2020 04:23
Show Gist options
  • Save ctslater/a98eb89b1e776dd0478b7aa5aa75c6f6 to your computer and use it in GitHub Desktop.
Save ctslater/a98eb89b1e776dd0478b7aa5aa75c6f6 to your computer and use it in GitHub Desktop.
3ESS tape format printer
#!/usr/bin/env python
import struct
import sys
if __name__ == '__main__':
filename = sys.argv[1]
f = open(filename, "rb")
read_len = 50
# Read in big-endian bytes
while True:
data = f.read(2*read_len)
if(len(data) == 0):
break
successful_len = len(data)//2
preamble = struct.unpack(f'>{successful_len}H', data)
for word in preamble:
# Reverse the entire word
binary_word = "{:016b}".format(word) # [::-1]
binary = (" ".join((binary_word[0:4],
binary_word[4:8],
binary_word[8:12],
binary_word[12:])))
octal = "{:07o}".format(word)
print(binary, " | ", octal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment