Пример #1
0
 def __getMachine(self, machine, mslfile, mslpath, debug=False):
     mslproc = msldb.MSL(default=None, pathmgr=mslpath, debug=debug)
     mslproc.build(mslfile, fail=True)
     cpux = mslproc.expand(machine)  # Return the expanded version of cpu
     self.addrsize = cpux.addrmax  # Set the maximum address size for CPU
     self.ccw = cpux.ccw  # Set the expected CCW format of the CPU
     self.psw = cpux.psw  # Set the expected PSW format of the CPU
     cache = MSLcache(cpux)  # Create the cache handler
     return cache
Пример #2
0
    def inst_report(self):
        # A MSL DB is captured so the INTBL object can create format statistics
        # for all defined formats, not just the ones in the selected cpu(s).
        mslfmt = None

        if len(self.cpus) == 0:
            print("inst report requires one or more --cpu arguments")
            return
        files = {}
        # Create a dictionary by filename of a list the the requested cpu(s)
        for filename, cpu in self.cpus:
            fn = files.setdefault(filename, [])
            if cpu not in fn:
                fn.append(cpu)
            files[filename] = fn

        # Attach the database to its filename in the dictionary
        dbs = {}
        for filename in files.keys():
            msl = msldb.MSL(default=MSLRPT.DEFAULT)
            errors = msl.build(filename, fail=True)
            if errors:
                print("MSL errors encountered in file: %s" % filename)
                continue
            # No errors so extract the database for the file and create dictionary
            db = msl.DB()
            if not mslfmt:
                mslfmt = db
            dbs[filename] = db

        # Create a list of the expanded CPU definitions requested
        cpux = []  # This is a list of tupples: (filename,msldb.CPUX)
        col = 0
        for filename, cpu in self.cpus:
            db = dbs[filename]
            try:
                cpu = db[cpu]
            except KeyError:
                print("MSL file %s does not define cpu: %s" % (filename, cpu))
            cpu_ex = cpu.expand(db)
            cpux.append(CPU(col, filename, cpu_ex))
            col += 1

        # Build the Instruction Table
        itbl=ITBL(len(cpux),self.seq,msl=mslfmt,\
            extend=self.extend,linesize=self.line)
        for c in cpux:
            itbl.cpu(c)
        itbl.validate()  # Valid the instructions

        # Print the instruction report
        itbl.prepare()  # Prepare to do the report
        if self.listing is None:
            print(itbl.generate())
        else:
            itbl.generate(filename=self.listing)
Пример #3
0
    def __init__(self, args):
        self.mslfile = args.mslfile[0]  # Input MSL text file

        # Normal processing options
        self.expand = args.expand  # Expand a cpu statment with dependencies
        self.fail = args.fail  # If True fail immediately on an error
        self.xref = args.xref  # Print the cross-reference listing

        # Diagnostic options
        self.dump = args.dump  # Dump the final output DB

        # The Machine Language Specification Processor
        self.dbp = msldb.MSL(default=satkutil.satkdir("asma/msl", debug=False))
Пример #4
0
 def cpu_report(self):
     files = self.__find_files()
     mslf = {}
     for filename in sorted(files):
         msl = msldb.MSL(default=MSLRPT.DEFAULT)
         errors = msl.build(filename)
         if errors:
             print("MSL errors encountered in file: %s" % f)
             continue
         db = msl.DB()
         cpus = []
         for entry in db.iter_entries():
             if isinstance(entry, msldb.CPU):
                 cpus.append(entry.ID)
         if len(cpus) > 0:
             mslf[filename] = cpus
     print("Available CPUs:")
     for f, cpus in mslf.items():
         strcpus = ""
         for c in sorted(cpus):
             strcpus = "%s, %s" % (strcpus, c)
         strcpus = strcpus[2:]
         print("    %s: %s" % (f, strcpus))
Пример #5
0
 def __find_files(self):
     msl = msldb.MSL(default=MSLRPT.DEFAULT)
     path = msl.opath  # Reach in and get the path manager
     return path.files(MSLRPT.PATHVAR, ext=".msl")