import enum as _enum
import sys as _sys
import os as _os
-from io import BytesIO
from openpower.decoder.power_enums import (
find_wiki_dir as _find_wiki_dir,
def load(ifile, byteorder=ByteOrder.LITTLE, **_):
byteorder = str(byteorder)
- # copy over to persistent binfile (BytesIO)
- cpfile = BytesIO()
- cpfile.write(ifile.read())
- cpfile.seek(0)
-
while True:
- insn = cpfile.read(4)
+ insn = ifile.read(4)
length = len(insn)
if length == 0:
return
raise IOError(insn)
insn = _WordInstruction.integer(value=insn, byteorder=byteorder)
if insn.PO == 0x1:
- suffix = cpfile.read(4)
+ suffix = ifile.read(4)
length = len(suffix)
if length == 0:
yield insn
insn = _PrefixedInstruction.pair(prefix=prefix, suffix=suffix)
yield insn
- cpfile.seek(0) # restore position so that generator can be reused
-
def dump(insns, verbosity, **_):
db = _Database(_find_wiki_dir())
from openpower.decoder.power_enums import find_wiki_dir
from openpower.sv import sv_binutils_fptrans
import unittest
+from io import BytesIO
import itertools
import sys
lst = list(isa)
with Program(lst, bigendian=False) as program:
print ("ops", program._instructions)
+ binfile = BytesIO()
program.binfile.seek(0)
- insns = load(program.binfile)
+ binfile.write(program.binfile.read())
+ program.binfile.seek(0)
+ binfile.seek(0)
+ insns = load(binfile)
#for insn in insns:
#print ("insn", insn)
insns = list(insns)