action='store_true', help="Output as little endian") parser.add_argument('-v', '--verbose', default=False, action='store_true', help="Be verbose") args = vars(parser.parse_args()) f = open(args['filename']) lines = f.readlines() lines = [x.replace("\n", "") for x in lines] f.close() mp = mips.MIPSProgram(text_base=args['text_base'], data_base=args['data_base']) mp.AddLines(lines) output = open(args['output'], 'w') if 'output' in args else None endianness = "little" if args['littleendian'] else "top" if 'output' in args: with open(args['output'], 'w') as out: print("Writing text to '%s'..." % (args['output']), end=' ') bytes = mp.Bytes(endian=endianness) for b in bytes: out.write("%c" % (b, )) print("done!") if 'data_out' in args: with open(args['data_out'], 'w') as out:
if simulator == 'modelsim': for i in range(0, num_bytes): out.write("00\n") elif simulator == 'xilinx': for i in range(0, num_bytes / 4): out.write("00000000,\n") args = vars(parser.parse_args()) f = open(args['filename']) lines = f.readlines() lines = [x.replace("\n", "") for x in lines] f.close() mp = mips.MIPSProgram(text_base=text_base, data_base=data_base) mp.AddLines(lines) output = open(args['output'], 'w') if 'output' in args else None endianness = "little" if args['littleendian'] else "top" if 'output' in args: #text_base = int(args['text_base'],16) start_addr = text_base + mp.Label("main") * 4 spu_int_addr = text_base + mp.Label("SPU_IRQ") * 4 spart_int_addr = text_base + mp.Label("SPART_IRQ") * 4 with open(args['output'], 'w') as out: print "Writing text to '%s'..." % (args['output']), bytes = mp.Bytes(endian=endianness) if args['simulator'] == 'modelsim': out.write("@0\n")
tmp = f.read(1) if t == 4: t = 0 lines.append(ans) ans = 0 else: with open(args['inputFile'], "r") as f: tmp = f.readline() tmp = f.readline() tmp = f.readline()[:-2] while tmp: t = tmp.split(' ') num = int(t[0], 16) * 256 * 256 * 256 + int(t[1], 16) * 256 + int(t[2], 16) * 256 + int(t[3], 16) lines.append(num) tmp = f.readline()[:-2] mp = mips.MIPSProgram(textBase = 0, dataBase = 0x4000) mp.addLines(lines) f, e = os.path.splitext(args['inputFile']) output = args['output'] if 'output' in args else f + '.asm' with open(output, 'w') as out: # print "Writing asm to '%s..." %(args['output']), data = mp.Data() for ans in data: out.write(ans) out.write('\n') print os.path.dirname(os.path.abspath(args['inputFile'])) # print "Done!"