forked from jdersch/PDP-8
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbin2load.py
executable file
·38 lines (30 loc) · 895 Bytes
/
bin2load.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
# Convert a ".bin" file to the ".load" decimal ASCII format (memory address plus memory contents)
# used by this emulator
# (This program was used to create focal-8.load and chekmo.load in the repo.)
# You will also need to modify pdp8.py (starting in line 768) if you would like to
# load other programs this way, because right now that code only looks for CHEKMO and FOCAL.
f = open("FOCAL-8.bn", "rb")
g = f.read()
n = 0
origin = 0
out = open("focal-8.load", "w")
while True:
hi = int(g[n])
n += 1
if hi != 0o200:
break
while True:
lo = int(g[n])
wd = (hi << 6) | lo
n += 1
hi = int(g[n])
n += 1
if hi == 0o200:
break
if wd > 0o7777:
origin = wd & 0o7777
else:
print("%4s: %s" % (oct(origin), oct(wd)))
out.write("%u %u\n" % (origin, wd))
origin = (origin + 1) & 0o7777