diff options
author | Snuffick <aleks.bae@gmail.com> | 2015-12-11 11:32:10 +0300 |
---|---|---|
committer | Snuffick <aleks.bae@gmail.com> | 2015-12-11 11:32:10 +0300 |
commit | c507aaed43ffb10a3b5a115916438ec414969146 (patch) | |
tree | 41947c0d34e11ee3e549dcc8975bae33d497a6cb /sw | |
parent | 49f076385c73b738acb508c3806678f058d4ceb6 (diff) | |
download | MIPSLabs-c507aaed43ffb10a3b5a115916438ec414969146.zip MIPSLabs-c507aaed43ffb10a3b5a115916438ec414969146.tar.gz MIPSLabs-c507aaed43ffb10a3b5a115916438ec414969146.tar.bz2 |
Исправлена ошибка в скрипте convert.py
Diffstat (limited to 'sw')
-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") |