1
0
mirror of https://github.com/DoctorWkt/unix-jun72.git synced 2026-02-02 06:51:49 +00:00
Files
DoctorWkt.unix-jun72/tools/fixaout.py
tim.newsham 92b192ed1e - Fixed tools/as to use the v2 assembler instead of the v7 assembler,
which also required some tweaks to tools/fixaout.py
- update init patch to use v2 assembler and also added my patch to
  use tty8.
2008-05-06 23:09:07 +00:00

32 lines
599 B
Python
Executable File

#!/usr/bin/env python
"""
Convert an 0407 binary into an 0405 binary, under the assumption
that the code starts at 040014 (by ".. = 40014").
See tools/as.
"""
import struct
def words(bs) :
l = len(bs) / 2
return list(struct.unpack('<%dH' % l, bs))
def unwords(ws) :
l = len(ws)
return struct.pack('<%dH' % l, *ws)
def read(fn) :
f = file(fn, 'rb')
d = f.read()
f.close()
return d
def write(fn, d) :
f = file(fn, 'wb')
f.write(d)
f.close()
d1 = words(read('a.out'))
hdr = d1[:8]
d = [0405, hdr[1], 0, 0, hdr[4], 0] + d1[8:]
write("b.out", unwords(d))