OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [resources/] [connotate-fuse.py] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 gdevic
#!/usr/bin/env python3
2 3 gdevic
#
3
# This script connotates fuse test files with Z80 opcode strings.
4
# Run it once to convert original fuse files to a new, connotated format.
5
#
6
#-------------------------------------------------------------------------------
7
#  Copyright (C) 2014  Goran Devic
8
#
9
#  This program is free software; you can redistribute it and/or modify it
10
#  under the terms of the GNU General Public License as published by the Free
11
#  Software Foundation; either version 2 of the License, or (at your option)
12
#  any later version.
13
#
14
#  This program is distributed in the hope that it will be useful, but WITHOUT
15
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17
#  more details.
18
#-------------------------------------------------------------------------------
19
import string
20
import os
21
import sys
22
 
23
op = {}
24
 
25
# Read all available Z80 opcode strings that we have, hash them by the opcode
26
def load(opcodeFile):
27
    global op
28
    with open(opcodeFile) as fIn:
29
        for line in fIn:
30
            (opcode, mnemonic) = (line.split()[0], line[12:])
31
            # Special case with ddcb and fdcb where our two formats slightly differ
32
            if opcode=="DDCB" or opcode=="FDCB":
33
                (opcode, mnemonic) = (line.split()[0]+line.split()[2], line[12:])
34
            op[opcode] = mnemonic.rstrip()
35
 
36
load("opcodes-xx.txt")
37
load("opcodes-cb-xx.txt")
38
load("opcodes-dd-cb.txt")
39
load("opcodes-dd-xx.txt")
40
load("opcodes-ed-xx.txt")
41
load("opcodes-fd-cb.txt")
42
load("opcodes-fd-xx.txt")
43
 
44
if len(sys.argv)!=2:
45 8 gdevic
    print ("Usage:", sys.argv[0], "<fuse-test-file>")
46 3 gdevic
    exit(0)
47
file = sys.argv[1]
48
 
49
with open(file) as f, open(file+".out", "wt") as f2:
50
    for line in f:
51
        line = line.rstrip()
52
        if line is None: break
53
        parts = line.split()
54
        note = ""
55
        if len(parts)==1 and parts[0]!="-1":
56
            index = parts[0].split("_")[0].upper()
57
            if index in op:
58
                note = " " + " "*(7-len(parts[0])) + op[index.upper()]
59
        f2.write(line + note + "\n")
60 8 gdevic
        print (line + note)

powered by: WebSVN 2.1.0

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