4 # Copyright (C) 2020 Michael Nolan <mtnolan2640@gmail.com>
7 def get_assembled_instruction(instruction
, bigendian
=False):
9 endian_fmt
= "elf64-big"
12 endian_fmt
= "elf64-little"
14 with tempfile
.NamedTemporaryFile(suffix
=".o") as outfile
:
15 args
= ["powerpc64-linux-gnu-as",
19 p
= subprocess
.Popen(args
, stdin
=subprocess
.PIPE
)
20 p
.communicate(instruction
.encode('utf-8'))
23 with tempfile
.NamedTemporaryFile(suffix
=".bin") as binfile
:
24 args
= ["powerpc64-linux-gnu-objcopy",
29 subprocess
.check_output(args
)
30 binary
= struct
.unpack('>i', binfile
.read(4))[0]