Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [resources/] [] - Rev 15

Go to most recent revision | Compare with Previous | Blame | View Log

#!/usr/bin/env python3
# This script connotates fuse test files with Z80 opcode strings.
# Run it once to convert original fuse files to a new, connotated format.
#  Copyright (C) 2014  Goran Devic
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the Free
#  Software Foundation; either version 2 of the License, or (at your option)
#  any later version.
#  This program is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
#  more details.
import string
import os
import sys
op = {}
# Read all available Z80 opcode strings that we have, hash them by the opcode
def load(opcodeFile):
    global op
    with open(opcodeFile) as fIn:
        for line in fIn:
            (opcode, mnemonic) = (line.split()[0], line[12:])
            # Special case with ddcb and fdcb where our two formats slightly differ
            if opcode=="DDCB" or opcode=="FDCB":
                (opcode, mnemonic) = (line.split()[0]+line.split()[2], line[12:])
            op[opcode] = mnemonic.rstrip()
if len(sys.argv)!=2:
    print ("Usage:", sys.argv[0], "<fuse-test-file>")
file = sys.argv[1]
with open(file) as f, open(file+".out", "wt") as f2:
    for line in f:
        line = line.rstrip()
        if line is None: break
        parts = line.split()
        note = ""
        if len(parts)==1 and parts[0]!="-1":
            index = parts[0].split("_")[0].upper()
            if index in op:
                note = " " + " "*(7-len(parts[0])) + op[index.upper()]
        f2.write(line + note + "\n")
        print (line + note)

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.