diff options
Diffstat (limited to 'sw/convert.py')
-rw-r--r-- | sw/convert.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/sw/convert.py b/sw/convert.py index c96b83c..bd8ab2b 100644 --- a/sw/convert.py +++ b/sw/convert.py @@ -19,18 +19,18 @@ def main(argv): data_addr = int(argv[0]) last_addr = int(argv[1]) except: - print "Wrong arguments" + print ("Wrong arguments") return if(parse("text.vh", "text.rom", data_addr) < 0): - print "Wrong text file" + print ("Wrong text file") return if(parse("data.vh", "data.rom", last_addr - data_addr) < 0): - print "Wrong text file" + print ("Wrong text file") return - print "Convertion was successfull" + print ("Convertion was successfull") def parse(file_name, rom_name, addr_last): @@ -39,6 +39,7 @@ def parse(file_name, rom_name, addr_last): rom_file.truncate() hex_parts = hex_file.readline() + line = "" try: hex_parts.index("@") @@ -48,27 +49,29 @@ def parse(file_name, rom_name, addr_last): attached = 0 words = 0 - rom_file.writelines("@00000000\n"); + rom_file.write("@00000000\n"); while(1): hex_parts = hex_file.readline() + hex_parts = hex_parts.translate(None, "\n\r") hex_parts = hex_parts.split(" "); - if(len(hex_parts) == 1): + if(len(hex_parts) < 4): break - for part in hex_parts: + for part in hex_parts: - if(part == "\n"): - continue + if(len(part) == 0): + continue - rom_file.write(part) + line += part attached += 1 if(attached == 4): attached = 0 words += 1 - rom_file.write("\n") + rom_file.write(line + "\n") + line = "" for i in range(addr_last - words): rom_file.write("00000000\n") |