From 938d7041f117a1ce26d42b19342280c9c8f93da7 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 29 Aug 2020 14:18:41 +0100 Subject: [PATCH] add wat to write out raw binary assembled programs --- src/soc/simulator/program.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/soc/simulator/program.py b/src/soc/simulator/program.py index aeb33a23..17950cda 100644 --- a/src/soc/simulator/program.py +++ b/src/soc/simulator/program.py @@ -110,5 +110,20 @@ class Program: self.binfile.seek(curpos, 0) return size + def write_bin(self, fname): + self.reset() + data = self.binfile.read() + with open(fname, "wb") as f: + f.write(data) + def close(self): self.binfile.close() + +if __name__ == '__main__': + lst = ['addi 5, 0, 4660', + 'mtcrf 255, 5', + 'mfocrf 2, 1', + 'attn', + ] + with Program(lst, False) as p: + p.write_bin("/tmp/test.bin") -- 2.30.2